From c505305855a5c7c999c7adfa0271436b3ff6ee55 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Wed, 8 Mar 2000 03:42:25 +0000 Subject: * libc/stdio/Makefile.am (lib_a_SOURCES): Added getw.c and putw.c. (CHEWOUT_FILES): Added getw.def and putw.def. * libc/stdio/Makefile.in: Rebuilt. * libc/stdio/stdio.tex: Include getw.def and putw.def. * libc/stdio/getw.c: New file. * libc/stdio/putw.c: New file. --- newlib/libc/stdio/Makefile.am | 4 +++ newlib/libc/stdio/Makefile.in | 8 ++++-- newlib/libc/stdio/getw.c | 67 +++++++++++++++++++++++++++++++++++++++++++ newlib/libc/stdio/putw.c | 66 ++++++++++++++++++++++++++++++++++++++++++ newlib/libc/stdio/stdio.tex | 8 ++++++ 5 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 newlib/libc/stdio/getw.c create mode 100644 newlib/libc/stdio/putw.c (limited to 'newlib/libc') diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am index 234da49b6..8461d4ace 100644 --- a/newlib/libc/stdio/Makefile.am +++ b/newlib/libc/stdio/Makefile.am @@ -36,6 +36,7 @@ lib_a_SOURCES = \ getc.c \ getchar.c \ gets.c \ + getw.c \ iprintf.c \ makebuf.c \ mktemp.c \ @@ -44,6 +45,7 @@ lib_a_SOURCES = \ putc.c \ putchar.c \ puts.c \ + putw.c \ refill.c \ remove.c \ rename.c \ @@ -97,12 +99,14 @@ CHEWOUT_FILES = \ getc.def \ getchar.def \ gets.def \ + getw.def \ iprintf.def \ mktemp.def \ perror.def \ putc.def \ putchar.def \ puts.def \ + putw.def \ remove.def \ rename.def \ rewind.def \ diff --git a/newlib/libc/stdio/Makefile.in b/newlib/libc/stdio/Makefile.in index ff2a83845..2f487a19f 100644 --- a/newlib/libc/stdio/Makefile.in +++ b/newlib/libc/stdio/Makefile.in @@ -118,6 +118,7 @@ lib_a_SOURCES = \ getc.c \ getchar.c \ gets.c \ + getw.c \ iprintf.c \ makebuf.c \ mktemp.c \ @@ -126,6 +127,7 @@ lib_a_SOURCES = \ putc.c \ putchar.c \ puts.c \ + putw.c \ refill.c \ remove.c \ rename.c \ @@ -177,12 +179,14 @@ CHEWOUT_FILES = \ getc.def \ getchar.def \ gets.def \ + getw.def \ iprintf.def \ mktemp.def \ perror.def \ putc.def \ putchar.def \ puts.def \ + putw.def \ remove.def \ rename.def \ rewind.def \ @@ -216,8 +220,8 @@ lib_a_DEPENDENCIES = vfiprintf.o lib_a_OBJECTS = clearerr.o fclose.o fdopen.o feof.o ferror.o fflush.o \ fgetc.o fgetpos.o fgets.o fileno.o findfp.o fiprintf.o flags.o fopen.o \ fprintf.o fputc.o fputs.o fread.o freopen.o fscanf.o fseek.o fsetpos.o \ -ftell.o fvwrite.o fwalk.o fwrite.o getc.o getchar.o gets.o iprintf.o \ -makebuf.o mktemp.o perror.o printf.o putc.o putchar.o puts.o refill.o \ +ftell.o fvwrite.o fwalk.o fwrite.o getc.o getchar.o gets.o getw.o iprintf.o \ +makebuf.o mktemp.o perror.o printf.o putc.o putchar.o puts.o putw.o refill.o \ remove.o rename.o rewind.o rget.o scanf.o setbuf.o setvbuf.o siprintf.o \ snprintf.o sprintf.o sscanf.o stdio.o tmpfile.o tmpnam.o ungetc.o \ vfprintf.o vfscanf.o vprintf.o vsnprintf.o vsprintf.o wbuf.o wsetup.o diff --git a/newlib/libc/stdio/getw.c b/newlib/libc/stdio/getw.c new file mode 100644 index 000000000..b6fd87313 --- /dev/null +++ b/newlib/libc/stdio/getw.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* +FUNCTION +<>---read a word (int) + +INDEX + getw + +ANSI_SYNOPSIS + #include + int getw(FILE *<[fp]>); + +TRAD_SYNOPSIS + #include + int getw(<[fp]>) + FILE *<[fp]>; + +DESCRIPTION +<> is a function, defined in <>. You can use <> +to get the next word from the file or stream identified by <[fp]>. As +a side effect, <> advances the file's current position +indicator. + +RETURNS The next word (read as an <>), unless there is no more +data, or the host system reports a read error; in either of these +situations, <> returns <>. Since <> is a valid +<>, you must use <> or <> to distinguish these +situations. + +PORTABILITY +<> is a remnant of K&R C, it is not part of any ISO C Standard. +<> should be used instead. In fact, this implementation of +<> is based upon <>. + +Supporting OS subroutines required: <>. */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "%W% (Berkeley) %G%"; +#endif /* LIBC_SCCS and not lint */ + +#include + +int +getw (fp) + register FILE *fp; +{ + int result; + if (fread((char*)&result, sizeof(result), 1, fp) != 1) + return EOF; + return result; +} diff --git a/newlib/libc/stdio/putw.c b/newlib/libc/stdio/putw.c new file mode 100644 index 000000000..4bcefaf7d --- /dev/null +++ b/newlib/libc/stdio/putw.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* +FUNCTION +<>---write a word (int) + +INDEX + putw + +ANSI_SYNOPSIS + #include + int putw(int <[w]>, FILE *<[fp]>); + +TRAD_SYNOPSIS + #include + int putw(, <[fp]>) + int ; + FILE *<[fp]>; + +DESCRIPTION +<> is a function, defined in <>. You can use <> +to write a word to the file or stream identified by <[fp]>. As a side +effect, <> advances the file's current position indicator. + +RETURNS The written word, unless the host system reports a write +error, in which case <> returns <>. Since <> is a +valid <>, you must use <> or <> to distinguish +these situations when writing the integer equal to <>. + +PORTABILITY +<> is a remnant of K&R C, it is not part of any ISO C Standard. +<> should be used instead. In fact, this implementation of +<> is based upon <>. + +Supporting OS subroutines required: <>. */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "%W% (Berkeley) %G%"; +#endif /* LIBC_SCCS and not lint */ + +#include + +int +putw (w, fp) + int w; + register FILE *fp; +{ + if (fwrite((const char*)&w, sizeof(w), 1, fp) != 1) + return EOF; + return w; +} diff --git a/newlib/libc/stdio/stdio.tex b/newlib/libc/stdio/stdio.tex index 466e1f0db..725b2f35b 100644 --- a/newlib/libc/stdio/stdio.tex +++ b/newlib/libc/stdio/stdio.tex @@ -46,12 +46,14 @@ structure. * getc:: Get a character from a file or stream (macro) * getchar:: Get a character from standard input (macro) * gets:: Get character string from standard input (obsolete) +* getw:: Get a word (int) from a file or stream * iprintf:: Write formatted output (integer only) * mktemp:: Generate unused file name * perror:: Print an error message on standard error * putc:: Write a character on a stream or file (macro) * putchar:: Write a character on standard output (macro) * puts:: Write a character string on standard output +* putw:: Write a word (int) to a file or stream * remove:: Delete a file's name * rename:: Rename a file * rewind:: Reinitialize a file or stream @@ -131,6 +133,9 @@ structure. @page @include stdio/gets.def +@page +@include stdio/getw.def + @page @include stdio/iprintf.def @@ -149,6 +154,9 @@ structure. @page @include stdio/puts.def +@page +@include stdio/putw.def + @page @include stdio/remove.def -- cgit v1.2.3