#ifndef __STDIO_LOADED #define __STDIO_LOADED 1 /**************************************************************************** ** ** - Standard Input/Output ** ***************************************************************************** ** Header introduced by the ANSI C Standard ***************************************************************************** ** ** Copyright 2000 Compaq Computer Corporation ** ** Compaq and the Compaq logo Registered in U.S. Patent and Trademark Office. ** ** Confidential computer software. Valid license from Compaq required for ** possession, use or copying. Consistent with FAR 12.211 and 12.212, ** Commercial Computer Software, Computer Software Documentation, and ** Technical Data for Commercial Items are licensed to the U.S. Government ** under vendor's standard commercial license. ** ****************************************************************************** */ #pragma __nostandard #include #ifdef __cplusplus extern "C" { #endif #if __INITIAL_POINTER_SIZE # pragma __pointer_size __save # pragma __pointer_size 32 #endif /* ** Cplusplus and unix_putc does not work together. ** Primarily for pragma inline functions. So put out an error. */ # if defined __UNIX_PUTC && defined __cplusplus # error " Use of __UNIX_PUTC not permitted with C++" # endif /* ** Member align structures */ #pragma __member_alignment __save #pragma __member_alignment /* ** Create 'public' typedefs that are either insensitive to pointer size or ** are sensitive to pointer size and must use short pointers. */ #ifndef NULL # define NULL __NULL #endif struct _iobuf { int _cnt; char *_ptr; char *_base; unsigned char _flag; #if __CRTL_VER >= 70000000 unsigned char _padfile; unsigned char _pad1; unsigned char _pad2; int _file; #else unsigned char _file; unsigned char _pad1; unsigned char _pad2; #endif }; #ifndef __FILE_T # define __FILE_T typedef __FILE FILE; #endif typedef struct {unsigned __f0 : 32; unsigned __f1 : 32; } fpos_t; #ifndef __SIZE_T # define __SIZE_T 1 typedef __size_t size_t; #endif /* ** Define macros to access stdin, stdout, and stderr */ #ifdef __ALPHA # define stderr (decc$ga_stderr) # define stdin (decc$ga_stdin) # define stdout (decc$ga_stdout) #else # define stderr (*decc$ga_stderr) # define stdin (*decc$ga_stdin) # define stdout (*decc$ga_stdout) #endif /* ** Define stdin, stdout, and stderr */ #pragma __extern_model __save #pragma __extern_model __strict_refdef extern __FILE * stderr; extern __FILE * stdin; extern __FILE * stdout; #pragma __extern_model __restore /* ** Define optind, opterr, optopt, and optarg. X/Open originally ** specified these in . ISO POSIX-2 moved them to ** X/Open retains them in both. */ #if __CRTL_VER >= 60200000 /* Supported starting with OpenVMS V6.2 */ # if defined(_XOPEN_SOURCE) || !defined(_ANSI_C_SOURCE) # pragma __extern_model __save # pragma __extern_model __strict_refdef extern int optind; extern int opterr; extern int optopt; extern char *optarg; # pragma __extern_model __restore # endif #endif /* ** The ANSI standard defines the following integral constant expressions as ** having distinct values, suitable for use as the third argument to the ** setvbuf function. */ #define _IOLBF 0x01 #define _IOFBF 0x02 #define _IONBF 0x04 /* ** Values for _flag field in the _iobuf structure. This flag is used by the ** functions clearerr(), feof() and ferror(). A standards conforming ** program should not use _IOEOF or _IOERR. Use clearerr, feof ** and ferror macros instead. */ # define _IOEOF 0x10 # define _IOERR 0x20 #ifndef _ANSI_C_SOURCE # define _IOREAD 0x01 # define _IOWRT 0x02 # define _IOMYBUF 0x08 # define _IOSTRG 0x40 # define _IORW 0x80 #endif /* ** Define seek modes. Note that the SEEK_EOF value is not defined by ** the ANSI standard, but is provided for compatibility with VAX C. */ #define SEEK_SET 0 #define SEEK_CUR 1 #define SEEK_END 2 #ifndef _ANSI_C_SOURCE # define SEEK_EOF SEEK_END #endif /* ** The literal BUFSIZ is defined by the ANSI standard as the size of the ** buffer used by the setbuf function. */ #ifdef __ALPHA # define BUFSIZ 32768 #else # define BUFSIZ 8192 #endif /* ** DEC C RTL extension. Define the values TRUE and FALSE. */ #ifndef _ANSI_C_SOURCE # ifndef TRUE # define TRUE 1 # endif # ifndef FALSE # define FALSE 0 # endif #endif /* ** The ANSI standard defines EOF as a negative integral constant expression ** that is returned by several functions to indicate end-of-file. */ #define EOF (-1) /* ** The ANSI standard defines FILENAME_MAX as an integral constant ** expression that is the size needed for an array of char large enough to ** hold the longest file name string that the implementation guarantees ** can be opened. ** ** The ANSI standard defines FOPEN_MAX as an integral constant expression ** that is the minumum number of files that the implementation guarantees ** can be opened simultaneously. This value is difficult to define as an ** accurate constant value since many things affect the ability to open a ** given number of files. */ #define FILENAME_MAX 256 #define FOPEN_MAX 8 /* ** DEC C RTL extension. Define OPEN_MAX to be identical to FOPEN_MAX. Also ** define _NFILE for VAX C compatibility. */ #ifndef _ANSI_C_SOURCE # define OPEN_MAX FOPEN_MAX # define _NFILE 20 #endif /* ** The literal values L_tmpnam and TMP_MAX are defined by the ANSI ** standard. If the argument to the tmpnam() function is not a null ** pointer, it is assumed to point to an array of at least L_tmpnam ** characters. The value TMP_MAX represents the number of unique names ** which must be returned from the tmpnam() function on successive calls. */ #define L_tmpnam 256 #define TMP_MAX 32 /* ** ISO POSIX-1 extensions. These literal values are analogous to the ** L_tmpnam value for tmpnam() function calls. */ #if defined(_POSIX_C_SOURCE) || !defined(_ANSI_C_SOURCE) # define L_cuserid 16 # define L_ctermid 64 #endif /* ** DEC C RTL extensions. These literal values are analogous to the ** L_tmpnam value for tmpnam() function calls. */ #ifndef _ANSI_C_SOURCE # define L_lcltmpnam 256 # define L_nettmpnam 256 #endif /* ** The MIA standard requires use of a special rename() and freopen() ** function. Define macros when compiling with that mode. */ #ifdef __MIA # define rename decc$mia_rename # define freopen decc$mia_freopen #endif /* ** DEC C Performance (Macros) */ #define feof(stream) (((unsigned int)((*(stream))->_flag) & _IOEOF) != 0) #define ferror(stream) (((unsigned int)((*(stream))->_flag) & _IOERR) != 0) #define clearerr(stream) ((void)((*(stream))->_flag &= ~(_IOERR | _IOEOF))) /* ** DEC C Performance (Inlined) ** ** Certain DEC C functions are available as inline code instead of making a ** call to the DEC C RTL. Using this inline code offers performance ** improvements and are enabled here for all programs on the ALPHA platform. */ #ifdef __ALPHA /* ** ANSI standard says that getc/putc can evaluate its parameters ** more than once. ** */ # ifndef getc # define getc(__fp) ((*__fp) ? \ (((((*__fp)->_cnt > 0) & !((int)(*__fp)->_flag & 0x40)) ? \ ((*__fp)->_cnt--, ((int) ((unsigned char) *((*__fp)->_ptr++)))) : \ (getc)(__fp))) : (getc)(__fp)) # endif # ifndef getchar # define getchar() ((*stdin) ? \ (((((*stdin)->_cnt > 0) & !((int)(*stdin)->_flag & 0x40)) ? \ ((*stdin)->_cnt--, ((int) ((unsigned char) *((*stdin)->_ptr++)))) : \ (getchar)())) : (getchar)()) # endif /* ** This is conditional until a problem with static inline ** procedures is corrected in the compiler. ** When this is corrected, we must separate this and ** conditionalize this out of c++. ** */ # ifdef __UNIX_PUTC # ifndef putc # pragma __inline __putc static int __putc( int __c, struct _iobuf **__p2 ) { struct _iobuf *__p = *__p2; if (!(*__p2)) return (putc)(__c,__p2); if ( !((__p)->_flag & 0x40) & ((int)((__p)->_ptr) != (int) *(((int *) (__p)) + 6)) & !(*(((unsigned char *)(__p))+14) & 0x10 )) { if ((__p)->_cnt) (__p)->_cnt--; *(__p)->_ptr++ = (__c); *(((unsigned char *) (__p)) + 14) |= 0x02; return __c; } else return (putc)(__c,__p2); } # define putc(c,fp) __putc(c,fp) # endif # ifndef putchar # pragma __inline __putchar static int __putchar( int __c ) { struct _iobuf *__p = *stdout; if (!(*stdout)) return (putchar)(__c); if (!((__p)->_flag & 0x40) & ((int)((__p)->_ptr)!=(int) *(((int *)(__p))+6)) & !(*(((unsigned char *)(__p))+14) & 0x10 )) { if ((__p)->_cnt) (__p)->_cnt--; *(__p)->_ptr++ = (__c); *(((unsigned char *) (__p)) + 14) |= 0x02; return __c; } else return (putchar)(__c); } # define putchar(c) __putchar(c) # endif # endif /* ** ANSI standard says that fgetc/fputc cannot evaluate its ** parameters more than once so make sure it is done ** via a static inline function. and surrounded by unix conditionals. */ # ifdef __UNIX_PUTC # ifndef fgetc # pragma inline __fgetc static int __fgetc (__FILE *__fp) {return (getc (__fp));} # define fgetc(fp) __fgetc(fp) # endif # ifndef fputc # pragma __inline __fputc static int __fputc(int __c, struct _iobuf **__p2) {return (putc(__c, __p2));} # define fputc(c,fp) __fputc(c,fp) # endif # endif #endif /* Alpha */ /* ** This section is for functions and declarations which do not support ** 64 bit pointers being passed (or returned). */ void setbuf (__FILE *__stream, char *__buf); int setvbuf (__FILE *__stream, char *__buf, int __mode, __size_t __size); /* ** The function cuserid is defined by IEEE Std 1003.1-1988 and was changed ** from mandatory to permitted by ISO POSIX-1. With IEEE Std 1003.1-1988, the ** definition is in . X/Open added it to while retaining ** the definition in ** ** The function getopt was originally in ISO POSIX-2 moved it to ** X/Open retains it in both. */ #if defined(_XOPEN_SOURCE) || !defined(_ANSI_C_SOURCE) # if __CRTL_VER >= 60200000 /* Supported starting with OpenVMS V6.2 */ int getopt (int __argc, char * const __argv[], const char *__optstring); # endif #endif /* ** We are done defining things which must always be short pointers. If ** the user has used /pointer_size=short or /pointer_size=long, we will ** allow long pointers to be used in function calls. */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size 64 #endif /* ** ANSI Function prototypes */ __size_t fread (void *__ptr, __size_t __size, __size_t __nmemb, __FILE *__stream); __size_t fwrite (const void *__ptr, __size_t __size, __size_t __nmemb, __FILE *__stream); int fclose (__FILE *__stream); int fflush (__FILE *__stream); int fgetpos (__FILE *__stream, fpos_t *__pos); int fprintf (__FILE *__stream, const char *__format, ...); int fputs (const char *__s, __FILE *__stream); int fscanf (__FILE *__stream, const char *__format, ...); int fseek (__FILE *__stream, long int __offset, int __whence); int fsetpos (__FILE *__stream, const fpos_t *__pos); long ftell (__FILE *__stream); void perror (const char *__s); int printf (const char *__format, ...); int puts (const char *__s); int remove (const char *__filename); int rename (const char *__old, const char *__new); int scanf (const char *__format, ...); int sprintf (char *__s, const char *__format, ...); int sscanf (const char *__s, const char *__format, ...); int ungetc (int __c, __FILE *__stream); int vfprintf (__FILE *__stream, const char *__format, __va_list __arg); int vprintf (const char *__format, __va_list __arg); int vsprintf (char *__s, const char *__format, __va_list __arg); __FILE_ptr32 tmpfile(void); /* ** The following function prototypes may be defined as macros */ void (clearerr) (__FILE *__stream); int (feof) (__FILE *__stream); int (ferror) (__FILE *__stream); int (fgetc) (__FILE *__stream); int (fputc) (int __c, __FILE *__stream); int (getc) (__FILE *__stream); int (getchar) (void); int (putc) (int __c, __FILE *__stream); int (putchar) (int __c); /* ** By defining __UNIX_FOPEN, a macro for fopen is defined which ensures ** that the created file does not inherit attributes from an existing ** file. To use the fopen function with optional RMS arguments, the ** caller is required to use (fopen)() to prevent macro expansion. */ #ifdef __UNIX_FOPEN __FILE_ptr32 fopen (const char *__filename, const char *__mode, ...); # define fopen(__p1,__p2) \ (fopen)(__p1,__p2,"ctx=stm","rfm=stmlf","rat=cr","mrs=0") #else # ifdef _ANSI_C_SOURCE __FILE_ptr32 fopen (const char *__filename, const char *__mode); # else __FILE_ptr32 fopen (const char *__filename, const char *__mode, ...); # endif #endif /* ** The DEC C RTL extends the ANSI standard definitions of the following ** functions. The function prototypes used in this header file differ ** when the user is compiling /standard=ansi89. */ #ifdef _ANSI_C_SOURCE __FILE_ptr32 freopen (const char *__filename, const char *__mode, __FILE *__stream); void rewind (__FILE *__stream); #else __FILE_ptr32 freopen (const char *__filename, const char *__mode, __FILE *__stream, ...); int rewind (__FILE *__stream); #endif /* ** The following functions have interfaces of XXX, _XXX32, and _XXX64 due ** to the fact that the return argument is a pointer that is relative to ** one of the arguments. */ #if __INITIAL_POINTER_SIZE == 32 #pragma __pointer_size 32 #endif #if defined(_POSIX_C_SOURCE) || !defined(_ANSI_C_SOURCE) char *ctermid (char *__str); #endif #if defined(_XOPEN_SOURCE) || !defined(_ANSI_C_SOURCE) char *cuserid (char *__str); #endif char *gets (char *__s); char *fgets (char *__s, int __n, __FILE *__stream); char *tmpnam (char *__s); #if __INITIAL_POINTER_SIZE == 32 #pragma __pointer_size 64 #endif #if __INITIAL_POINTER_SIZE && !defined(_ANSI_C_SOURCE) && __CRTL_VER >= 70000000 # pragma __pointer_size 32 char *_ctermid32 (char *__str); char *_cuserid32 (char *__str); char *_gets32 (char *); char *_fgets32 (char *, int, __FILE *); char *_tmpnam32 (char *); # pragma __pointer_size 64 char *_ctermid64 (char *__str); char *_cuserid64 (char *__str); char *_gets64 (char *); char *_fgets64 (char *, int, __FILE *); char *_tmpnam64 (char *); #endif /* ** ISO POSIX-1 Extensions */ #if defined(_POSIX_C_SOURCE) || !defined(_ANSI_C_SOURCE) int (fileno) (__FILE *__stream); __FILE_ptr32 fdopen(int __file_desc, const char *__mode); #endif /* ** ISO POSX-2 Extensions */ #if _POSIX_C_SOURCE >= 2 || !defined(_ANSI_C_SOURCE) && __CRTL_VER >= 70000000 __FILE_ptr32 popen(const char *__command, const char *__mode); int pclose(__FILE *__stream); #endif /* ** X/Open extensions */ #if defined(_XOPEN_SOURCE) || !defined(_ANSI_C_SOURCE) int getw (__FILE *__stream); int putw (int __integer, __FILE *__stream); #if __CRTL_VER >= 70000000 /* tempnam() was introduced in OpenVMS V7.0 */ /* ** P_tmpdir is the directory name used for tempnam(). It is defined ** by X/Open. */ # define P_tmpdir "SYS$SCRATCH:" __char_ptr32 tempnam(const char *dir, const char *pfx); #endif #endif /* ** DEC C RTL extensions. This include explicit 64-bit interfaces ** to otherwise standard routines. */ #ifndef _ANSI_C_SOURCE # if __INITIAL_POINTER_SIZE == 32 # pragma __pointer_size 32 # endif char *fgetname(__FILE *__stream, char *__buf, ...); # if __INITIAL_POINTER_SIZE && __CRTL_VER >= 70000000 # pragma __pointer_size 32 char *_fgetname32(__FILE *__stream, char *__buf, ...); # pragma __pointer_size 64 char *_fgetname64(__FILE *__stream, char *__buf, ...); # endif int decc$read (int __file_desc, void *__buffer, int __nbytes); # define decc$record_read(stream, buf, max_size) decc$read (((*(stream))->_file), (buf), (max_size)) # define decc$record_write(stream, buf, size) fwrite ((buf), (size), 1, (stream)) # define FILE_TYPE struct _iobuf * int fwait (__FILE *__stream); int lwait (int __file_desc); /* ** fsync is standardized by X/Open to be in */ int fsync (int __file_desc); # endif /* ** Support code for precompiled printf functions */ #if ((__DECC_VER > 50600000) && defined(_INTRINSICS)) # pragma intrinsic(printf, fprintf, sprintf) # ifdef _INLINE_INTRINSICS static __inline int decc$__CFE_print_puts(const char *x) { return(fputs(x,stdout)); } static __inline int decc$__CFE_print_putc(int x) { putc(x,stdout); return(1); } static __inline int decc$__CFE_print_putc_nl(int x) { putc(x,stdout); putc('\n',stdout); return(2); } static __inline int decc$__CFE_fprint_puts_nl(const char *x, __FILE *f) { register int i = fputs(x,f); putc('\n',f); return(i+1); } static __inline int decc$__CFE_fprint_putc(int x, __FILE *f) { putc(x,f); return(1); } static __inline int decc$__CFE_fprint_putc_nl(int x, __FILE *f) { putc(x,f); putc('\n',f); return(2); } # else int decc$__CFE_print_puts( const char *x ); int decc$__CFE_print_putc( int x ); int decc$__CFE_print_putc_nl( int x ); int decc$__CFE_fprint_puts_nl( const char *x, __FILE *f ); int decc$__CFE_fprint_putc( int x, __FILE *f ); int decc$__CFE_fprint_putc_nl( int x, __FILE *f ); # endif #endif /* ** Restore the users pointer context */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size __restore #endif #ifdef __cplusplus } #endif #pragma __member_alignment __restore #pragma __standard #endif /* __STDIO_LOADED */