diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2012-06-24 22:28:35 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2012-06-24 22:28:35 +0000 |
commit | 3950ffe2a485479f6561c27364d3d7df5a21d124 (patch) | |
tree | 468c6e14449d1b1e279222ec32f676b0311917d2 /src/lib/libast/stdio | |
download | ksh-upstream.tar.gz |
Imported Upstream version 93u+upstream
Diffstat (limited to 'src/lib/libast/stdio')
98 files changed, 4069 insertions, 0 deletions
diff --git a/src/lib/libast/stdio/_doprnt.c b/src/lib/libast/stdio/_doprnt.c new file mode 100644 index 0000000..afa160d --- /dev/null +++ b/src/lib/libast/stdio/_doprnt.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +_doprnt(const char* fmt, va_list args, Sfio_t* f) +{ + STDIO_INT(f, "_doprnt", int, (const char*, va_list, Sfio_t*), (fmt, args, f)) + + return sfvprintf(f, fmt, args); +} diff --git a/src/lib/libast/stdio/_doscan.c b/src/lib/libast/stdio/_doscan.c new file mode 100644 index 0000000..d112a40 --- /dev/null +++ b/src/lib/libast/stdio/_doscan.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +_doscan(Sfio_t* f, const char* fmt, va_list args) +{ + STDIO_INT(f, "_doscan", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) + + return sfvscanf(f, fmt, args); +} diff --git a/src/lib/libast/stdio/_filbuf.c b/src/lib/libast/stdio/_filbuf.c new file mode 100644 index 0000000..f74e6d7 --- /dev/null +++ b/src/lib/libast/stdio/_filbuf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int +_filbuf(Sfio_t* f) +{ + STDIO_INT(f, "_filbuf", int, (Sfio_t*), (f)) + + return _sffilbuf(f, 0); +} diff --git a/src/lib/libast/stdio/_flsbuf.c b/src/lib/libast/stdio/_flsbuf.c new file mode 100644 index 0000000..51cbcda --- /dev/null +++ b/src/lib/libast/stdio/_flsbuf.c @@ -0,0 +1,44 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if !STDIO_TRANSFER + +NoN(_flsbuf) + +#else + +#if defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern int +_flsbuf(int c, Sfio_t* f) +{ + STDIO_INT(f, "_flsbuf", int, (int, Sfio_t*), (c, f)) + + return _sfflsbuf(f, c); +} + +#endif diff --git a/src/lib/libast/stdio/_stdfun.c b/src/lib/libast/stdio/_stdfun.c new file mode 100644 index 0000000..5858903 --- /dev/null +++ b/src/lib/libast/stdio/_stdfun.c @@ -0,0 +1,80 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 <ast.h> + +#if !_UWIN + +void _STUB_stdfun(){} + +#else + +#include <ast_windows.h> +#include <uwin.h> +#include <dlfcn.h> +#include "FEATURE/uwin" + +#if _lib___iob_func +#define IOB ((char*)__iob_func()) +#elif _lib___p__iob +#define IOB ((char*)__p__iob()) +#elif _dat__iob +#define IOB ((char*)_iob) +#else +#define IOB ((char*)_p__iob()) +#endif + +#define IOBMAX (512*32) + +#include "stdhdr.h" + +int +_stdfun(Sfio_t* f, Funvec_t* vp) +{ + static char* iob; + static int init; + static void* bp; + static void* np; + + if (!iob && !(iob = IOB)) + return 0; + if (f && ((char*)f < iob || (char*)f > iob+IOBMAX)) + return 0; + if (!vp->vec[1]) + { + if (!init) + { + init = 1; + bp = dlopen("/usr/bin/stdio.dll", 0); + } + if (bp && (vp->vec[1] = (Fun_f)dlsym(bp, vp->name))) + return 1; + if (!np && !(np = dlopen("/sys/msvcrt.dll", 0))) + return -1; + if (!(vp->vec[1] = (Fun_f)dlsym(np, vp->name))) + return -1; + } + return 1; +} + +#endif diff --git a/src/lib/libast/stdio/_stdopen.c b/src/lib/libast/stdio/_stdopen.c new file mode 100644 index 0000000..dc99778 --- /dev/null +++ b/src/lib/libast/stdio/_stdopen.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +/* OBSOLETE 20010101 -- use fdopen */ + +#include "stdhdr.h" + +extern Sfio_t* +_stdopen(int fd, const char* mode) +{ + return fdopen(fd, mode); +} diff --git a/src/lib/libast/stdio/_stdprintf.c b/src/lib/libast/stdio/_stdprintf.c new file mode 100644 index 0000000..db57a8d --- /dev/null +++ b/src/lib/libast/stdio/_stdprintf.c @@ -0,0 +1,38 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +/* OBSOLETE 20010101 -- use printf */ + +#include "stdhdr.h" + +extern int +_stdprintf(const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = sfvprintf(sfstdout, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/_stdscanf.c b/src/lib/libast/stdio/_stdscanf.c new file mode 100644 index 0000000..386a0cb --- /dev/null +++ b/src/lib/libast/stdio/_stdscanf.c @@ -0,0 +1,38 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +/* OBSOLETE 20010101 -- use scanf */ + +#include "stdhdr.h" + +extern int +_stdscanf(const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = sfvscanf(sfstdin, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/_stdsprnt.c b/src/lib/libast/stdio/_stdsprnt.c new file mode 100644 index 0000000..71c8f74 --- /dev/null +++ b/src/lib/libast/stdio/_stdsprnt.c @@ -0,0 +1,38 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +/* OBSOLETE 20010101 -- use sprintf */ + +#include "stdhdr.h" + +extern int +_stdsprintf(char* s, const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = s ? sfvsprintf(s, SF_BUFSIZE, fmt, args) : -1; + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/_stdvbuf.c b/src/lib/libast/stdio/_stdvbuf.c new file mode 100644 index 0000000..c9a2861 --- /dev/null +++ b/src/lib/libast/stdio/_stdvbuf.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +/* OBSOLETE 20010101 -- use setvbuf */ + +#include "stdhdr.h" + +extern int +_stdsetvbuf(Sfio_t* f, char* buf, int type, size_t size) +{ + return setvbuf(f, buf, type, size); +} diff --git a/src/lib/libast/stdio/_stdvsnprnt.c b/src/lib/libast/stdio/_stdvsnprnt.c new file mode 100644 index 0000000..78fdf2d --- /dev/null +++ b/src/lib/libast/stdio/_stdvsnprnt.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +/* OBSOLETE 20010101 -- use vsnprintf */ + +#include "stdhdr.h" + +extern int +_stdvsnprintf(char* s, int n, const char* fmt, va_list args) +{ + return vsnprintf(s, n, fmt, args); +} diff --git a/src/lib/libast/stdio/_stdvsprnt.c b/src/lib/libast/stdio/_stdvsprnt.c new file mode 100644 index 0000000..a3b78e6 --- /dev/null +++ b/src/lib/libast/stdio/_stdvsprnt.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +/* OBSOLETE 20010101 -- use vsprintf */ + +#include "stdhdr.h" + +extern int +_stdvsprintf(char* s, const char* fmt, va_list args) +{ + return vsprintf(s, fmt, args); +} diff --git a/src/lib/libast/stdio/_stdvsscn.c b/src/lib/libast/stdio/_stdvsscn.c new file mode 100644 index 0000000..0b1fd68 --- /dev/null +++ b/src/lib/libast/stdio/_stdvsscn.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +/* OBSOLETE 20010101 -- use vsscanf */ + +#include "stdhdr.h" + +extern int +_stdvsscanf(char* s, const char* fmt, va_list args) +{ + return vsscanf(s, fmt, args); +} diff --git a/src/lib/libast/stdio/asprintf.c b/src/lib/libast/stdio/asprintf.c new file mode 100644 index 0000000..60f59cc --- /dev/null +++ b/src/lib/libast/stdio/asprintf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +asprintf(char** s, const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = vasprintf(s, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/clearerr.c b/src/lib/libast/stdio/clearerr.c new file mode 100644 index 0000000..5d2e07c --- /dev/null +++ b/src/lib/libast/stdio/clearerr.c @@ -0,0 +1,33 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +clearerr(Sfio_t* f) +{ + STDIO_INT(f, "clearerr", int, (Sfio_t*), (f)) + + sfclrerr(f); + return sfclrlock(f); +} diff --git a/src/lib/libast/stdio/fclose.c b/src/lib/libast/stdio/fclose.c new file mode 100644 index 0000000..17063cb --- /dev/null +++ b/src/lib/libast/stdio/fclose.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fclose(Sfio_t* f) +{ + STDIO_INT(f, "fclose", int, (Sfio_t*), (f)) + + return sfclose(f); +} diff --git a/src/lib/libast/stdio/fcloseall.c b/src/lib/libast/stdio/fcloseall.c new file mode 100644 index 0000000..94c8553 --- /dev/null +++ b/src/lib/libast/stdio/fcloseall.c @@ -0,0 +1,57 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#define MAXLOOP 3 + +int +fcloseall(void) +{ + Sfpool_t* p; + Sfpool_t* next; + int n; + int nclose; + int count; + int loop; + + STDIO_INT(0, "fcloseall", int, (void), ()) + + for(loop = 0; loop < MAXLOOP; ++loop) + { nclose = count = 0; + for(p = &_Sfpool; p; p = next) + { /* find the next legitimate pool */ + for(next = p->next; next; next = next->next) + if(next->n_sf > 0) + break; + for(n = 0; n < ((p == &_Sfpool) ? p->n_sf : 1); ++n) + { count += 1; + if(sfclose(p->sf[n]) >= 0) + nclose += 1; + } + } + if(nclose == count) + break; + } + return 0; /* always return 0 per GNU */ +} diff --git a/src/lib/libast/stdio/fdopen.c b/src/lib/libast/stdio/fdopen.c new file mode 100644 index 0000000..c707c83 --- /dev/null +++ b/src/lib/libast/stdio/fdopen.c @@ -0,0 +1,34 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +Sfio_t* +fdopen(int fd, const char* mode) +{ + int flags; + + if (fd < 0 || !(flags = _sftype(mode, NiL, NiL))) + return 0; + return sfnew(NiL, NiL, (size_t)SF_UNBOUND, fd, flags); +} diff --git a/src/lib/libast/stdio/feof.c b/src/lib/libast/stdio/feof.c new file mode 100644 index 0000000..2b77397 --- /dev/null +++ b/src/lib/libast/stdio/feof.c @@ -0,0 +1,42 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if !_UWIN + +NoN(feof) + +#else + +#undef feof + +int +feof(Sfio_t* f) +{ + STDIO_INT(f, "feof", int, (Sfio_t*), (f)) + + return sfeof(f); +} + +#endif diff --git a/src/lib/libast/stdio/ferror.c b/src/lib/libast/stdio/ferror.c new file mode 100644 index 0000000..d374df1 --- /dev/null +++ b/src/lib/libast/stdio/ferror.c @@ -0,0 +1,42 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if !_UWIN + +NoN(ferror) + +#else + +#undef ferror + +int +ferror(Sfio_t* f) +{ + STDIO_INT(f, "ferror", int, (Sfio_t*), (f)) + + return sferror(f); +} + +#endif diff --git a/src/lib/libast/stdio/fflush.c b/src/lib/libast/stdio/fflush.c new file mode 100644 index 0000000..de6574b --- /dev/null +++ b/src/lib/libast/stdio/fflush.c @@ -0,0 +1,41 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +#ifndef _USE_GNU +#define _USE_GNU +#endif + +#include "stdhdr.h" + +int +fflush(Sfio_t* f) +{ + if (!f) + return fcloseall(); + + STDIO_INT(f, "fflush", int, (Sfio_t*), (f)) + + if (f->extent > 0) + sfseek(f, (Sfoff_t)0, SEEK_CUR|SF_PUBLIC); + return (sfsync(f) < 0 || sfpurge(f) < 0) ? -1 : 0; +} diff --git a/src/lib/libast/stdio/fgetc.c b/src/lib/libast/stdio/fgetc.c new file mode 100644 index 0000000..09d280f --- /dev/null +++ b/src/lib/libast/stdio/fgetc.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fgetc(Sfio_t* f) +{ + STDIO_INT(f, "fgetc", int, (Sfio_t*), (f)) + + return sfgetc(f); +} diff --git a/src/lib/libast/stdio/fgetpos.c b/src/lib/libast/stdio/fgetpos.c new file mode 100644 index 0000000..16da6fa --- /dev/null +++ b/src/lib/libast/stdio/fgetpos.c @@ -0,0 +1,48 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +#ifndef _NO_LARGEFILE64_SOURCE +#define _NO_LARGEFILE64_SOURCE 1 +#endif + +#include "stdhdr.h" + +int +fgetpos(Sfio_t* f, fpos_t* pos) +{ + STDIO_INT(f, "fgetpos", int, (Sfio_t*, fpos_t*), (f, pos)) + + return (pos->_sf_offset = sfseek(f, (Sfoff_t)0, SEEK_CUR)) >= 0 ? 0 : -1; +} + +#ifdef _typ_int64_t + +int +fgetpos64(Sfio_t* f, fpos64_t* pos) +{ + STDIO_INT(f, "fgetpos64", int, (Sfio_t*, fpos64_t*), (f, pos)) + + return (pos->_sf_offset = sfseek(f, (Sfoff_t)0, SEEK_CUR)) >= 0 ? 0 : -1; +} + +#endif diff --git a/src/lib/libast/stdio/fgets.c b/src/lib/libast/stdio/fgets.c new file mode 100644 index 0000000..727974a --- /dev/null +++ b/src/lib/libast/stdio/fgets.c @@ -0,0 +1,110 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +extern char* +_stdgets(Sfio_t* f, char* us, int n, int isgets) +{ + int p; + unsigned char* is; + unsigned char* ps; + + if(n <= 0 || !us || (f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0)) + return NIL(char*); + + SFLOCK(f,0); + + n -= 1; + is = (uchar*)us; + + while(n) + { /* peek the read buffer for data */ + if((p = f->endb - (ps = f->next)) <= 0 ) + { f->getr = '\n'; + f->mode |= SF_RC; + if(SFRPEEK(f,ps,p) <= 0) + break; + } + + if(p > n) + p = n; + +#if _lib_memccpy + if((ps = (uchar*)memccpy((char*)is,(char*)ps,'\n',p)) != NIL(uchar*)) + p = ps-is; + is += p; + ps = f->next+p; +#else + if(!(f->flags&(SF_BOTH|SF_MALLOC))) + { while(p-- && (*is++ = *ps++) != '\n') + ; + p = ps-f->next; + } + else + { reg int c = ps[p-1]; + if(c != '\n') + ps[p-1] = '\n'; + while((*is++ = *ps++) != '\n') + ; + if(c != '\n') + { f->next[p-1] = c; + if((ps-f->next) >= p) + is[-1] = c; + } + } +#endif + + /* gobble up read data and continue */ + f->next = ps; + if(is[-1] == '\n') + break; + else if(n > 0) + n -= p; + } + + if((_Sfi = is - ((uchar*)us)) <= 0) + us = NIL(char*); + else if(isgets && is[-1] == '\n') + { is[-1] = '\0'; + _Sfi -= 1; + } + else *is = '\0'; + + SFOPEN(f,0); + return us; +} + +char* +fgets(char* s, int n, Sfio_t* f) +{ + STDIO_PTR(f, "fgets", char*, (char*, int, Sfio_t*), (s, n, f)) + + return _stdgets(f, s, n, 0); +} + +char* +gets(char* s) +{ + return _stdgets(sfstdin, s, BUFSIZ, 1); +} diff --git a/src/lib/libast/stdio/fgetwc.c b/src/lib/libast/stdio/fgetwc.c new file mode 100644 index 0000000..64f7d83 --- /dev/null +++ b/src/lib/libast/stdio/fgetwc.c @@ -0,0 +1,35 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +wint_t +fgetwc(Sfio_t* f) +{ + wchar_t c; + + STDIO_INT(f, "fgetwc", wint_t, (Sfio_t*), (f)) + + FWIDE(f, WEOF); + return (sfread(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF; +} diff --git a/src/lib/libast/stdio/fgetws.c b/src/lib/libast/stdio/fgetws.c new file mode 100644 index 0000000..d1adbed --- /dev/null +++ b/src/lib/libast/stdio/fgetws.c @@ -0,0 +1,52 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +wchar_t* +fgetws(wchar_t* s, int n, Sfio_t* f) +{ + register wchar_t* p = s; + register wchar_t* e = s + n - 1; + register wint_t c; + + STDIO_PTR(f, "fgets", wchar_t*, (wchar_t*, int, Sfio_t*), (s, n, f)) + + FWIDE(f, 0); + while (p < e && (c = fgetwc(f)) != WEOF && (*p++ = c) != '\n'); + *p = 0; + return s; +} + +wchar_t* +getws(wchar_t* s) +{ + register wchar_t* p = s; + register wchar_t* e = s + BUFSIZ - 1; + register wint_t c; + + FWIDE(sfstdin, 0); + while (p < e && (c = fgetwc(sfstdin)) != WEOF && (*p++ = c) != '\n'); + *p = 0; + return s; +} diff --git a/src/lib/libast/stdio/fileno.c b/src/lib/libast/stdio/fileno.c new file mode 100644 index 0000000..5ca6de8 --- /dev/null +++ b/src/lib/libast/stdio/fileno.c @@ -0,0 +1,42 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if !_UWIN + +NoN(fileno) + +#else + +#undef fileno + +int +fileno(Sfio_t* f) +{ + STDIO_INT(f, "fileno", int, (Sfio_t*), (f)) + + return sffileno(f); +} + +#endif diff --git a/src/lib/libast/stdio/flockfile.c b/src/lib/libast/stdio/flockfile.c new file mode 100644 index 0000000..43141ec --- /dev/null +++ b/src/lib/libast/stdio/flockfile.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +void +flockfile(Sfio_t* f) +{ + STDIO_VOID(f, "flockfile", void, (Sfio_t*), (f)) + + (void)sfmutex(f, SFMTX_LOCK); +} diff --git a/src/lib/libast/stdio/fmemopen.c b/src/lib/libast/stdio/fmemopen.c new file mode 100644 index 0000000..dfb6317 --- /dev/null +++ b/src/lib/libast/stdio/fmemopen.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +Sfio_t* +fmemopen(void* buf, size_t size, const char* mode) +{ + STDIO_PTR(0, "fmemopen", Sfio_t*, (void*, size_t, const char*), (buf, size, mode)) + + return sfnew(NiL, buf, size, -1, SF_STRING|_sftype(mode, NiL, NiL)); +} diff --git a/src/lib/libast/stdio/fopen.c b/src/lib/libast/stdio/fopen.c new file mode 100644 index 0000000..4b99fef --- /dev/null +++ b/src/lib/libast/stdio/fopen.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +Sfio_t* +fopen(const char* path, const char* mode) +{ + return sfopen(NiL, path, mode); +} diff --git a/src/lib/libast/stdio/fprintf.c b/src/lib/libast/stdio/fprintf.c new file mode 100644 index 0000000..0939cc7 --- /dev/null +++ b/src/lib/libast/stdio/fprintf.c @@ -0,0 +1,39 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fprintf(Sfio_t* f, const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + + STDIO_INT(f, "vfprintf", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) + + v = sfvprintf(f, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/fpurge.c b/src/lib/libast/stdio/fpurge.c new file mode 100644 index 0000000..eeaea0d --- /dev/null +++ b/src/lib/libast/stdio/fpurge.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fpurge(Sfio_t* f) +{ + STDIO_INT(f, "fpurge", int, (Sfio_t*), (f)) + + return sfpurge(f); +} diff --git a/src/lib/libast/stdio/fputc.c b/src/lib/libast/stdio/fputc.c new file mode 100644 index 0000000..72cf874 --- /dev/null +++ b/src/lib/libast/stdio/fputc.c @@ -0,0 +1,42 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if !_UWIN + +NoN(fputc) + +#else + +#undef fputc + +int +fputc(int c, Sfio_t* f) +{ + STDIO_INT(f, "fputc", int, (int, Sfio_t*), (c, f)) + + return sfputc(f, c); +} + +#endif diff --git a/src/lib/libast/stdio/fputs.c b/src/lib/libast/stdio/fputs.c new file mode 100644 index 0000000..0fdc459 --- /dev/null +++ b/src/lib/libast/stdio/fputs.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fputs(const char* s, Sfio_t* f) +{ + STDIO_INT(f, "fputs", int, (const char*, Sfio_t*), (s, f)) + + return sfputr(f, s, -1); +} diff --git a/src/lib/libast/stdio/fputwc.c b/src/lib/libast/stdio/fputwc.c new file mode 100644 index 0000000..1029a3b --- /dev/null +++ b/src/lib/libast/stdio/fputwc.c @@ -0,0 +1,33 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +wint_t +fputwc(wchar_t c, Sfio_t* f) +{ + STDIO_INT(f, "fputc", wint_t, (wchar_t, Sfio_t*), (c, f)) + + FWIDE(f, WEOF); + return (sfwrite(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF; +} diff --git a/src/lib/libast/stdio/fputws.c b/src/lib/libast/stdio/fputws.c new file mode 100644 index 0000000..3e1034e --- /dev/null +++ b/src/lib/libast/stdio/fputws.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fputws(const wchar_t* s, Sfio_t* f) +{ + size_t n; + + STDIO_INT(f, "fputws", int, (const wchar_t*, Sfio_t*), (s, f)) + + FWIDE(f, WEOF); + n = wcslen(s) * sizeof(wchar_t); + return (sfwrite(f, s, n) == n) ? 0 : -1; +} diff --git a/src/lib/libast/stdio/fread.c b/src/lib/libast/stdio/fread.c new file mode 100644 index 0000000..c96a1e7 --- /dev/null +++ b/src/lib/libast/stdio/fread.c @@ -0,0 +1,34 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +size_t +fread(void* p, size_t s, size_t n, Sfio_t* f) +{ + ssize_t v; + + STDIO_INT(f, "fread", ssize_t, (void*, size_t, size_t, Sfio_t*), (p, s, n, f)) + + return ((v = sfread(f, p, s * n)) <= 0) ? 0 : (v / s); +} diff --git a/src/lib/libast/stdio/freopen.c b/src/lib/libast/stdio/freopen.c new file mode 100644 index 0000000..e8de05b --- /dev/null +++ b/src/lib/libast/stdio/freopen.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +Sfio_t* +freopen(const char* path, const char* mode, Sfio_t* f) +{ + STDIO_PTR(f, "freopen", Sfio_t*, (const char*, const char*, Sfio_t*), (path, mode, f)) + + return sfopen(f, path, mode); +} diff --git a/src/lib/libast/stdio/fscanf.c b/src/lib/libast/stdio/fscanf.c new file mode 100644 index 0000000..2beb400 --- /dev/null +++ b/src/lib/libast/stdio/fscanf.c @@ -0,0 +1,39 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fscanf(Sfio_t* f, const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + + STDIO_INT(f, "vfscanf", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) + + v = sfvscanf(f, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/fseek.c b/src/lib/libast/stdio/fseek.c new file mode 100644 index 0000000..1198a31 --- /dev/null +++ b/src/lib/libast/stdio/fseek.c @@ -0,0 +1,48 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +#ifndef _NO_LARGEFILE64_SOURCE +#define _NO_LARGEFILE64_SOURCE 1 +#endif + +#include "stdhdr.h" + +int +fseek(Sfio_t* f, long off, int op) +{ + STDIO_INT(f, "fseek", int, (Sfio_t*, long, int), (f, off, op)) + + return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1; +} + +#ifdef _typ_int64_t + +int +fseek64(Sfio_t* f, int64_t off, int op) +{ + STDIO_INT(f, "fseek64", int, (Sfio_t*, int64_t, int), (f, off, op)) + + return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1; +} + +#endif diff --git a/src/lib/libast/stdio/fseeko.c b/src/lib/libast/stdio/fseeko.c new file mode 100644 index 0000000..0cf3186 --- /dev/null +++ b/src/lib/libast/stdio/fseeko.c @@ -0,0 +1,48 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +#ifndef _NO_LARGEFILE64_SOURCE +#define _NO_LARGEFILE64_SOURCE 1 +#endif + +#include "stdhdr.h" + +int +fseeko(Sfio_t* f, off_t off, int op) +{ + STDIO_INT(f, "fseeko", int, (Sfio_t*, off_t, int), (f, off, op)) + + return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1; +} + +#ifdef _typ_int64_t + +int +fseeko64(Sfio_t* f, int64_t off, int op) +{ + STDIO_INT(f, "fseeko64", int, (Sfio_t*, int64_t, int), (f, off, op)) + + return sfseek(f, (Sfoff_t)off, op|SF_SHARE) >= 0 ? 0 : -1; +} + +#endif diff --git a/src/lib/libast/stdio/fsetpos.c b/src/lib/libast/stdio/fsetpos.c new file mode 100644 index 0000000..cc9abbc --- /dev/null +++ b/src/lib/libast/stdio/fsetpos.c @@ -0,0 +1,48 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +#ifndef _NO_LARGEFILE64_SOURCE +#define _NO_LARGEFILE64_SOURCE 1 +#endif + +#include "stdhdr.h" + +int +fsetpos(Sfio_t* f, const fpos_t* pos) +{ + STDIO_INT(f, "fsetpos", int, (Sfio_t*, const fpos_t*), (f, pos)) + + return sfseek(f, (Sfoff_t)pos->_sf_offset, SF_PUBLIC) == (Sfoff_t)pos->_sf_offset ? 0 : -1; +} + +#ifdef _typ_int64_t + +int +fsetpos64(Sfio_t* f, const fpos64_t* pos) +{ + STDIO_INT(f, "fsetpos64", int, (Sfio_t*, const fpos64_t*), (f, pos)) + + return sfseek(f, (Sfoff_t)pos->_sf_offset, SF_PUBLIC) == (Sfoff_t)pos->_sf_offset ? 0 : -1; +} + +#endif diff --git a/src/lib/libast/stdio/ftell.c b/src/lib/libast/stdio/ftell.c new file mode 100644 index 0000000..0437e48 --- /dev/null +++ b/src/lib/libast/stdio/ftell.c @@ -0,0 +1,48 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +#ifndef _NO_LARGEFILE64_SOURCE +#define _NO_LARGEFILE64_SOURCE 1 +#endif + +#include "stdhdr.h" + +long +ftell(Sfio_t* f) +{ + STDIO_INT(f, "ftell", long, (Sfio_t*), (f)) + + return (long)sfseek(f, (Sfoff_t)0, SEEK_CUR); +} + +#if _typ_int64_t + +int64_t +ftell64(Sfio_t* f) +{ + STDIO_INT(f, "ftell64", int64_t, (Sfio_t*), (f)) + + return (int64_t)sfseek(f, (Sfoff_t)0, SEEK_CUR); +} + +#endif diff --git a/src/lib/libast/stdio/ftello.c b/src/lib/libast/stdio/ftello.c new file mode 100644 index 0000000..f430fec --- /dev/null +++ b/src/lib/libast/stdio/ftello.c @@ -0,0 +1,48 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +#ifndef _NO_LARGEFILE64_SOURCE +#define _NO_LARGEFILE64_SOURCE 1 +#endif + +#include "stdhdr.h" + +off_t +ftello(Sfio_t* f) +{ + STDIO_INT(f, "ftello", off_t, (Sfio_t*), (f)) + + return sfseek(f, (Sfoff_t)0, SEEK_CUR); +} + +#ifdef _typ_int64_t + +int64_t +ftello64(Sfio_t* f) +{ + STDIO_INT(f, "ftello64", int64_t, (Sfio_t*), (f)) + + return sfseek(f, (Sfoff_t)0, SEEK_CUR) >= 0 ? 0 : -1; +} + +#endif diff --git a/src/lib/libast/stdio/ftrylockfile.c b/src/lib/libast/stdio/ftrylockfile.c new file mode 100644 index 0000000..28501e8 --- /dev/null +++ b/src/lib/libast/stdio/ftrylockfile.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +ftrylockfile(Sfio_t* f) +{ + STDIO_INT(f, "ftrylockfile", int, (Sfio_t*), (f)) + + return sfmutex(f, SFMTX_TRYLOCK); +} diff --git a/src/lib/libast/stdio/funlockfile.c b/src/lib/libast/stdio/funlockfile.c new file mode 100644 index 0000000..33195d5 --- /dev/null +++ b/src/lib/libast/stdio/funlockfile.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +void +funlockfile(Sfio_t* f) +{ + STDIO_VOID(f, "funlockfile", void, (Sfio_t*), (f)) + + (void)sfmutex(f, SFMTX_UNLOCK); +} diff --git a/src/lib/libast/stdio/fwide.c b/src/lib/libast/stdio/fwide.c new file mode 100644 index 0000000..efcb453 --- /dev/null +++ b/src/lib/libast/stdio/fwide.c @@ -0,0 +1,51 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fwide(Sfio_t* f, int mode) +{ + STDIO_INT(f, "fwide", int, (Sfio_t*, int), (f, mode)) + + if (mode > 0) + { + f->bits &= ~SF_MB; + f->bits |= SF_WC; + } + else if (mode < 0) + { + f->bits &= ~SF_WC; + f->bits |= SF_MB; + } + if (f->bits & SF_MB) + return -1; + if (f->bits & SF_WC) + return 1; + if ((f->flags & SF_SYNCED) || f->next > f->data) + { + f->bits |= SF_MB; + return -1; + } + return 0; +} diff --git a/src/lib/libast/stdio/fwprintf.c b/src/lib/libast/stdio/fwprintf.c new file mode 100644 index 0000000..b4726e3 --- /dev/null +++ b/src/lib/libast/stdio/fwprintf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fwprintf(Sfio_t* f, const wchar_t* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = vfwprintf(f, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/fwrite.c b/src/lib/libast/stdio/fwrite.c new file mode 100644 index 0000000..12bfe89 --- /dev/null +++ b/src/lib/libast/stdio/fwrite.c @@ -0,0 +1,34 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +size_t +fwrite(const void* p, size_t s, size_t n, Sfio_t* f) +{ + ssize_t v; + + STDIO_INT(f, "fwrite", ssize_t, (const void*, size_t, size_t, Sfio_t*), (p, s, n, f)) + + return ((v = sfwrite(f, p, s * n)) <= 0) ? 0 : (v / s); +} diff --git a/src/lib/libast/stdio/fwscanf.c b/src/lib/libast/stdio/fwscanf.c new file mode 100644 index 0000000..f64f203 --- /dev/null +++ b/src/lib/libast/stdio/fwscanf.c @@ -0,0 +1,39 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +fwscanf(Sfio_t* f, const wchar_t* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + + STDIO_INT(f, "vfwscanf", int, (Sfio_t*, const wchar_t*, va_list), (f, fmt, args)) + + v = vfwscanf(f, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/getc.c b/src/lib/libast/stdio/getc.c new file mode 100644 index 0000000..b04507f --- /dev/null +++ b/src/lib/libast/stdio/getc.c @@ -0,0 +1,42 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if !_UWIN + +NoN(getc) + +#else + +#undef getc + +int +getc(Sfio_t* f) +{ + STDIO_INT(f, "getc", int, (Sfio_t*), (f)) + + return sfgetc(f); +} + +#endif diff --git a/src/lib/libast/stdio/getchar.c b/src/lib/libast/stdio/getchar.c new file mode 100644 index 0000000..80781eb --- /dev/null +++ b/src/lib/libast/stdio/getchar.c @@ -0,0 +1,40 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if !_UWIN + +NoN(getchar) + +#else + +#undef getchar + +int +getchar(void) +{ + return sfgetc(sfstdin); +} + +#endif diff --git a/src/lib/libast/stdio/getdelim.c b/src/lib/libast/stdio/getdelim.c new file mode 100644 index 0000000..331125a --- /dev/null +++ b/src/lib/libast/stdio/getdelim.c @@ -0,0 +1,96 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +ssize_t +getdelim(char** sp, size_t* np, int delim, Sfio_t* f) +{ + ssize_t m; + ssize_t n; + ssize_t k; + ssize_t p; + uchar* s; + uchar* ps; + SFMTXDECL(f); + + STDIO_INT(f, "getdelim", ssize_t, (char**, size_t*, int, Sfio_t*), (sp, np, delim, f)) + + SFMTXENTER(f, -1); + + if(delim < 0 || delim > 255 || !sp || !np) /* bad parameters */ + SFMTXRETURN(f, -1); + + if(f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0) + SFMTXRETURN(f, -1); + + SFLOCK(f,0); + + if(!(s = (uchar*)(*sp)) || (n = *np) < 0) + { s = NIL(uchar*); n = 0; } + for(m = 0;; ) + { /* read new data */ + if((p = f->endb - (ps = f->next)) <= 0 ) + { f->getr = delim; + f->mode |= SF_RC; + if(SFRPEEK(f,ps,p) <= 0) + { m = -1; + break; + } + } + + for(k = 0; k < p; ++k) /* find the delimiter */ + { if(ps[k] == delim) + { k += 1; /* include delim in copying */ + break; + } + } + + if((m+k+1) >= n ) /* make sure there is space */ + { n = ((m+k+15)/8)*8; + if(!(s = (uchar*)realloc(s, n)) ) + { *sp = 0; *np = 0; + m = -1; + break; + } + *sp = (char*)s; *np = n; + } + + memcpy(s+m, ps, k); m += k; + f->next = ps+k; /* skip copied data in buffer */ + + if(s[m-1] == delim) + { s[m] = 0; /* 0-terminated */ + break; + } + } + + SFOPEN(f,0); + SFMTXRETURN(f,m); +} + +ssize_t +__getdelim(char** sp, size_t* np, int delim, Sfio_t* f) +{ + return getdelim(sp, np, delim, f); +} diff --git a/src/lib/libast/stdio/getline.c b/src/lib/libast/stdio/getline.c new file mode 100644 index 0000000..914a5c1 --- /dev/null +++ b/src/lib/libast/stdio/getline.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +#ifndef _USE_GNU +#define _USE_GNU +#endif + +#include "stdhdr.h" + +ssize_t +getline(char** sp, size_t* np, Sfio_t* f) +{ + STDIO_INT(f, "getline", ssize_t, (char**, size_t*, Sfio_t*), (sp, np, f)) + + return getdelim(sp, np, '\n', f); +} diff --git a/src/lib/libast/stdio/getw.c b/src/lib/libast/stdio/getw.c new file mode 100644 index 0000000..b0063be --- /dev/null +++ b/src/lib/libast/stdio/getw.c @@ -0,0 +1,34 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +getw(Sfio_t* f) +{ + int v; + + STDIO_INT(f, "getw", int, (Sfio_t*), (f)) + + return sfread(f, &v, sizeof(v)) == sizeof(v) ? v : -1; +} diff --git a/src/lib/libast/stdio/getwc.c b/src/lib/libast/stdio/getwc.c new file mode 100644 index 0000000..7e4a39f --- /dev/null +++ b/src/lib/libast/stdio/getwc.c @@ -0,0 +1,31 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" +#include "ast_wchar.h" + +wint_t +getwc(Sfio_t* f) +{ + return fgetwc(f); +} diff --git a/src/lib/libast/stdio/getwchar.c b/src/lib/libast/stdio/getwchar.c new file mode 100644 index 0000000..4564c2a --- /dev/null +++ b/src/lib/libast/stdio/getwchar.c @@ -0,0 +1,31 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" +#include "ast_wchar.h" + +wint_t +getwchar(void) +{ + return fgetwc(sfstdin); +} diff --git a/src/lib/libast/stdio/pclose.c b/src/lib/libast/stdio/pclose.c new file mode 100644 index 0000000..b06b25a --- /dev/null +++ b/src/lib/libast/stdio/pclose.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +pclose(Sfio_t* f) +{ + STDIO_INT(f, "pclose", int, (Sfio_t*), (f)) + + return sfclose(f); +} diff --git a/src/lib/libast/stdio/popen.c b/src/lib/libast/stdio/popen.c new file mode 100644 index 0000000..61968aa --- /dev/null +++ b/src/lib/libast/stdio/popen.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +Sfio_t* +popen(const char* cmd, const char* mode) +{ + return sfpopen((Sfio_t*)(-1), cmd, mode); +} diff --git a/src/lib/libast/stdio/printf.c b/src/lib/libast/stdio/printf.c new file mode 100644 index 0000000..ca999f4 --- /dev/null +++ b/src/lib/libast/stdio/printf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +printf(const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = sfvprintf(sfstdout, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/putc.c b/src/lib/libast/stdio/putc.c new file mode 100644 index 0000000..34d1b14 --- /dev/null +++ b/src/lib/libast/stdio/putc.c @@ -0,0 +1,42 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if !_UWIN + +NoN(putc) + +#else + +#undef putc + +int +putc(int c, Sfio_t* f) +{ + STDIO_INT(f, "putc", int, (int, Sfio_t*), (c, f)) + + return sfputc(f, c); +} + +#endif diff --git a/src/lib/libast/stdio/putchar.c b/src/lib/libast/stdio/putchar.c new file mode 100644 index 0000000..5fb8217 --- /dev/null +++ b/src/lib/libast/stdio/putchar.c @@ -0,0 +1,40 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +#if !_UWIN + +NoN(putchar) + +#else + +#undef putchar + +int +putchar(int c) +{ + return sfputc(sfstdout, c); +} + +#endif diff --git a/src/lib/libast/stdio/puts.c b/src/lib/libast/stdio/puts.c new file mode 100644 index 0000000..3ef397b --- /dev/null +++ b/src/lib/libast/stdio/puts.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +puts(const char* s) +{ + return sfputr(sfstdout, s, '\n'); +} diff --git a/src/lib/libast/stdio/putw.c b/src/lib/libast/stdio/putw.c new file mode 100644 index 0000000..626439d --- /dev/null +++ b/src/lib/libast/stdio/putw.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +putw(int v, Sfio_t* f) +{ + STDIO_INT(f, "putw", int, (int, Sfio_t*), (v, f)) + + return sfwrite(f, &v, sizeof(v)) == sizeof(v) ? 0 : -1; +} diff --git a/src/lib/libast/stdio/putwc.c b/src/lib/libast/stdio/putwc.c new file mode 100644 index 0000000..8a4e86e --- /dev/null +++ b/src/lib/libast/stdio/putwc.c @@ -0,0 +1,31 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" +#include "ast_wchar.h" + +wint_t +putwc(wchar_t c, Sfio_t* f) +{ + return fputwc(c, f); +} diff --git a/src/lib/libast/stdio/putwchar.c b/src/lib/libast/stdio/putwchar.c new file mode 100644 index 0000000..70c967f --- /dev/null +++ b/src/lib/libast/stdio/putwchar.c @@ -0,0 +1,31 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" +#include "ast_wchar.h" + +wint_t +putwchar(wchar_t c) +{ + return fputwc(c, sfstdout); +} diff --git a/src/lib/libast/stdio/rewind.c b/src/lib/libast/stdio/rewind.c new file mode 100644 index 0000000..d82985c --- /dev/null +++ b/src/lib/libast/stdio/rewind.c @@ -0,0 +1,33 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +void +rewind(Sfio_t* f) +{ + STDIO_VOID(f, "rewind", void, (Sfio_t*), (f)) + + sfseek(f, (Sfoff_t)0, SEEK_SET|SF_PUBLIC); + sfclrlock(f); +} diff --git a/src/lib/libast/stdio/scanf.c b/src/lib/libast/stdio/scanf.c new file mode 100644 index 0000000..5b2976e --- /dev/null +++ b/src/lib/libast/stdio/scanf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +scanf(const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = sfvscanf(sfstdin, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/setbuf.c b/src/lib/libast/stdio/setbuf.c new file mode 100644 index 0000000..83d6132 --- /dev/null +++ b/src/lib/libast/stdio/setbuf.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +void +setbuf(Sfio_t* f, char* b) +{ + STDIO_VOID(f, "setbuf", void, (Sfio_t*, char*), (f, b)) + + sfsetbuf(f, b, b ? BUFSIZ : 0); +} diff --git a/src/lib/libast/stdio/setbuffer.c b/src/lib/libast/stdio/setbuffer.c new file mode 100644 index 0000000..6211c72 --- /dev/null +++ b/src/lib/libast/stdio/setbuffer.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +setbuffer(Sfio_t* f, char* b, int n) +{ + STDIO_INT(f, "setbuffer", int, (Sfio_t*, char*, int), (f, b, n)) + + return sfsetbuf(f, b, n) ? 0 : -1; +} diff --git a/src/lib/libast/stdio/setlinebuf.c b/src/lib/libast/stdio/setlinebuf.c new file mode 100644 index 0000000..b18b151 --- /dev/null +++ b/src/lib/libast/stdio/setlinebuf.c @@ -0,0 +1,33 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +setlinebuf(Sfio_t* f) +{ + STDIO_INT(f, "setlinebuf", int, (Sfio_t*), (f)) + + sfset(f, SF_LINE, 1); + return 0; +} diff --git a/src/lib/libast/stdio/setvbuf.c b/src/lib/libast/stdio/setvbuf.c new file mode 100644 index 0000000..c8a38f8 --- /dev/null +++ b/src/lib/libast/stdio/setvbuf.c @@ -0,0 +1,48 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +setvbuf(Sfio_t* f, char* buf, int type, size_t size) +{ + STDIO_INT(f, "setvbuf", int, (Sfio_t*, char*, int, size_t), (f, buf, type, size)) + + if (type == _IOLBF) + sfset(f, SF_LINE, 1); + else if (f->flags & SF_STRING) + return -1; + else if (type == _IONBF) + { + sfsync(f); + sfsetbuf(f, NiL, 0); + } + else if (type == _IOFBF) + { + if (size == 0) + size = SF_BUFSIZE; + sfsync(f); + sfsetbuf(f, (Void_t*)buf, size); + } + return 0; +} diff --git a/src/lib/libast/stdio/snprintf.c b/src/lib/libast/stdio/snprintf.c new file mode 100644 index 0000000..f30c243 --- /dev/null +++ b/src/lib/libast/stdio/snprintf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +snprintf(char* s, int n, const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = sfvsprintf(s, n, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/sprintf.c b/src/lib/libast/stdio/sprintf.c new file mode 100644 index 0000000..3a8139a --- /dev/null +++ b/src/lib/libast/stdio/sprintf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +sprintf(char* s, const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = s ? sfvsprintf(s, INT_MAX, fmt, args) : -1; + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/sscanf.c b/src/lib/libast/stdio/sscanf.c new file mode 100644 index 0000000..c04d2d3 --- /dev/null +++ b/src/lib/libast/stdio/sscanf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +sscanf(const char* s, const char* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = sfvsscanf(s, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/stdhdr.h b/src/lib/libast/stdio/stdhdr.h new file mode 100644 index 0000000..1b2a930 --- /dev/null +++ b/src/lib/libast/stdio/stdhdr.h @@ -0,0 +1,115 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +#ifndef _STDHDR_H +#define _STDHDR_H 1 + +#ifndef _NO_LARGEFILE64_SOURCE +#define _NO_LARGEFILE64_SOURCE 1 +#endif +#undef _LARGEFILE64_SOURCE + +#define _ast_fseeko ______fseeko +#define _ast_ftello ______ftello +#include "sfhdr.h" +#undef _ast_fseeko +#undef _ast_ftello + +#include "stdio.h" + +#define SF_MB 010000 +#define SF_WC 020000 + +#if _UWIN + +#define STDIO_TRANSFER 1 + +typedef int (*Fun_f)(); + +typedef struct Funvec_s +{ + const char* name; + Fun_f vec[2]; +} Funvec_t; + +extern int _stdfun(Sfio_t*, Funvec_t*); + +#define STDIO_INT(p,n,t,f,a) \ + { \ + typedef t (*_s_f)f; \ + int _i; \ + static Funvec_t _v = { n }; \ + if ((_i = _stdfun(p, &_v)) < 0) \ + return -1; \ + else if (_i > 0) \ + return ((_s_f)_v.vec[_i])a; \ + } + +#define STDIO_PTR(p,n,t,f,a) \ + { \ + typedef t (*_s_f)f; \ + int _i; \ + static Funvec_t _v = { n }; \ + if ((_i = _stdfun(p, &_v)) < 0) \ + return 0; \ + else if (_i > 0) \ + return ((_s_f)_v.vec[_i])a; \ + } + +#define STDIO_VOID(p,n,t,f,a) \ + { \ + typedef t (*_s_f)f; \ + int _i; \ + static Funvec_t _v = { n }; \ + if ((_i = _stdfun(p, &_v)) < 0) \ + return; \ + else if (_i > 0) \ + { \ + ((_s_f)_v.vec[_i])a; \ + return; \ + } \ + } + +#else + +#define STDIO_INT(p,n,t,f,a) +#define STDIO_PTR(p,n,t,f,a) +#define STDIO_VOID(p,n,t,f,a) + +#endif + +#define FWIDE(f,r) \ + do \ + { \ + if (fwide(f, 0) < 0) \ + return r; \ + f->bits |= SF_WC; \ + } while (0) + +#ifdef __EXPORT__ +#define extern __EXPORT__ +#endif + +extern int sfdcwide(Sfio_t*); + +#endif diff --git a/src/lib/libast/stdio/stdio_c99.c b/src/lib/libast/stdio/stdio_c99.c new file mode 100644 index 0000000..f8d0f8d --- /dev/null +++ b/src/lib/libast/stdio/stdio_c99.c @@ -0,0 +1,118 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 + +/* + * C99 stdio extensions + */ + +#include "stdhdr.h" + +void +clearerr_unlocked(Sfio_t* sp) +{ + clearerr(sp); +} + +int +feof_unlocked(Sfio_t* sp) +{ + return feof(sp); +} + +int +ferror_unlocked(Sfio_t* sp) +{ + return ferror(sp); +} + +int +fflush_unlocked(Sfio_t* sp) +{ + return fflush(sp); +} + +int +fgetc_unlocked(Sfio_t* sp) +{ + return fgetc(sp); +} + +char* +fgets_unlocked(char* buf, int size, Sfio_t* sp) +{ + return fgets(buf, size, sp); +} + +int +fileno_unlocked(Sfio_t* sp) +{ + return fileno(sp); +} + +int +fputc_unlocked(int c, Sfio_t* sp) +{ + return fputc(c, sp); +} + +int +fputs_unlocked(char* buf, Sfio_t* sp) +{ + return fputs(buf, sp); +} + +size_t +fread_unlocked(void* buf, size_t size, size_t n, Sfio_t* sp) +{ + return fread(buf, size, n, sp); +} + +size_t +fwrite_unlocked(void* buf, size_t size, size_t n, Sfio_t* sp) +{ + return fwrite(buf, size, n, sp); +} + +int +getc_unlocked(Sfio_t* sp) +{ + return getc(sp); +} + +int +getchar_unlocked(void) +{ + return getchar(); +} + +int +putc_unlocked(int c, Sfio_t* sp) +{ + return putc(c, sp); +} + +int +putchar_unlocked(int c) +{ + return putchar(c); +} diff --git a/src/lib/libast/stdio/swprintf.c b/src/lib/libast/stdio/swprintf.c new file mode 100644 index 0000000..6bb0942 --- /dev/null +++ b/src/lib/libast/stdio/swprintf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +swprintf(wchar_t* s, size_t size, const wchar_t* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = vswprintf(s, size, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/swscanf.c b/src/lib/libast/stdio/swscanf.c new file mode 100644 index 0000000..00f27a4 --- /dev/null +++ b/src/lib/libast/stdio/swscanf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +swscanf(const wchar_t* s, const wchar_t* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = vswscanf(s, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/tmpfile.c b/src/lib/libast/stdio/tmpfile.c new file mode 100644 index 0000000..c913dc8 --- /dev/null +++ b/src/lib/libast/stdio/tmpfile.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +Sfio_t* +tmpfile(void) +{ + return sftmp(0); +} diff --git a/src/lib/libast/stdio/ungetc.c b/src/lib/libast/stdio/ungetc.c new file mode 100644 index 0000000..e448beb --- /dev/null +++ b/src/lib/libast/stdio/ungetc.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +ungetc(int c, Sfio_t* f) +{ + STDIO_INT(f, "ungetc", int, (int, Sfio_t*), (c, f)) + + return sfungetc(f, c); +} diff --git a/src/lib/libast/stdio/ungetwc.c b/src/lib/libast/stdio/ungetwc.c new file mode 100644 index 0000000..4877f0c --- /dev/null +++ b/src/lib/libast/stdio/ungetwc.c @@ -0,0 +1,39 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +wint_t +ungetwc(wint_t c, Sfio_t* f) +{ + register unsigned char* s = (unsigned char*)&c; + register unsigned char* e = s + sizeof(c); + + STDIO_INT(f, "ungetwc", wint_t, (wint_t, Sfio_t*), (c, f)) + + FWIDE(f, WEOF); + while (s < e) + if (sfungetc(f, *s++) == EOF) + return WEOF; + return c; +} diff --git a/src/lib/libast/stdio/vasprintf.c b/src/lib/libast/stdio/vasprintf.c new file mode 100644 index 0000000..f03397f --- /dev/null +++ b/src/lib/libast/stdio/vasprintf.c @@ -0,0 +1,45 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vasprintf(char** s, const char* fmt, va_list args) +{ + Sfio_t* f; + int v; + + if (f = sfstropen()) + { + v = sfvprintf(f, fmt, args); + if (!(*s = strdup(sfstruse(f)))) + v = -1; + sfstrclose(f); + } + else + { + *s = 0; + v = -1; + } + return v; +} diff --git a/src/lib/libast/stdio/vfprintf.c b/src/lib/libast/stdio/vfprintf.c new file mode 100644 index 0000000..04a2e2f --- /dev/null +++ b/src/lib/libast/stdio/vfprintf.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vfprintf(Sfio_t* f, const char* fmt, va_list args) +{ + STDIO_INT(f, "vfprintf", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) + + return sfvprintf(f, fmt, args); +} diff --git a/src/lib/libast/stdio/vfscanf.c b/src/lib/libast/stdio/vfscanf.c new file mode 100644 index 0000000..f9bcc01 --- /dev/null +++ b/src/lib/libast/stdio/vfscanf.c @@ -0,0 +1,32 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vfscanf(Sfio_t* f, const char* fmt, va_list args) +{ + STDIO_INT(f, "vfscanf", int, (Sfio_t*, const char*, va_list), (f, fmt, args)) + + return sfvscanf(f, fmt, args); +} diff --git a/src/lib/libast/stdio/vfwprintf.c b/src/lib/libast/stdio/vfwprintf.c new file mode 100644 index 0000000..b396792 --- /dev/null +++ b/src/lib/libast/stdio/vfwprintf.c @@ -0,0 +1,68 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vfwprintf(Sfio_t* f, const wchar_t* fmt, va_list args) +{ + char* m; + char* x; + wchar_t*w; + size_t n; + int v; + Sfio_t* t; + + STDIO_INT(f, "vfwprintf", int, (Sfio_t*, const wchar_t*, va_list), (f, fmt, args)) + + FWIDE(f, WEOF); + n = wcstombs(NiL, fmt, 0); + if (m = malloc(n + 1)) + { + if (t = sfstropen()) + { + wcstombs(m, fmt, n + 1); + sfvprintf(t, m, args); + free(m); + if (!(x = sfstruse(t))) + v = -1; + else + { + n = mbstowcs(NiL, x, 0); + if (w = (wchar_t*)sfreserve(f, n * sizeof(wchar_t) + 1, 0)) + v = mbstowcs(w, x, n + 1); + else + v = -1; + } + sfstrclose(t); + } + else + { + free(m); + v = -1; + } + } + else + v = -1; + return v; +} diff --git a/src/lib/libast/stdio/vfwscanf.c b/src/lib/libast/stdio/vfwscanf.c new file mode 100644 index 0000000..ca23f9a --- /dev/null +++ b/src/lib/libast/stdio/vfwscanf.c @@ -0,0 +1,129 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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 +{ + Sfdisc_t sfdisc; /* sfio discipline */ + Sfio_t* f; /* original wide stream */ + char fmt[1]; /* mb fmt */ +} Wide_t; + +/* + * wide exception handler + * free on close + */ + +static int +wideexcept(Sfio_t* f, int op, void* val, Sfdisc_t* dp) +{ + 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) + free(dp); + break; + } + return 0; +} + +/* + * sfio wide discipline read + * 1 wchar_t at a time + * go pure multibyte for best performance + */ + +static ssize_t +wideread(Sfio_t* f, Void_t* buf, size_t size, Sfdisc_t* dp) +{ + register Wide_t* w = (Wide_t*)dp; + wchar_t wuf[2]; + +#if 0 + if (sfread(w->f, wuf, sizeof(wuf[0])) != sizeof(wuf[0])) + return -1; + wuf[1] = 0; + return wcstombs(buf, wuf, size); +#else + ssize_t r; + + r = sfread(w->f, wuf, sizeof(wuf[0])); + if (r != sizeof(wuf[0])) + return -1; + wuf[1] = 0; + r = wcstombs(buf, wuf, size); + return r; +#endif +} + +int +vfwscanf(Sfio_t* f, const wchar_t* fmt, va_list args) +{ + size_t n; + int v; + Sfio_t* t; + Wide_t* w; + char buf[1024]; + + STDIO_INT(f, "vfwscanf", int, (Sfio_t*, const wchar_t*, va_list), (f, fmt, args)) + + FWIDE(f, WEOF); + n = wcstombs(NiL, fmt, 0); + if (w = newof(0, Wide_t, 1, n)) + { + if (t = sfnew(NiL, buf, sizeof(buf), OPEN_MAX+1, SF_READ)) + { + w->sfdisc.exceptf = wideexcept; + w->sfdisc.readf = wideread; + w->f = f; + if (sfdisc(t, &w->sfdisc) == &w->sfdisc) + { + wcstombs(w->fmt, fmt, n + 1); + v = sfvscanf(t, w->fmt, args); + } + else + { + free(w); + v = -1; + } + sfsetfd(t, -1); + sfclose(t); + } + else + { + free(w); + v = -1; + } + } + else + v = -1; + return v; +} diff --git a/src/lib/libast/stdio/vprintf.c b/src/lib/libast/stdio/vprintf.c new file mode 100644 index 0000000..e8764f3 --- /dev/null +++ b/src/lib/libast/stdio/vprintf.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vprintf(const char* fmt, va_list args) +{ + return sfvprintf(sfstdout, fmt, args); +} diff --git a/src/lib/libast/stdio/vscanf.c b/src/lib/libast/stdio/vscanf.c new file mode 100644 index 0000000..33371d9 --- /dev/null +++ b/src/lib/libast/stdio/vscanf.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vscanf(const char* fmt, va_list args) +{ + return sfvscanf(sfstdin, fmt, args); +} diff --git a/src/lib/libast/stdio/vsnprintf.c b/src/lib/libast/stdio/vsnprintf.c new file mode 100644 index 0000000..5cde8fa --- /dev/null +++ b/src/lib/libast/stdio/vsnprintf.c @@ -0,0 +1,52 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vsnprintf(char* s, int n, const char* form, va_list args) +{ + Sfio_t* f; + ssize_t rv; + + /* make a temp stream */ + if(!(f = sfnew(NIL(Sfio_t*),NIL(char*),(size_t)SF_UNBOUND, + -1,SF_WRITE|SF_STRING)) ) + return -1; + + if((rv = sfvprintf(f,form,args)) >= 0 ) + { if(s && n > 0) + { if((rv+1) >= n) + n--; + else + n = rv; + memcpy(s, f->data, n); + s[n] = 0; + } + _Sfi = rv; + } + + sfclose(f); + + return rv; +} diff --git a/src/lib/libast/stdio/vsprintf.c b/src/lib/libast/stdio/vsprintf.c new file mode 100644 index 0000000..8e44614 --- /dev/null +++ b/src/lib/libast/stdio/vsprintf.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vsprintf(char* s, const char* fmt, va_list args) +{ + return vsnprintf(s, 4 * SF_BUFSIZE, fmt, args); +} diff --git a/src/lib/libast/stdio/vsscanf.c b/src/lib/libast/stdio/vsscanf.c new file mode 100644 index 0000000..b7f14d6 --- /dev/null +++ b/src/lib/libast/stdio/vsscanf.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vsscanf(const char* s, const char* fmt, va_list args) +{ + return sfvsscanf(s, fmt, args); +} diff --git a/src/lib/libast/stdio/vswprintf.c b/src/lib/libast/stdio/vswprintf.c new file mode 100644 index 0000000..ac09afb --- /dev/null +++ b/src/lib/libast/stdio/vswprintf.c @@ -0,0 +1,55 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vswprintf(wchar_t* s, size_t n, const wchar_t* fmt, va_list args) +{ + Sfio_t f; + int v; + + if (!s) + return -1; + + /* + * make a fake stream + */ + + SFCLEAR(&f, NiL); + f.flags = SF_STRING|SF_WRITE; + f.bits = SF_PRIVATE; + f.mode = SF_WRITE; + f.size = n - 1; + f.data = f.next = f.endr = (uchar*)s; + f.endb = f.endw = f.data + f.size; + + /* + * call and adjust + */ + + v = vfwprintf(&f, fmt, args); + *f.next = 0; + _Sfi = f.next - f.data; + return v; +} diff --git a/src/lib/libast/stdio/vswscanf.c b/src/lib/libast/stdio/vswscanf.c new file mode 100644 index 0000000..3f6d96c --- /dev/null +++ b/src/lib/libast/stdio/vswscanf.c @@ -0,0 +1,51 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vswscanf(const wchar_t* s, const wchar_t* fmt, va_list args) +{ + Sfio_t f; + + if (!s) + return -1; + + /* + * make a fake stream + */ + + SFCLEAR(&f, NiL); + f.flags = SF_STRING|SF_READ; + f.bits = SF_PRIVATE; + f.mode = SF_READ; + f.size = wcslen(s) * sizeof(wchar_t); + f.data = f.next = f.endw = (uchar*)s; + f.endb = f.endr = f.data + f.size; + + /* + * sfio does the rest + */ + + return vfwscanf(&f, fmt, args); +} diff --git a/src/lib/libast/stdio/vwprintf.c b/src/lib/libast/stdio/vwprintf.c new file mode 100644 index 0000000..60e9dea --- /dev/null +++ b/src/lib/libast/stdio/vwprintf.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vwprintf(const wchar_t* fmt, va_list args) +{ + return vfwprintf(sfstdout, fmt, args); +} diff --git a/src/lib/libast/stdio/vwscanf.c b/src/lib/libast/stdio/vwscanf.c new file mode 100644 index 0000000..dd5007f --- /dev/null +++ b/src/lib/libast/stdio/vwscanf.c @@ -0,0 +1,30 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +vwscanf(const wchar_t* fmt, va_list args) +{ + return vfwscanf(sfstdin, fmt, args); +} diff --git a/src/lib/libast/stdio/wprintf.c b/src/lib/libast/stdio/wprintf.c new file mode 100644 index 0000000..bf8949a --- /dev/null +++ b/src/lib/libast/stdio/wprintf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +wprintf(const wchar_t* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = vfwprintf(sfstdout, fmt, args); + va_end(args); + return v; +} diff --git a/src/lib/libast/stdio/wscanf.c b/src/lib/libast/stdio/wscanf.c new file mode 100644 index 0000000..7c783b8 --- /dev/null +++ b/src/lib/libast/stdio/wscanf.c @@ -0,0 +1,36 @@ +/*********************************************************************** +* * +* 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 * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (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" + +int +wscanf(const wchar_t* fmt, ...) +{ + va_list args; + int v; + + va_start(args, fmt); + v = vfwscanf(sfstdin, fmt, args); + va_end(args); + return v; +} |