vfwscanf.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include "stdhdr.h"
typedef struct
{
Sfio_t* f; /* original wide stream */
} Wide_t;
/*
* wide exception handler
* free on close
*/
static int
{
if (sffileno(f) >= 0)
return -1;
switch (op)
{
case SF_ATEXIT:
sfdisc(f, SF_POPDISC);
break;
case SF_CLOSING:
case SF_DPOP:
case SF_FINAL:
if (op != SF_CLOSING)
break;
}
return 0;
}
/*
* sfio wide discipline read
* 1 wchar_t at a time
* go pure multibyte for best performance
*/
static ssize_t
{
#if 0
return -1;
wuf[1] = 0;
#else
ssize_t r;
if (r != sizeof(wuf[0]))
return -1;
wuf[1] = 0;
return r;
#endif
}
int
{
size_t n;
int v;
Sfio_t* t;
Wide_t* w;
char buf[1024];
{
{
w->f = f;
{
}
else
{
free(w);
v = -1;
}
sfsetfd(t, -1);
sfclose(t);
}
else
{
free(w);
v = -1;
}
}
else
v = -1;
return v;
}