# To unbundle, run this file echo abort.3 sed 's/.//' >abort.3 <<'//GO.SYSIN DD abort.3' -.TH ABORT 3 -.SH NAME -abort \- generate IOT fault -.SH DESCRIPTION -.I Abort -executes the PDP11 IOT instruction. -This causes a signal that normally terminates -the process with a core dump, which may be used for debugging. -.SH SEE ALSO -adb(1), signal(2), exit(2) -.SH DIAGNOSTICS -Usually `IOT trap \- core dumped' from the shell. //GO.SYSIN DD abort.3 echo abs.3 sed 's/.//' >abs.3 <<'//GO.SYSIN DD abs.3' -.TH ABS 3 -.SH NAME -abs \- integer absolute value -.SH SYNOPSIS -.B abs(i) -.SH DESCRIPTION -.I Abs -returns -the absolute value of its integer operand. -.SH SEE ALSO -floor(3) for -.I fabs -.SH BUGS -You get what the hardware gives on the largest negative integer. //GO.SYSIN DD abs.3 echo assert.3x sed 's/.//' >assert.3x <<'//GO.SYSIN DD assert.3x' -.TH ASSERT 3X -.SH NAME -assert \- -program verification -.SH SYNOPSIS -.B #include -.PP -.B assert (expression) -.SH DESCRIPTION -.PP -.I Assert -is a macro that indicates -.I expression -is expected to be true at this point in the program. -It causes an -.IR exit (2) -with a diagnostic comment on the standard output -when -.I expression -is false (0). -Compiling with the -.IR cc (1) -option -.SM -.B \-DNDEBUG -effectively deletes -.I assert -from the program. -.SH DIAGNOSTICS -`Assertion failed: file -.I f -line -.I n.' -.I F -is the source file and -.I n -the source line number -of the -.I assert -statement. //GO.SYSIN DD assert.3x echo atof.3 sed 's/.//' >atof.3 <<'//GO.SYSIN DD atof.3' -.TH ATOF 3 -.SH NAME -atof, atoi, atol \- convert ASCII to numbers -.SH SYNOPSIS -.B double atof(nptr) -.br -.B char *nptr; -.PP -.B atoi(nptr) -.br -.B char *nptr; -.PP -.B long atol(nptr) -.br -.B char *nptr; -.SH DESCRIPTION -These functions convert a string pointed to by -.I nptr -to floating, integer, and long integer -representation respectively. -The first unrecognized character ends the string. -.PP -.I Atof -recognizes an optional string of tabs and spaces, -then an optional sign, then -a string of digits optionally containing a decimal -point, then an optional `e' or `E' followed -by an optionally signed integer. -.PP -.I Atoi -and -.I atol -recognize an optional string of tabs and spaces, -then an optional sign, then a string of -digits. -.SH SEE ALSO -scanf(3) -.SH BUGS -There are no provisions for overflow. //GO.SYSIN DD atof.3 echo crypt.3 sed 's/.//' >crypt.3 <<'//GO.SYSIN DD crypt.3' -.TH CRYPT 3 -.SH NAME -crypt, setkey, encrypt \- DES encryption -.SH SYNOPSIS -.B char *crypt(key, salt) -.br -.B char *key, *salt; -.PP -.B setkey(key) -.br -.B char *key; -.PP -.B encrypt(block, edflag) -.br -.B char *block; -.SH DESCRIPTION -.I Crypt -is the password encryption routine. -It is based on the NBS Data Encryption Standard, with -variations intended (among other things) to frustrate use of hardware -implementations of the DES for key search. -.PP -The first argument to -.I crypt -is a user's typed password. -The second is a 2-character string chosen from the -set [a-zA-Z0-9./]. -The -.I salt -string is used to perturb the DES algorithm in one of 4096 -different ways, after which the password -is used as the key to encrypt repeatedly a constant string. -The returned value points to the encrypted password, -in the same alphabet as the salt. -The first two characters are the salt itself. -.PP -The other entries provide (rather primitive) -access to the actual DES algorithm. -The argument of -.I setkey -is a character array of length 64 containing only the characters -with numerical value 0 and 1. -If this string is divided into groups of 8, -the low-order bit in each group is ignored, -leading to a 56-bit key which is set into the machine. -.PP -The argument to the -.I encrypt -entry is likewise a character array of length 64 -containing 0's and 1's. -The argument array is modified in place -to a similar array -representing the bits of the argument after having been -subjected to the DES algorithm using the key set by -.I setkey. -If -.I edflag -is 0, the argument is encrypted; -if non-zero, -it is decrypted. -.SH "SEE ALSO" -passwd(1), passwd(5), login(1), getpass(3) -.SH BUGS -The return value -points to static data whose content is overwritten -by each call. //GO.SYSIN DD crypt.3 echo ctime.3 sed 's/.//' >ctime.3 <<'//GO.SYSIN DD ctime.3' -.TH CTIME 3 -.SH NAME -ctime, localtime, gmtime, asctime, timezone \- convert date and time to ASCII -.SH SYNOPSIS -.B char *ctime(clock) -.br -.B long *clock; -.PP -.B #include -.PP -.B struct tm *localtime(clock) -.br -.B long *clock; -.PP -.B struct tm *gmtime(clock) -.br -.B long *clock; -.PP -.B char *asctime(tm) -.br -.B struct tm *tm; -.PP -.B char *timezone(zone, dst) -.SH DESCRIPTION -.I Ctime -converts a time pointed to by -.I clock -such as returned by -.IR time (2) -into ASCII -and returns a pointer to a -26-character string -in the following form. -All the fields have constant width. -.PP - Sun Sep 16 01:03:52 1973\\n\\0 -.PP -.I Localtime -and -.I gmtime -return pointers to structures containing -the broken-down time. -.I Localtime -corrects for the time zone and possible daylight savings time; -.I gmtime -converts directly to GMT, which is the time UNIX uses. -.I Asctime -converts a broken-down time to ASCII and returns a pointer -to a 26-character string. -.PP -The structure declaration from the include file is: -.RS -.PP -.nf -.so /usr/include/time.h -.fi -.RE -.PP -These quantities give the time on a 24-hour clock, -day of month (1-31), month of year (0-11), day of week -(Sunday = 0), year \- 1900, day of year (0-365), -and a flag that is nonzero if daylight saving time is in effect. -.PP -When local time is called for, -the program consults the system to determine the time zone and -whether the standard U.S.A. daylight saving time adjustment is -appropriate. -The program knows about the peculiarities -of this conversion in 1974 and 1975; -if necessary, -a table for these years can be extended. -.PP -.I Timezone -returns the name of the time zone associated with its first argument, -which is measured in minutes westward from Greenwich. -If the second argument is 0, the standard name is used, -otherwise the Daylight Saving version. -If the required name does not appear in a table -built into the routine, -the difference from GMT is produced; e.g. -in Afghanistan -.I timezone(\-(60*4+30), 0) -is appropriate because it is 4:30 ahead of GMT -and the string -.B GMT+4:30 -is produced. -.SH "SEE ALSO" -time(2) -.SH BUGS -The return values point to static data -whose content is overwritten by each call. //GO.SYSIN DD ctime.3 echo ctype.3 sed 's/.//' >ctype.3 <<'//GO.SYSIN DD ctype.3' -.TH CTYPE 3 -.SH NAME -isalpha, isupper, islower, isdigit, isalnum, isspace, ispunct, -isprint, iscntrl, isascii \- -character classification -.SH SYNOPSIS -.B #include -.PP -.B isalpha(c) -.PP -.B . . . -.SH DESCRIPTION -These macros classify ASCII-coded integer values -by table lookup. -Each is a predicate returning nonzero for true, -zero for false. -.I Isascii -is defined on all integer values; the rest -are defined only where -.I isascii -is true and on the single non-ASCII value -EOF (see -.IR stdio (3)). -.TP 15n -.I isalpha -.I c -is a letter -.TP -.I isupper -.I c -is an upper case letter -.TP -.I islower -.I c -is a lower case letter -.TP -.I isdigit -.I c -is a digit -.TP -.I isalnum -.I c -is an alphanumeric character -.TP -.I isspace -.I c -is a space, tab, carriage return, newline, or formfeed -.TP -.I ispunct -.I c -is a punctuation character (neither control nor alphanumeric) -.TP -.I isprint -.I c -is a printing character, code 040(8) (space) through 0176 (tilde) -.TP -.I iscntrl -.I c -is a delete character (0177) or ordinary control character -(less than 040). -.TP -.I isascii -.I c -is an ASCII character, code less than 0200 -.SH "SEE ALSO" -ascii(7) //GO.SYSIN DD ctype.3 echo dbm.3x sed 's/.//' >dbm.3x <<'//GO.SYSIN DD dbm.3x' -.TH DBM 3X -.SH NAME -dbminit, fetch, store, delete, firstkey, nextkey \- data base subroutines -.SH SYNOPSIS -.nf -.PP -.B "typedef struct { char *dptr; int dsize; } datum;" -.PP -.B dbminit(file) -.B char *file; -.PP -.B datum fetch(key) -.B datum key; -.PP -.B store(key, content) -.B datum key, content; -.PP -.B delete(key) -.B datum key; -.PP -.B datum firstkey(); -.PP -.B datum nextkey(key); -.B datum key; -.SH DESCRIPTION -These functions maintain -key/content pairs in a data base. -The functions will handle very large -(a billion blocks) -databases and will access a keyed item -in one or two filesystem accesses. -The functions are obtained with the loader option -.BR \-ldbm . -.PP -.IR Key s -and -.IR content s -are -described by the -.I datum -typedef. -A -.I datum -specifies a string of -.I dsize -bytes pointed to by -.I dptr. -Arbitrary binary data, as well as normal -ASCII strings, are allowed. -The data base is stored in two files. -One file is a directory containing a bit map -and has `.dir' as its suffix. -The second file contains all data and -has `.pag' as its suffix. -.PP -Before a database can be accessed, -it must be opened by -.I dbminit. -At the time of this call, -the files -.IB file .dir -and -.IB file .pag -must exist. -(An empty database is created by -creating zero-length -`.dir' and `.pag' files.) -.PP -Once open, -the data stored under a key is -accessed by -.I fetch -and data is placed under a key -by -.IR store . -A key (and its associated contents) -is deleted by -.IR delete . -A linear pass through all keys in a database -may be made, -in an (apparently) random order, -by use of -.I firstkey -and -.IR nextkey . -.I Firstkey -will return the first key -in the database. -With any key -.I nextkey -will return the next key in the database. -This code will traverse the data base: -.PP - for(key=firstkey(); key.dptr!=NULL; key=nextkey(key)) -.SH DIAGNOSTICS -All functions that return an -.I int -indicate errors with negative values. -A zero return indicates ok. -Routines that return a -.I datum -indicate errors with a null (0) -.I dptr. -.SH BUGS -The -`.pag' -file will contain holes so -that its apparent size is about -four times its actual content. -Older UNIX systems may create real -file blocks for these holes when touched. -These files cannot be copied -by normal means (cp, cat, tp, tar, ar) -without filling in the holes. -.PP -.I Dptr -pointers returned -by these subroutines -point into static storage -that is changed by subsequent calls. -.PP -The sum of the sizes of -a -key/content pair must not exceed -the internal block size -(currently 512 bytes). -Moreover all key/content pairs that hash -together must fit on a single block. -.I Store -will return an error in the event that -a disk block fills with inseparable data. -.PP -.I Delete -does not physically reclaim file space, -although it does make it available for reuse. -.PP -The order of keys presented by -.I firstkey -and -.I nextkey -depends on a hashing function, not on anything -interesting. //GO.SYSIN DD dbm.3x echo ecvt.3 sed 's/.//' >ecvt.3 <<'//GO.SYSIN DD ecvt.3' -.TH ECVT 3 -.SH NAME -ecvt, fcvt, gcvt \- output conversion -.SH SYNOPSIS -.B char *ecvt(value, ndigit, decpt, sign) -.br -.B double value; -.br -.B int ndigit, *decpt, *sign; -.PP -.B char *fcvt(value, ndigit, decpt, sign) -.br -.B double value; -.br -.B int ndigit, *decpt, *sign; -.PP -.B char *gcvt(value, ndigit, buf) -.br -.B double value; -.br -.B char *buf; -.SH DESCRIPTION -.I Ecvt -converts the -.I value -to a null-terminated string of -.I ndigit -ASCII digits -and returns a pointer thereto. -The position of the decimal point relative to the -beginning of the string is stored indirectly -through -.IR decpt "" -(negative means to the left of the -returned digits). -If the sign of the result is negative, -the word pointed to by -.IR sign "" -is non-zero, otherwise -it is zero. -The low-order digit is rounded. -.PP -.IR Fcvt " is identical to " "ecvt\fR, except that the correct digit" -has been rounded for Fortran F-format output of the number -of digits specified by -.IR \(*_ndigits . -.PP -.I Gcvt -converts the -.I value -to a null-terminated ASCII string in -.I buf -and returns a pointer to -.I buf. -It attempts to produce -.I ndigit -significant digits in Fortran F format if -possible, otherwise E format, ready for -printing. -Trailing zeros may be suppressed. -.SH "SEE ALSO" -printf(3) -.SH BUGS -The return values point to static data -whose content is overwritten by each call. //GO.SYSIN DD ecvt.3 echo end.3 sed 's/.//' >end.3 <<'//GO.SYSIN DD end.3' -.TH END 3 -.SH NAME -end, etext, edata \- last locations in program -.SH SYNOPSIS -.B extern end; -.br -.B extern etext; -.br -.B extern edata; -.SH DESCRIPTION -These names refer neither to routines -nor to locations with interesting contents. -The address of -.I etext -is the first address above the program text, -.I edata -above the initialized data region, and -.I end -above the uninitialized data region. -.PP -When execution begins, the program break -coincides with -.I end, -but many functions reset the program break, among them -the routines of -.IR brk (2), -.IR malloc (3), -standard input/output -.RI ( stdio (3)), -the profile -.RB ( \-p ) -option of -.IR cc (1), -etc. -The current value of the program break -is reliably returned by `sbrk(0)', -see -.IR brk (2). -.SH "SEE ALSO" -brk(2), malloc(3) //GO.SYSIN DD end.3 echo exp.3m sed 's/.//' >exp.3m <<'//GO.SYSIN DD exp.3m' -.TH EXP 3M -.SH NAME -exp, log, log10, pow, sqrt \- exponential, logarithm, power, square root -.SH SYNOPSIS -.B #include -.PP -.B double exp(x) -.br -.B double x; -.PP -.B double log(x) -.br -.B double x; -.PP -.B double log10(x) -.br -.B double x; -.PP -.B double pow(x, y) -.br -.B double x, y; -.PP -.B double sqrt(x) -.br -.B double x; -.SH DESCRIPTION -.I Exp -returns the exponential function of -.I x. -.PP -.I Log -returns the natural logarithm of -.IR x ; -.I log10 -returns the base 10 logarithm. -.PP -.I Pow -returns -.I x\u\s8y\s10\d. -.PP -.I Sqrt -returns the square root of -.I x. -.SH SEE ALSO -hypot(3), -sinh(3), -intro(2) -.SH DIAGNOSTICS -.I Exp -and -.I pow -return a huge value when the correct value would -overflow; -.I errno -is set to ERANGE. -.I Pow -returns 0 and sets -.I errno -to -EDOM when the second argument is negative and non-integral and -when -both arguments are 0. -.PP -.I Log -returns 0 when -.I x -is zero or negative; -.I errno -is set to EDOM. -.PP -.I Sqrt -returns 0 when -.I x -is negative; -.I errno -is set to EDOM. //GO.SYSIN DD exp.3m echo fclose.3s sed 's/.//' >fclose.3s <<'//GO.SYSIN DD fclose.3s' -.TH FCLOSE 3S -.SH NAME -fclose, fflush \- close or flush a stream -.SH SYNOPSIS -.B #include -.PP -.B fclose(stream) -.br -.SM -.B FILE -.B *stream; -.PP -.B fflush(stream) -.br -.SM -.B FILE -.B *stream; -.SH DESCRIPTION -.I Fclose -causes any buffers for the named -.I stream -to be emptied, and the file to be closed. -Buffers allocated by the standard input/output system -are freed. -.PP -.I Fclose -is performed automatically upon -calling -.IR exit (2). -.PP -.I Fflush -causes any buffered data for the named output -.I stream -to be written to that file. -The stream remains open. -.SH "SEE ALSO" -close(2), -fopen(3), -setbuf(3) -.SH DIAGNOSTICS -These routines return -.SM -.B EOF -if -.I stream -is not associated with an output file, or -if buffered data cannot be transferred to that file. //GO.SYSIN DD fclose.3s echo ferror.3s sed 's/.//' >ferror.3s <<'//GO.SYSIN DD ferror.3s' -.TH FERROR 3S -.SH NAME -feof, ferror, clearerr, fileno \- stream status inquiries -.SH SYNOPSIS -.B #include -.PP -.B feof(stream) -.br -.SM -.B FILE -.B *stream; -.PP -.B ferror(stream) -.br -.SM -.B FILE -.B *stream -.PP -.B clearerr(stream) -.br -.SM -.B FILE -.B *stream -.PP -.B fileno(stream) -.br -.SM -.B FILE -.B *stream; -.SH DESCRIPTION -.I Feof -returns non-zero when end of file is read on the named input -.I stream, -otherwise zero. -.PP -.I Ferror -returns non-zero when an error has occurred reading or writing -the named -.I stream, -otherwise zero. -Unless cleared by -.I clearerr, -the error indication lasts until -the stream is closed. -.PP -.I Clrerr -resets the error indication on the named -.I stream. -.PP -.I Fileno -returns the integer file descriptor -associated with the -.I stream, -see -.IR open (2). -.PP -These functions -are implemented as macros; -they cannot be redeclared. -.SH "SEE ALSO" -fopen(3), open(2) //GO.SYSIN DD ferror.3s echo floor.3m sed 's/.//' >floor.3m <<'//GO.SYSIN DD floor.3m' -.TH FLOOR 3M -.SH NAME -fabs, floor, ceil \- absolute value, floor, ceiling functions -.SH SYNOPSIS -.B #include -.PP -.B double floor(x) -.br -.B double x; -.PP -.B double ceil(x) -.br -.B double x; -.PP -.B double fabs(x) -.br -.B double(x); -.SH DESCRIPTION -.I Fabs -returns the absolute value -.RI | \|x\| |. -.PP -.I Floor -returns the -largest integer -not greater than -.IR x . -.PP -.I Ceil -returns the -smallest integer -not less than -.IR x . -.SH SEE ALSO -abs(3) //GO.SYSIN DD floor.3m echo fopen.3s sed 's/.//' >fopen.3s <<'//GO.SYSIN DD fopen.3s' -.TH FOPEN 3S -.SH NAME -fopen, freopen, fdopen \- open a stream -.SH SYNOPSIS -.B #include -.PP -.SM -.B FILE -.B *fopen(filename, type) -.br -.B char *filename, *type; -.PP -.SM -.B FILE -.B *freopen(filename, type, stream) -.br -.B char *filename, *type; -.br -.SM -.B FILE -.B *stream; -.PP -.SM -.B FILE -.B *fdopen(fildes, type) -.br -.B char *type; -.SH DESCRIPTION -.I Fopen -opens the file named by -.I filename -and associates a stream with it. -.I Fopen -returns a pointer to be used to identify -the stream in subsequent operations. -.PP -.I Type -is a character string having one of the following values: -.TP 5 -"r" -open for reading -.ns -.TP 5 -"w" -create for writing -.ns -.TP 5 -"a" -append: open for writing at end -of file, or create for writing -.PP -.I Freopen -substitutes the named file in place -of the open -.IR stream . -It returns the original value of -.IR stream . -The original stream is closed. -.PP -.I Freopen -is typically used to attach the preopened -constant names, -.B stdin, stdout, stderr, -to specified files. -.PP -.I Fdopen -associates a stream with a file descriptor obtained from -.I open, dup, creat, -or -.IR pipe (2). -The -.I type -of the stream must agree with the mode of the open file. -.SH "SEE ALSO" -open(2), -fclose(3) -.SH DIAGNOSTICS -.I Fopen -and -.I freopen -return the pointer -.SM -.B NULL -if -.I filename -cannot be accessed. -.SH BUGS -.I Fdopen -is not portable to systems other than UNIX. //GO.SYSIN DD fopen.3s echo fread.3s sed 's/.//' >fread.3s <<'//GO.SYSIN DD fread.3s' -.TH FREAD 3S -.SH NAME -fread, fwrite \- buffered binary input/output -.SH SYNOPSIS -.B #include -.PP -.B fread(ptr, sizeof(*ptr), nitems, stream) -.br -.SM -.B FILE -.B *stream; -.PP -.B fwrite(ptr, sizeof(*ptr), nitems, stream) -.br -.SM -.B FILE -.B *stream; -.SH DESCRIPTION -.I Fread -reads, into a block beginning at -.I ptr, -.I nitems -of data of the type of -.I *ptr -from the named input -.IR stream . -It returns the number of items actually read. -.PP -.I Fwrite -appends at most -.I nitems -of data of the type of -.I *ptr -beginning at -.I ptr -to the named output -.IR stream . -It returns the number of items actually written. -.SH "SEE ALSO" -read(2), write(2), -fopen(3), -getc(3), putc(3), -gets(3), puts(3), -printf(3), scanf(3) -.SH DIAGNOSTICS -.I Fread -and -.I fwrite -return -0 -upon end of file or error. //GO.SYSIN DD fread.3s echo frexp.3 sed 's/.//' >frexp.3 <<'//GO.SYSIN DD frexp.3' -.TH FREXP 3 -.SH NAME -frexp, ldexp, modf \- split into mantissa and exponent -.SH SYNOPSIS -.B double frexp(value, eptr) -.br -.B double value; -.br -.B int *eptr; -.PP -.B double ldexp(value, exp) -.br -.B double value; -.PP -.B double modf(value, iptr) -.br -.B double value, *iptr; -.SH DESCRIPTION -.I Frexp -returns the mantissa of a double -.I value -as a double quantity, -.I x, -of magnitude less than 1 -and stores an integer -.I n -such that -.I value -= -.IR x *2** n -indirectly through -.I eptr. -.PP -.I Ldexp -returns the quantity -.IR value *2** exp. -.PP -.I Modf -returns the positive fractional part of -.I value -and stores the integer part indirectly -through -.I iptr. //GO.SYSIN DD frexp.3 echo fseek.3s sed 's/.//' >fseek.3s <<'//GO.SYSIN DD fseek.3s' -.TH FSEEK 3S -.SH NAME -fseek, ftell, rewind \- reposition a stream -.SH SYNOPSIS -.B #include -.PP -.B fseek(stream, offset, ptrname) -.br -.SM -.B FILE -.B *stream; -.br -.B long offset; -.PP -.B long ftell(stream) -.br -.SM -.B FILE -.B *stream; -.PP -.B rewind(stream) -.SH DESCRIPTION -.I Fseek -sets the position of the next input or output -operation on the -.IR stream . -The new position is at the signed distance -.I offset -bytes -from the beginning, the current position, or the end of the file, -according as -.I ptrname -has the value 0, 1, or 2. -.PP -.I Fseek -undoes any effects of -.IR ungetc (3). -.PP -.I Ftell -returns the current value of the offset relative to the beginning -of the file associated with the named -.IR stream . -It is measured in bytes on UNIX; -on some other systems it is a magic cookie, -and the only foolproof way to obtain an -.I offset -for -.IR fseek . -.PP -.I Rewind(stream) -is equivalent to -.I "fseek(stream, 0L, 0)." -.SH "SEE ALSO" -lseek(2), -fopen(3) -.SH DIAGNOSTICS -.I Fseek -returns \-1 for improper seeks. //GO.SYSIN DD fseek.3s echo getc.3s sed 's/.//' >getc.3s <<'//GO.SYSIN DD getc.3s' -.TH GETC 3S -.SH NAME -getc, getchar, fgetc, getw \- get character or word from stream -.SH SYNOPSIS -.B #include -.PP -.B int getc(stream) -.br -.SM -.B FILE -.B *stream; -.PP -.B int getchar() -.PP -.B int fgetc(stream) -.br -.SM -.B FILE -.B *stream; -.PP -.B int getw(stream) -.br -.SM -.B FILE -.B *stream; -.SH DESCRIPTION -.I Getc -returns the next character from the named input -.IR stream . -.PP -.I Getchar() -is identical to -.IR getc(stdin) . -.PP -.I Fgetc -behaves like -.I getc, -but is a genuine function, not a macro; -it may be used to save object text. -.PP -.I Getw -returns the next -word from the named input -.IR stream . -It returns the constant -.SM -.B EOF -upon end of file or error, but since that is a good -integer value, -.I feof -and -.IR ferror (3) -should be used to check the success of -.IR getw . -.I Getw -assumes no special alignment in the file. -.SH "SEE ALSO" -fopen(3), putc(3), -gets(3), scanf(3), -fread(3), -ungetc(3) -.SH DIAGNOSTICS -These functions return the integer constant -.SM -.B EOF -at end of file or upon read error. -.PP -A stop with message, -`Reading bad file', means an attempt has been made to -read from a stream that has not been opened for -reading by -.IR fopen . -.SH BUGS -The end-of-file return from -.I getchar -is incompatible with that in UNIX editions 1-6. -.PP -Because it is implemented as a macro, -.I getc -treats a -.I stream -argument with side effects incorrectly. -In particular, -`getc(*f++);' -doesn't work sensibly. //GO.SYSIN DD getc.3s echo getenv.3 sed 's/.//' >getenv.3 <<'//GO.SYSIN DD getenv.3' -.TH GETENV 3 -.SH NAME -getenv \- value for environment name -.SH SYNOPSIS -.B char *getenv(name) -.br -.B char *name; -.SH DESCRIPTION -.I Getenv -.a -searches the environment list -(see -.IR environ (5)) -for a string of the form -.IB name = value -and returns -.I value -if such a string is present, otherwise 0 (NULL). -.SH SEE ALSO -environ(5), exec(2) //GO.SYSIN DD getenv.3 echo getgrent.3 sed 's/.//' >getgrent.3 <<'//GO.SYSIN DD getgrent.3' -.TH GETGRENT 3 -.SH NAME -getgrent, getgrgid, getgrnam, setgrent, endgrent \- get group file entry -.SH SYNOPSIS -.B #include -.PP -.B struct group *getgrent(); -.PP -.B struct group *getgrgid(gid) int gid; -.PP -.B struct group *getgrnam(name) char *name; -.PP -.B int setgrent(); -.PP -.B int endgrent(); -.SH DESCRIPTION -.I Getgrent, -.I getgrgid -and -.I getgrnam -each return pointers -to an object -with the following structure -containing the broken-out -fields of a line in the group file. -.RS -.PP -.nf -.so /usr/include/grp.h -.fi -.RE -.PP -The members of this structure are: -.TP -gr_name -The name of the group. -.br -.ns -.TP -gr_passwd -The encrypted password of the group. -.br -.ns -.TP -gr_gid -The numerical group-ID. -.br -.ns -.TP -gr_mem -Null-terminated vector -of pointers to the individual -member names. -.PP -.I Getgrent -simply reads the next -line while -.I getgrgid -and -.I getgrnam -search until a matching -.I gid -or -.I name -is found -(or until EOF is encountered). -Each routine picks up -where the others leave off -so successive calls may be used -to search the entire file. -.PP -A call to -.I setgrent -has the effect of rewinding -the group file -to allow -repeated searches. -.I Endgrent -may be called to -close the group file -when processing is complete. -.SH FILES -/etc/group -.SH "SEE ALSO" -getlogin(3), getpwent(3), group(5) -.SH DIAGNOSTICS -A null pointer -(0) is returned on EOF or error. -.SH BUGS -All information -is contained in a static area -so it must be copied if it is -to be saved. //GO.SYSIN DD getgrent.3 echo getlogin.3 sed 's/.//' >getlogin.3 <<'//GO.SYSIN DD getlogin.3' -.TH GETLOGIN 3 -.SH NAME -getlogin \- get login name -.SH SYNOPSIS -.B char *getlogin(); -.SH DESCRIPTION -.I Getlogin -returns a pointer to -the login name -as found in -.IR /etc/utmp . -It may be used -in conjunction -with -.I getpwnam -to locate the correct -password file entry -when the same userid -is shared by several -login names. -.PP -If -.I getlogin -is called within a process -that is not attached to a -typewriter, it returns NULL. -The correct procedure -for determining the login name -is to first call -.I getlogin -and if it fails, -to call -.IR getpwuid . -.SH FILES -/etc/utmp -.SH "SEE ALSO" -getpwent(3), getgrent(3), utmp(5) -.SH DIAGNOSTICS -Returns NULL (0) if name not found. -.SH BUGS -The return values point to static data -whose content is overwritten by each call. //GO.SYSIN DD getlogin.3 echo getpass.3 sed 's/.//' >getpass.3 <<'//GO.SYSIN DD getpass.3' -.TH GETPASS 3 -.SH NAME -getpass \- read a password -.SH SYNOPSIS -.B char *getpass(prompt) -.br -.B char *prompt; -.SH DESCRIPTION -.I Getpass -reads a password from the file -.IR /dev/tty , -or if that cannot be opened, from the standard input, -after prompting with the null-terminated string -.I prompt -and disabling echoing. -A pointer is returned to a null-terminated string -of at most 8 characters. -.SH FILES -/dev/tty -.SH "SEE ALSO" -crypt(3) -.SH BUGS -The return value points to static data -whose content is overwritten by each call. //GO.SYSIN DD getpass.3 echo getpw.3 sed 's/.//' >getpw.3 <<'//GO.SYSIN DD getpw.3' -.TH GETPW 3 deprecated -.SH NAME -getpw \- get name from UID -.SH SYNOPSIS -.B getpw(uid, buf) -.br -.B char *buf; -.SH DESCRIPTION -.I Getpw -searches the password file for -the (numerical) -.IR uid ", and fills in " "buf" -with the corresponding line; -it returns non-zero if -.IR uid "" -could not -be found. -The line is null-terminated. -.SH FILES -/etc/passwd -.SH "SEE ALSO" -getpwent(3), -passwd(5) -.SH DIAGNOSTICS -Non-zero -return on error. //GO.SYSIN DD getpw.3 echo getpwent.3 sed 's/.//' >getpwent.3 <<'//GO.SYSIN DD getpwent.3' -.TH GETPWENT 3 -.SH NAME -getpwent, getpwuid, getpwnam, setpwent, endpwent -\- get password file entry -.SH SYNOPSIS -.B #include -.PP -.B struct passwd *getpwent(); -.PP -.B struct passwd *getpwuid(uid) int uid; -.PP -.B struct passwd *getpwnam(name) char *name; -.PP -.B int setpwent(); -.PP -.B int endpwent(); -.SH DESCRIPTION -.I Getpwent, -.I getpwuid -and -.I getpwnam -each return a pointer to an object with the -following structure -containing the broken-out -fields of a line in the password file. -.RS -.PP -.nf -.so /usr/include/pwd.h -.ft R -.ad -.fi -.RE -.PP -The fields -.I pw_quota -and -.I pw_comment -are unused; the others have meanings described in -.IR passwd (5). -.PP -.I Getpwent -reads the next -line (opening the file if necessary); -.I setpwent -rewinds the file; -.I endpwent -closes it. -.PP -.I Getpwuid -and -.I getpwnam -search from the beginning until a matching -.I uid -or -.I name -is found -(or until EOF is encountered). -.SH FILES -/etc/passwd -.SH "SEE ALSO" -getlogin(3), getgrent(3), passwd(5) -.SH DIAGNOSTICS -Null pointer -(0) returned on EOF or error. -.SH BUGS -All information -is contained in a static area -so it must be copied if it is -to be saved. -.br //GO.SYSIN DD getpwent.3 echo gets.3s sed 's/.//' >gets.3s <<'//GO.SYSIN DD gets.3s' -.TH GETS 3S -.SH NAME -gets, fgets \- get a string from a stream -.SH SYNOPSIS -.B #include -.PP -.B char *gets(s) -.br -.B char *s; -.PP -.B char *fgets(s, n, stream) -.br -.B char *s; -.br -.SM -.B FILE -.B *stream; -.SH DESCRIPTION -.I Gets -reads a string into -.I s -from the standard input stream -.B stdin. -The string is terminated by a newline -character, which is replaced in -.I s -by a null character. -.I Gets -returns its argument. -.PP -.I Fgets -reads -.IR n \-1 -characters, or up to a newline -character, whichever comes first, -from the -.I stream -into the string -.IR s . -The last character read into -.I s -is followed by a null character. -.I Fgets -returns its first argument. -.SH "SEE ALSO" -puts(3), -getc(3), scanf(3), fread(3), -ferror(3) -.SH DIAGNOSTICS -.I Gets -and -.I fgets -return the constant pointer -.SM -.B NULL -upon end of file or error. -.SH BUGS -.I Gets -deletes a newline, -.I fgets -keeps it, -all in the name of backward compatibility. //GO.SYSIN DD gets.3s echo hypot.3m sed 's/.//' >hypot.3m <<'//GO.SYSIN DD hypot.3m' -.TH HYPOT 3M -.SH NAME -hypot, cabs \- euclidean distance -.SH SYNOPSIS -.B #include -.PP -.B double hypot(x, y) -.br -.B double x, y; -.PP -.B double cabs(z) -.br -.B struct { double x, y;} z; -.SH DESCRIPTION -.I Hypot -and -.I cabs -return -.PP -.IP "" 15n -sqrt(x*x + y*y), -.LP -taking precautions against unwarranted overflows. -.SH SEE ALSO -exp(3) for -.I sqrt //GO.SYSIN DD hypot.3m echo intro.3 sed 's/.//' >intro.3 <<'//GO.SYSIN DD intro.3' -.TH INTRO 3 -.SH NAME -intro \- introduction to library functions -.SH SYNOPSIS -.B #include -.PP -.B #include -.SH DESCRIPTION -This section describes functions that may be found -in various libraries, other than those functions -that directly invoke UNIX system primitives, -which are described in section 2. -Functions are divided into various libraries distinguished -by the section number at the top of the page: -.TP 6n -(3) -These functions, together with those of section 2 and those -marked (3S), constitute library -.I libc, -which is automatically loaded by the C compiler -.IR cc (1) -and the Fortran compiler -.IR f77 (1). -The link editor -.IR ld (1) -searches this library under the `\-lc' option. -Declarations for some of these functions may be obtained -from include files indicated on the appropriate pages. -.TP -(3M) -These functions constitute the math library, -.I libm. -They are automatically loaded as needed by the Fortran compiler -.IR f77 (1). -The link editor searches this library under the `\-lm' option. -Declarations for these functions may be obtained from -the include file . -.TP -(3S) -These functions constitute the -`standard I/O package', -see -.IR stdio (3). -These functions are in the library -.I libc -already mentioned. -Declarations for these functions may be obtained from -the include file . -.TP -(3X) -Various -specialized libraries have not been given distinctive -captions. -The files in which these libraries are found are named -on the appropriate pages. -.SH FILES -/lib/libc.a -.br -/lib/libm.a, /usr/lib/libm.a (one or the other) -.SH SEE ALSO -stdio(3), -nm(1), ld(1), cc(1), f77(1), intro(2) -.SH DIAGNOSTICS -Functions in the math library (3M) may return -conventional values when the function is undefined for the -given arguments or when the value is not representable. -In these cases the external variable -.I errno -(see -.IR intro (2)) -is set to the value EDOM -or ERANGE. -The values of EDOM and ERANGE are defined in -the include file -.I . -.SH ASSEMBLER -In assembly language these functions may be accessed -by simulating the C calling sequence. -For example, -.IR ecvt (3) -might be called this way: -.IP "" -.globl _ecvt -.nf -setd -mov $sign,\-(sp) -mov $decpt,\-(sp) -mov ndigit,\-(sp) -movf value,\-(sp) -jsr pc,_ecvt -add $14.,sp -.fi //GO.SYSIN DD intro.3 echo j0.3m sed 's/.//' >j0.3m <<'//GO.SYSIN DD j0.3m' -.TH J0 3M -.SH NAME -j0, j1, jn, y0, y1, yn \- bessel functions -.SH SYNOPSIS -.B #include -.PP -.B double j0(x) -.br -.B double x; -.PP -.B double j1(x) -.br -.B double x; -.PP -.B double jn(n, x); -.br -.B double x; -.PP -.B double y0(x) -.br -.B double x; -.PP -.B double y1(x) -.br -.B double x; -.PP -.B double yn(n, x) -.br -.B double x; -.SH DESCRIPTION -These functions calculate Bessel functions of the first -and second kinds for real arguments and integer orders. -.SH DIAGNOSTICS -Negative arguments cause -.I y0, y1, -and -.I yn -to return a huge negative value -and set -.I errno -to EDOM. //GO.SYSIN DD j0.3m echo l3tol.3 sed 's/.//' >l3tol.3 <<'//GO.SYSIN DD l3tol.3' -.TH L3TOL 3 -.SH NAME -l3tol, ltol3 \- convert between 3-byte integers and long integers -.SH SYNOPSIS -.B l3tol(lp, cp, n) -.br -.B long *lp; -.br -.B char *cp; -.PP -.B ltol3(cp, lp, n) -.br -.B char *cp; -.br -.B long *lp; -.SH DESCRIPTION -.I L3tol -converts a list of -.I n -three-byte integers packed into a character string -pointed to by -.I cp -into a list of long integers pointed to by -.IR lp . -.PP -.I Ltol3 -performs the reverse conversion from long integers -.RI ( lp ) -to three-byte integers -.RI ( cp ). -.PP -These functions are useful for file-system maintenance; -disk addresses are three bytes long. -.SH SEE ALSO -filsys(5) //GO.SYSIN DD l3tol.3 echo malloc.3 sed 's/.//' >malloc.3 <<'//GO.SYSIN DD malloc.3' -.TH MALLOC 3 -.SH NAME -malloc, free, realloc, calloc \- main memory allocator -.SH SYNOPSIS -.B char *malloc(size) -.br -.B unsigned size; -.PP -.B free(ptr) -.br -.B char *ptr; -.PP -.B char *realloc(ptr, size) -.br -.B char *ptr; -.br -.B unsigned size; -.PP -.B char *calloc(nelem, elsize) -.br -.B unsigned nelem, elsize; -.SH DESCRIPTION -.I Malloc -and -.I free -provide a simple general-purpose memory allocation package. -.I Malloc -returns a pointer to a block of at least -.I size -bytes beginning on a word boundary. -.PP -The argument to -.I free -is a pointer to a block previously allocated by -.IR malloc ; -this space is made available for further allocation, -but its contents are left undisturbed. -.PP -Needless to say, grave disorder will result if the space -assigned by -.I malloc -is overrun or if some random number is handed to -.IR free . -.PP -.I Malloc -allocates the first big enough contiguous reach of -free space -found in a circular search from the last -block allocated or freed, -coalescing adjacent free blocks as it searches. -It calls -.I sbrk -(see -.IR break (2)) -to get more memory from the system when there is no -suitable space already free. -.PP -.I Realloc -changes the size of the block pointed to by -.I ptr -to -.I size -bytes and returns a pointer to the (possibly moved) -block. -The contents will be unchanged up to the -lesser of the new and old sizes. -.PP -.I Realloc -also works if -.I ptr -points to a block freed since the last call of -.I malloc, realloc -or -.IR calloc ; -thus sequences of -.I free, malloc -and -.I realloc -can exploit the search strategy of -.I malloc -to do storage compaction. -.PP -.I Calloc -allocates space for -an array of -.I nelem -elements of size -.I elsize. -The space is initialized to zeros. -.PP -Each of the allocation routines returns a pointer -to space suitably aligned (after possible pointer coercion) -for storage of any type of object. -.SH DIAGNOSTICS -.I Malloc, realloc -and -.I calloc -return a null pointer (0) if there is no available memory -or if the arena has been detectably corrupted by storing outside the bounds -of a block. -.I Malloc -may be recompiled to check the arena very stringently -on every transaction; -see the source code. -.SH BUGS -When -.I realloc -returns 0, -the block -pointed to by -.I ptr -may be destroyed. //GO.SYSIN DD malloc.3 echo mktemp.3 sed 's/.//' >mktemp.3 <<'//GO.SYSIN DD mktemp.3' -.TH MKTEMP 3 -.SH NAME -mktemp \- make a unique file name -.SH SYNOPSIS -.B char *mktemp(template) -.br -.B char *template; -.SH DESCRIPTION -.I Mktemp -replaces -.I template -by a unique file name, and returns the -address of the template. -The template should look like a file name with six trailing -X's, which will be replaced with the -current process id and a unique letter. -.SH "SEE ALSO" -getpid(2) //GO.SYSIN DD mktemp.3 echo monitor.3 sed 's/.//' >monitor.3 <<'//GO.SYSIN DD monitor.3' -.TH MONITOR 3 -.SH NAME -monitor \- prepare execution profile -.SH SYNOPSIS -.B monitor(lowpc, highpc, buffer, bufsize, nfunc) -.br -.B -int (*lowpc)( ), (*highpc)( ); -.br -.B short buffer[ ]; -.SH DESCRIPTION -An executable program created by -`cc \-p' automatically includes calls for -.I monitor -with default parameters; -.I monitor -needn't be called explicitly -except to gain fine control over profiling. -.PP -.I Monitor -is an interface to -.IR profil (2). -.I Lowpc -and -.I highpc -are the addresses of two functions; -.I buffer -is the address of a (user supplied) -array of -.I bufsize -short integers. -.I Monitor -arranges to record a histogram of -periodically sampled values of the program counter, -and of counts of calls -of certain functions, in the buffer. -The lowest address sampled -is that of -.I lowpc -and the highest is -just below -.IR highpc . -At most -.I nfunc -call counts can be kept; only calls of functions -compiled with the profiling option -.B \-p -of -.IR cc (1) -are recorded. -For the results to be significant, -especially where there are small, heavily -used routines, -it is suggested that the buffer be no more -than a few times smaller than the range -of locations sampled. -.PP -To profile the entire program, -it is sufficient to use -.PP - extern etext(); -.br - ... -.br - monitor((int)2, etext, buf, bufsize, nfunc); -.PP -.I Etext -lies just above all the -program text, see -.IR end (3). -.PP -To stop execution monitoring and write the results -on the file -.I mon.out, -use -.PP - monitor(0); -.LP -then -.IR prof (1) -can be used -to examine the results. -.SH FILES -mon.out -.SH "SEE ALSO" -prof(1), profil(2), cc(1) //GO.SYSIN DD monitor.3 echo mp.3x sed 's/.//' >mp.3x <<'//GO.SYSIN DD mp.3x' -.TH MP 3X -.SH NAME -itom, madd, msub, mult, mdiv, min, mout, -pow, gcd, rpow \- multiple precision integer arithmetic -.SH SYNOPSIS -.nf -.B "typedef struct { int len; short *val; } mint;" -.PP -.PP -.B madd(a, b, c) -.B msub(a, b, c) -.B mult(a, b, c) -.B mdiv(a, b, q, r) -.B min(a) -.B mout(a) -.B pow(a, b, m, c) -.B gcd(a, b, c) -.B rpow(a, b, c) -.B msqrt(a, b, r) -.B mint *a, *b, *c, *m, "*q, *r;" -.PP -.B -.B sdiv(a, n, q, r) -.B mint *a, *q; -.B short *r; -.PP -.B mint *itom(n) -.SH DESCRIPTION -These routines perform arithmetic on integers of -arbitrary length. -The integers are stored using the defined type -.I mint. -Pointers to -a -.I mint -should be initialized using the function -.IR itom , -which sets the initial value to -.IR n . -After that space is managed automatically by the routines. -.PP -.IR madd , " msub" , " mult" , -assign to their third arguments the sum, difference, and -product, respectively, of their first two arguments. -.I mdiv -assigns the quotient and remainder, respectively, -to its third and fourth arguments. -.I sdiv -is like -.I mdiv -except that the divisor is an ordinary integer. -.I msqrt -produces the square root and remainder of its first argument. -.I rpow -calculates -.I a -raised to the power -.IR b , -while -.I pow -calculates this reduced modulo -.IR m . -.IR min " and" mout -do decimal input and output. -.PP -The functions are obtained with the -loader option -.IR -lmp . -.SH DIAGNOSTICS -Illegal operations and running out of memory -produce messages and core images. //GO.SYSIN DD mp.3x echo nlist.3 sed 's/.//' >nlist.3 <<'//GO.SYSIN DD nlist.3' -.TH NLIST 3 -.SH NAME -nlist \- get entries from name list -.SH SYNOPSIS -.B #include -.br -.B nlist(filename, nl) -.br -.B char *filename; -.DT -.nf -.ft 3 -struct nlist nl[ ]; -.fi -.SH DESCRIPTION -.I Nlist -examines the name list in -the given executable output file -and selectively extracts a -list of values. -The name list consists of -an array of structures containing names, -types and values. -The list is terminated with a null name. -Each name is looked up in the name list of -the file. -If the name is found, the type and value of the -name are inserted in the next two fields. -If the name is not found, both entries are set to 0. -See -.IR a.out (5) -for the structure declaration. -.PP -This subroutine is useful for -examining the system name list kept in -the file -.BR /unix . -In this way programs can obtain system addresses -that are up to date. -.SH "SEE ALSO" -a.out(5) -.SH DIAGNOSTICS -All -type entries are set to 0 if the file cannot be found -or if it is not a valid namelist. //GO.SYSIN DD nlist.3 echo perror.3 sed 's/.//' >perror.3 <<'//GO.SYSIN DD perror.3' -.TH PERROR 3 -.SH NAME -perror, sys_errlist, sys_nerr \- system error messages -.SH SYNOPSIS -.B perror(s) -.br -.B char *s; -.PP -.B int sys_nerr; -.br -.B char *sys_errlist[]; -.SH DESCRIPTION -.I Perror -produces a short error message -on the standard error file -describing the last error encountered during a call -to the system from a C program. -First the argument string -.I s -is printed, then a colon, then the message and a new-line. -Most usefully, the argument string is the name -of the program which incurred the error. -The error number is taken from the external variable -.I errno -(see -.IR intro (2)), -which is set when errors occur but not cleared when -non-erroneous calls are made. -.PP -To simplify variant formatting -of messages, the vector of message strings -.I sys_errlist -is provided; -.I errno -can be used as an index in this table to get the -message string without the newline. -.I Sys_nerr -is the number of messages provided for in the table; -it should be checked because new -error codes may be added to the system before -they are added to the table. -.SH "SEE ALSO" -intro(2) //GO.SYSIN DD perror.3 echo pkopen.3 sed 's/.//' >pkopen.3 <<'//GO.SYSIN DD pkopen.3' -.TH PKOPEN 3 deprecated -.SH NAME -pkopen, pkclose, pkread, pkwrite, pkfail \- packet driver simulator -.SH SYNOPSIS -.B char *pkopen(fd) -.PP -.B pkclose(ptr) -.br -.B char *ptr; -.PP -.B pkread(ptr, buffer, count) -.br -.B char *ptr, *buffer; -.PP -.B pkwrite(ptr, buffer, count) -.br -.B char *ptr, *buffer; -.PP -.B pkfail() -.SH DESCRIPTION -These routines are a user-level implementation of the -full-duplex -end-to-end communication protocol described in -.IR pk (4). -If -.I fd -is a file descriptor open for reading and writing, -.I pkopen -carries out the initial synchronization and returns an identifying -pointer. -The pointer -is used as the first parameter to -.I pkread, -.I pkwrite, -and -.I pkclose. -.PP -.I Pkread, pkwrite -and -.I pkclose -behave analogously to -.I read, write -and -.IR close (2). -However, a write of zero bytes -is meaningful and will produce a corresponding -read of zero bytes. -.SH SEE ALSO -pk(4), pkon(2) -.SH DIAGNOSTICS -.I Pkfail -is called upon persistent breakdown of communication. -.I Pkfail -must be supplied by the user. -.PP -.I Pkopen -returns a null (0) pointer if packet protocol -can not be established. -.PP -.I Pkread -returns \-1 on end of file, -0 in correspondence with a 0-length write. -.SH BUGS -This simulation of -.IR pk (4) -leaves something to be desired -in needing special read and write routines, and in -not being inheritable across calls of -.IR exec (2). -Its prime use is on systems that lack -.I pk. -.br -These functions use -.IR alarm (2); -simultaneous use of -.I alarm -for other puposes may cause trouble. //GO.SYSIN DD pkopen.3 echo plot.3x sed 's/.//' >plot.3x <<'//GO.SYSIN DD plot.3x' -.TH PLOT 3X -.SH NAME -plot: openpl et al. \- graphics interface -.SH SYNOPSIS -.B openpl( ) -.PP -.B erase( ) -.PP -.B label(s) -.B char s[ ]; -.PP -.B line(x1, y1, x2, y2) -.PP -.B circle(x, y, r) -.PP -.B arc(x, y, x0, y0, x1, y1) -.PP -.B move(x, y) -.PP -.B cont(x, y) -.PP -.B point(x, y) -.PP -.B linemod(s) -.B char s[ ]; -.PP -.B space(x0, y0, x1, y1) -.PP -.B closepl( ) -.fi -.PP -.ft R -.SH DESCRIPTION -These subroutines -generate -graphic output in a relatively -device-independent manner. -See -.IR plot (5) -for a description -of their effect. -.I Openpl -must be used before any of the others to open the -device for writing. -.I Closepl -flushes the output. -.PP -String arguments to -.I label -and -.I linemod -are null-terminated, and do not contain newlines. -.PP -Various flavors of these functions exist for different -output devices. -They are obtained by the following -.IR ld (1) -options: -.TP 8n -.B \-lplot -device-independent -graphics stream on standard -output for -.IR plot (1) -filters -.br -.ns -.TP -.B \-l300 -GSI 300 terminal -.br -.ns -.TP -.B \-l300s -GSI 300S terminal -.br -.ns -.TP -.B \-l450 -DASI 450 terminal -.br -.ns -.TP -.B \-l4014 -Tektronix 4014 terminal -.SH "SEE ALSO" -plot(5), plot(1), graph(1) //GO.SYSIN DD plot.3x echo popen.3s sed 's/.//' >popen.3s <<'//GO.SYSIN DD popen.3s' -.TH POPEN 3S -.SH NAME -popen, pclose \- initiate I/O to/from a process -.SH SYNOPSIS -.B #include -.PP -.SM -.B FILE -.B *popen(command, type) -.br -.B char *command, *type; -.PP -.B pclose(stream) -.br -.SM -.B FILE -.B *stream; -.SH DESCRIPTION -The arguments to -.I popen -are pointers to null-terminated strings -containing respectively a shell command line and an I/O -mode, either "r" for reading or "w" for -writing. -It creates a pipe between -the calling process and -the command to be executed. -The value returned -is a stream pointer that -can be used (as appropriate) to write to the standard input -of the command or read from its standard output. -.PP -A stream opened by -.I popen -should be closed by -.I pclose, -which waits for the associated process to terminate -and returns the exit status of the command. -.PP -Because open files are shared, a type "r" command -may be used as an input filter, -and a type "w" as an output filter. -.SH "SEE ALSO" -pipe(2), -fopen(3), -fclose(3), -system(3), -wait(2) -.SH DIAGNOSTICS -.I Popen -returns a null pointer -if files or processes cannot be created, or the Shell -cannot be accessed. -.PP -.I Pclose -returns \-1 if -.I stream -is not associated with a `popened' command. -.SH BUGS -Buffered reading before opening an input filter -may leave the standard input of that filter mispositioned. -Similar problems with an output filter may be -forestalled by careful buffer flushing, e.g. with -.I fflush, -see -.IR fclose (3). //GO.SYSIN DD popen.3s echo printf.3s sed 's/.//' >printf.3s <<'//GO.SYSIN DD printf.3s' -.TH PRINTF 3S -.SH NAME -printf, fprintf, sprintf \- formatted output conversion -.SH SYNOPSIS -.B #include -.PP -.B printf(format -.RB [ , -arg ] ... -.B ) -.br -.B char *format; -.PP -.B fprintf(stream, format -.RB [ , -arg ] ... -.B ) -.br -.SM -.B FILE -.B *stream; -.br -.B char *format; -.PP -.B sprintf(s, format -.RB [ , -arg ] ... -.B ) -.br -.B char *s, format; -.SH DESCRIPTION -.I Printf -places output on the standard output stream -.IR stdout . -.I Fprintf -places output on the named output -.IR stream . -.I Sprintf -places `output' in the string -.I s, -followed by the character `\\0'. -.PP -Each of these functions -converts, formats, and prints its arguments after the first -under control of the first argument. -The first argument is a character string -which contains -two types of objects: -plain characters, which are simply copied to the -output stream, -and conversion specifications, -each of which causes conversion and printing -of the next successive -.I arg -.IR printf . -.PP -Each conversion specification is introduced by -the character -.BR % . -Following the -.BR % , -there may be -.TP -\- -an optional minus sign `\-' which specifies -.I "left adjustment" -of the converted value -in the -indicated field; -.TP -\- -an optional digit string specifying a -.I "field width;" -if the converted value has fewer characters -than the field width -it will be blank-padded on the left (or right, -if the left-adjustment indicator has been -given) to make up the field width; -if the field width begins with a zero, -zero-padding will be done instead of blank-padding; -.TP -\- -an optional period -.RB ` . ' -which serves to -separate the field width from the -next digit string; -.TP -\- -an optional digit string -specifying a -.I precision -which specifies -the number of digits to appear after the -decimal point, for e- and f-conversion, -or the maximum number of characters -to be printed from a string; -.TP -\- -the character -.B l -specifying that a following -.BR d , -.BR o , -.BR x , -or -.B u -corresponds to a long integer -.I arg. -(A capitalized conversion code accomplishes -the same thing.) -.TP -\- -a character which indicates the type of -conversion to be applied. -.PP -A field width or precision may be `*' instead of a digit string. -In this case an integer -.I arg -supplies -the field width or precision. -.PP -The conversion characters -and their meanings are -.TP -.B dox -The integer -.I arg -is converted to decimal, octal, or -hexadecimal notation respectively. -.TP -.B f -The float or double -.I arg -is converted to decimal notation -in the style `[\fB\-\fR]ddd.ddd' -where the number of d's after the decimal point -is equal to the precision specification -for the argument. -If the precision -is missing, -6 digits are given; -if the precision is explicitly 0, no digits and -no decimal point are printed. -.TP -.B e -The float or double -.I arg -is converted in the style -`[\fB\-\fR]d\fB.\fRddd\fBe\fR\(+-dd' -where there is one digit before the decimal point and -the number after is equal to the -precision specification for the argument; -when the precision is missing, -6 digits are produced. -.TP -.B g -The float or double -.I arg -is printed in style -.BR d , -in style -.BR f , -or in -style -.BR e , -whichever gives full precision in minimum space. -.TP -.B c -The character -.I arg -is printed. -Null characters are ignored. -.TP -.B s -.I Arg -is taken to be a string (character pointer) -and characters from the string are printed until -a null character or until -the number of characters indicated by the precision -specification is reached; -however if the precision is 0 or missing -all characters up to a null are printed. -.TP -.B u -The unsigned integer -.I arg -is converted to decimal -and printed (the result will be in the -range 0 to 65535). -.TP -.B % -Print a `%'; no argument is converted. -.PP -In no case does a non-existent or small field width -cause truncation of a field; -padding takes place only if the specified field -width exceeds the actual width. -Characters generated by -.I printf -are printed by -.IR putc (3). -.PP -.B Examples -.br -To print a date and time in the form `Sunday, July 3, 10:02', -where -.I weekday -and -.I month -are pointers to null-terminated strings: -.RS -.HP -.nh -printf("%s, %s %d, %02d:%02d", weekday, month, day, hour, min); -.RE -.hy -.PP -To print -.if n pi -.if t \(*p -to 5 decimals: -.IP -printf("pi = %.5f", 4*atan(1.0)); -.SH "SEE ALSO" -putc(3), -scanf(3), -ecvt(3) -.SH BUGS -Very wide fields (>128 characters) fail. //GO.SYSIN DD printf.3s echo putc.3s sed 's/.//' >putc.3s <<'//GO.SYSIN DD putc.3s' -.TH PUTC 3S -.SH NAME -putc, putchar, fputc, putw \- put character or word on a stream -.SH SYNOPSIS -.B #include -.PP -.B int putc(c, stream) -.br -.B char c; -.br -.SM -.B FILE -.B *stream; -.PP -.B putchar(c) -.PP -.B fputc(c, stream) -.br -.SM -.B FILE -.B *stream; -.PP -.B putw(w, stream) -.br -.SM -.B FILE -.B *stream; -.SH DESCRIPTION -.I Putc -appends the character -.I c -to the named output -.IR stream . -It returns the character written. -.PP -.I Putchar(c) -is defined as -.I "putc(c, stdout)." -.PP -.I Fputc -behaves like -.I putc, -but is a genuine function rather than a macro. -It may be used to save on object text. -.PP -.I Putw -appends word -(i.e. -.BR int ) -.I w -to the output -.IR stream . -It returns the word written. -.I Putw -neither assumes nor causes special alignment in the file. -.PP -The standard stream -.I stdout -is normally buffered if and only if the -output does not refer to a terminal; -this default may be changed by -.IR setbuf (3). -The standard stream -.I stderr -is by default unbuffered unconditionally, -but use of -.I freopen -(see -.IR fopen (3)) -will cause it to become buffered; -.IR setbuf , -again, will set the state to whatever is desired. -When an output stream is unbuffered information appears on the -destination file or terminal as soon as written; -when it is buffered many characters are saved up and written as a block. -.I Fflush -(see -.IR fclose (3)) -may be used to force the block out early. -.SH "SEE ALSO" -fopen(3), fclose(3), getc(3), -puts(3), printf(3), -fread(3) -.SH DIAGNOSTICS -These functions return the constant -.SM -.B EOF -upon error. -Since this is a good integer, -.IR ferror (3) -should be used to detect -.I putw -errors. -.SH BUGS -Because it is implemented as a macro, -.I putc -treats a -.I stream -argument with side effects improperly. -In particular -`putc(c, *f++);' -doesn't work sensibly. //GO.SYSIN DD putc.3s echo puts.3s sed 's/.//' >puts.3s <<'//GO.SYSIN DD puts.3s' -.TH PUTS 3S -.SH NAME -puts, fputs \- put a string on a stream -.SH SYNOPSIS -.B #include -.PP -.B puts(s) -.br -.B char *s; -.PP -.B fputs(s, stream) -.br -.B char *s; -.br -.SM -.B FILE -.B *stream; -.SH DESCRIPTION -.I Puts -copies the null-terminated string -.I s -to the standard output stream -.I stdout -and appends a -newline character. -.PP -.I Fputs -copies the null-terminated string -.I s -to the named output -.IR stream . -.PP -Neither routine copies the terminal null character. -.SH "SEE ALSO" -fopen(3), gets(3), -putc(3), printf(3), -ferror(3) -.br -fread(3) for -.I fwrite -.SH BUGS -.I Puts -appends a newline, -.I fputs -does not, all in the name of backward compatibility. //GO.SYSIN DD puts.3s echo qsort.3 sed 's/.//' >qsort.3 <<'//GO.SYSIN DD qsort.3' -.TH QSORT 3 -.SH NAME -qsort \- quicker sort -.SH SYNOPSIS -.B qsort(base, nel, width, compar) -.br -.B char *base; -.br -.B int (*compar)( ); -.SH DESCRIPTION -.I Qsort -is an implementation -of the quicker-sort algorithm. -The first argument is a pointer to the base of the data; -the second is the number of elements; -the third is the width of an element -in bytes; -the last is the name of the comparison routine -to be called with two arguments which are pointers -to the elements being compared. -The routine must return -an integer less than, equal to, or greater than 0 -according as the first argument is to be considered -less than, equal to, or greater than the second. -.SH "SEE ALSO" -sort(1) //GO.SYSIN DD qsort.3 echo rand.3 sed 's/.//' >rand.3 <<'//GO.SYSIN DD rand.3' -.TH RAND 3 -.SH NAME -rand, srand \- random number generator -.SH SYNOPSIS -.B srand(seed) -.br -.B int seed; -.PP -.B rand( ) -.SH DESCRIPTION -.I Rand -uses a multiplicative congruential -random number generator -with period 2\u\s732\s0\d -to return successive pseudo-random -numbers in the range from 0 to 2\u\s715\s10\d\-1. -.PP -The generator is reinitialized by calling -.I srand -with 1 as argument. -It can be set to a random starting point by calling -.I srand -with whatever you like as argument. //GO.SYSIN DD rand.3 echo scanf.3s sed 's/.//' >scanf.3s <<'//GO.SYSIN DD scanf.3s' -.TH SCANF 3S -.SH NAME -scanf, fscanf, sscanf \- formatted input conversion -.SH SYNOPSIS -.B #include -.PP -.B scanf(format -[ , pointer ] . . . -.B ) -.br -.B char *format; -.PP -.B fscanf(stream, format -[ , pointer ] . . . -.B ) -.br -.SM -.B FILE -.B *stream; -.br -.B char *format; -.PP -.B sscanf(s, format -[ , pointer ] . . . -.B ) -.br -.B char *s, *format; -.SH DESCRIPTION -.I Scanf -reads from the standard input stream -.IR stdin . -.I Fscanf -reads from the named input -.IR stream . -.I Sscanf -reads from the character string -.IR s . -Each function reads characters, interprets -them according to a format, and stores the results in its arguments. -Each expects as arguments -a control string -.I format, -described below, -and a set of -.I pointer -arguments -indicating where the converted input should be stored. -.PP -The -control string -usually contains -conversion specifications, which are used to direct interpretation -of input sequences. -The control string may contain: -.TP 4 -1. -Blanks, tabs or newlines, -which match optional white space in the input. -.TP 4 -2. -An ordinary character (not %) which must match -the next character of the input stream. -.TP 4 -3. -Conversion specifications, consisting of the -character -.BR % , -an optional assignment suppressing character -.BR * , -an optional numerical maximum field width, and a conversion -character. -.PP -A conversion specification directs the conversion of the -next input field; the result -is placed in the variable pointed to by the corresponding argument, -unless assignment suppression was -indicated by -.BR * . -An input field is defined as a string of non-space characters; -it extends to the next inappropriate character or until the field -width, if specified, is exhausted. -.PP -The conversion character indicates the interpretation of the -input field; the corresponding pointer argument must -usually be of a restricted type. -The following conversion characters are legal: -.TP 4 -.B % -a single `%' is expected -in the input at this point; -no assignment is done. -.TP 4 -.B d -a decimal integer is expected; -the corresponding argument should be an integer pointer. -.TP 4 -.B o -an octal integer is expected; -the corresponding argument should be a integer pointer. -.TP 4 -.B x -a hexadecimal integer is expected; -the corresponding argument should be an integer pointer. -.ti -0.2i -.TP 4 -.B s -a character string is expected; -the corresponding argument should be a character pointer -pointing to an array of characters large enough to accept the -string and a terminating `\e0', which will be added. -The input field is terminated by a space character -or a newline. -.TP 4 -.B c -a character is expected; the -corresponding argument should be a character pointer. -The normal skip over space characters is suppressed -in this case; -to read the next non-space character, try -`%1s'. -If a field width is given, the corresponding argument -should refer to a character array, and the -indicated number of characters is read. -.TP 4 -\z\fBe\v'1'f\v'-1'\fR -a -floating point number is expected; -the next field is converted accordingly and stored through the -corresponding argument, which should be a pointer to a -.IR float . -The input format for -floating point numbers is -an optionally signed -string of digits -possibly containing a decimal point, followed by an optional -exponent field consisting of an E or e followed by an optionally signed integer. -.TP 4 -.B [ -indicates a string not to be delimited by space characters. -The left bracket is followed by a set of characters and a right -bracket; the characters between the brackets define a set -of characters making up the string. -If the first character -is not circumflex (\|^\|), the input field -is all characters until the first character not in the set between -the brackets; if the first character -after the left bracket is ^, the input field is all characters -until the first character which is in the remaining set of characters -between the brackets. -The corresponding argument must point to a character array. -.PP -The conversion characters -.BR d , -.B o -and -.B x -may be capitalized or preceeded by -.B l -to indicate that a pointer to -.B long -rather than to -.B int -is in the argument list. -Similarly, the conversion characters -.B e -or -.B f -may be capitalized or -preceded by -.B l -to indicate a pointer to -.B double -rather than to -.BR float . -The conversion characters -.BR d , -.B o -and -.B x -may be preceeded by -.B h -to indicate a pointer to -.B short -rather than to -.BR int . -.PP -The -.I scanf -functions return the number of successfully matched and assigned input -items. -This can be used to decide how many input items were found. -The constant -.SM -.B EOF -is returned upon end of input; note that this is different -from 0, which means that no conversion was done; -if conversion was intended, it was frustrated by an -inappropriate character in the input. -.PP -For example, the call -.IP "" 10 -int i; float x; char name[50]; -.br -scanf( "%d%f%s", &i, &x, name); -.PP -with the input line -.IP -25 54.32E\(mi1 thompson -.PP -will assign to -.I i -the value -25, -.I x -the value 5.432, and -.I name -will contain -.IR `thompson\e0' . -Or, -.IP -int i; float x; char name[50]; -.br -scanf("%2d%f%*d%[1234567890]", &i, &x, name); -.PP -with input -.IP -56789 0123 56a72 -.PP -will assign 56 to -.I i, -789.0 to -.I x, -skip `0123', -and place the string `56\e0' in -.IR name . -The next call to -.I getchar -will return `a'. -.SH "SEE ALSO" -atof(3), -getc(3), printf(3) -.SH DIAGNOSTICS -The -.I scanf -functions return -.SM -.B EOF -on end of input, -and a short count for missing or illegal data items. -.SH BUGS -The success of literal matches and suppressed -assignments is not directly -determinable. //GO.SYSIN DD scanf.3s echo setbuf.3s sed 's/.//' >setbuf.3s <<'//GO.SYSIN DD setbuf.3s' -.TH SETBUF 3S -.SH NAME -setbuf \- assign buffering to a stream -.SH SYNOPSIS -.B #include -.PP -.B setbuf(stream, buf) -.br -.SM -.B FILE -.B *stream; -.br -.B char *buf; -.SH DESCRIPTION -.I Setbuf -is used after a stream has been opened but before it -is read or written. -It causes the character array -.I buf -to be used instead of an automatically allocated buffer. -If -.I buf -is the constant pointer -.SM -.B NULL, -input/output will be completely unbuffered. -.PP -A manifest constant -.SM -.B BUFSIZ -tells how big an array is needed: -.PP -.in +10 -char buf[BUFSIZ]; -.PP -A buffer is normally obtained from -.IR malloc (3) -upon the first -.I getc -or -.IR putc (3) -on the file, -except that output streams directed to terminals, -and the standard error stream -.I stderr -are normally not buffered. -.SH "SEE ALSO" -fopen(3), getc(3), putc(3), malloc(3) //GO.SYSIN DD setbuf.3s echo setjmp.3 sed 's/.//' >setjmp.3 <<'//GO.SYSIN DD setjmp.3' -.TH SETJMP 3 -.SH NAME -setjmp, longjmp \- non-local goto -.SH SYNOPSIS -.B #include -.PP -.B setjmp(env) -.br -.B jmp_buf env; -.PP -.B longjmp(env, val) -.br -.B jmp_buf env; -.SH DESCRIPTION -These routines are useful for dealing with errors -and interrupts encountered in -a low-level subroutine of a program. -.PP -.I Setjmp -saves its stack environment in -.I env -for later use by -.I longjmp. -It returns value 0. -.PP -.I Longjmp -restores the environment saved by the last call of -.IR setjmp . -It then returns in such a way that execution -continues as if the call of -.I setjmp -had just returned the value -.I val -to the function that invoked -.I setjmp, -which must not itself have returned in the interim. -All accessible data have values as of the time -.I longjmp -was called. -.SH "SEE ALSO" -signal(2) //GO.SYSIN DD setjmp.3 echo sin.3m sed 's/.//' >sin.3m <<'//GO.SYSIN DD sin.3m' -.TH SIN 3M -.SH NAME -sin, cos, tan, asin, acos, atan, atan2 \- trigonometric functions -.SH SYNOPSIS -.B #include -.PP -.B double sin(x) -.br -.B double x; -.PP -.B double cos(x) -.br -.B double x; -.PP -.B double asin(x) -.br -.B double x; -.PP -.B double acos(x) -.br -.B double x; -.PP -.B double atan(x) -.br -.B double x; -.PP -.B double atan2(x, y) -.br -.B double x, y; -.SH DESCRIPTION -.I Sin, cos -and -.I tan -return trigonometric functions of radian arguments. -The magnitude of the argument should be checked -by the caller to make sure the result is meaningful. -.PP -.I Asin -returns the arc sin in the range \-\(*p/2 to \(*p/2. -.PP -.I Acos -returns the arc cosine in the range -0 to \(*p. -.PP -.I Atan -returns the arc tangent of -.I x -in the range \-\(*p/2 to \(*p/2. -.PP -.I Atan2 -returns the arc tangent of -.I x/y -in the range \-\(*p to \(*p. -.SH DIAGNOSTICS -Arguments of magnitude greater than 1 -cause -.I asin -and -.I acos -to return value 0; -.I errno -is set to EDOM. -The value of -.I tan -at its singular points is a huge number, and -.I errno -is set to ERANGE. -.SH BUGS -The value of -.I tan -for arguments greater than about 2**31 is garbage. //GO.SYSIN DD sin.3m echo sinh.3m sed 's/.//' >sinh.3m <<'//GO.SYSIN DD sinh.3m' -.TH SINH 3M -.SH NAME -sinh, cosh, tanh \- hyperbolic functions -.SH SYNOPSIS -.B #include -.PP -.B double sinh(x) -.br -.B double x; -.PP -.B double cosh(x) -.br -.B double x; -.PP -.B double tanh(x) -.br -.B double x; -.SH DESCRIPTION -These functions compute the designated hyperbolic functions -for real arguments. -.SH DIAGNOSTICS -.I Sinh -and -.I cosh -return a huge value of appropriate sign -when the correct value would overflow. //GO.SYSIN DD sinh.3m echo sleep.3 sed 's/.//' >sleep.3 <<'//GO.SYSIN DD sleep.3' -.TH SLEEP 3 -.SH NAME -sleep \- suspend execution for interval -.SH SYNOPSIS -.B sleep(seconds) -.br -.B unsigned seconds; -.SH DESCRIPTION -The current process is suspended from execution for the number -of seconds specified by the argument. -The actual suspension time may be up to 1 second less than -that requested, because scheduled wakeups occur at fixed 1-second intervals, -and an arbitrary amount longer because of other activity -in the system. -.PP -The routine is implemented by setting an alarm clock signal -and pausing until it occurs. -The previous state of this signal is saved and restored. -If the sleep time exceeds the time to the alarm signal, -the process sleeps only until the signal would have occurred, and the -signal is sent 1 second later. -.SH "SEE ALSO" -alarm(2), pause(2) //GO.SYSIN DD sleep.3 echo stdio.3s sed 's/.//' >stdio.3s <<'//GO.SYSIN DD stdio.3s' -.TH STDIO 3S -.SH NAME -stdio \- standard buffered input/output package -.SH SYNOPSIS -.B #include -.PP -.SM -.B FILE -.B *stdin; -.br -.SM -.B FILE -.B *stdout; -.br -.SM -.B FILE -.B *stderr; -.SH DESCRIPTION -The functions described in Sections 3S constitute an efficient -user-level buffering scheme. -The in-line macros -.I getc -and -.IR putc (3) -handle characters quickly. -The higher level routines -.I "gets, fgets, scanf, fscanf, fread," -.I "puts, fputs, printf, fprintf, fwrite" -all use -.I getc -and -.I putc; -they can be freely intermixed. -.PP -A file with associated buffering is called a -.I stream, -and is declared to be a pointer to a defined type -.SM -.B FILE. -.IR Fopen (3) -creates certain descriptive data for a stream -and returns a pointer to designate the stream in all -further transactions. -There are three normally open streams with constant -pointers declared in -the include file and associated with the standard open files: -.TP 10n -.BR stdin -standard input file -.br -.ns -.TP -.B stdout -standard output file -.br -.ns -.TP -.BR stderr -standard error file -.PP -A constant `pointer' -.SM -.B NULL -(0) -designates no stream at all. -.PP -An integer constant -.SM -.B EOF -(\-1) is returned -upon end of file or error by integer functions that -deal with streams. -.PP -Any routine that uses the standard input/output package -must include the header file of pertinent -macro definitions. -The functions and constants mentioned in sections labeled 3S -are declared in the include file -and need no further declaration. -The constants, and the following `functions' are -implemented as macros; redeclaration of these names -is perilous: -.I getc, -.I getchar, -.I putc, -.I putchar, -.I feof, -.I ferror, -.IR fileno . -.SH "SEE ALSO" -open(2), close(2), read(2), write(2) -.SH DIAGNOSTICS -The value -.SM -.B EOF -is returned uniformly to indicate that a -.SM -.B FILE -pointer has not been initialized with -.I fopen, -input (output) has been attempted on an output (input) stream, -or a -.SM -.B FILE -pointer designates corrupt or otherwise unintelligible -.SM -.B FILE -data. //GO.SYSIN DD stdio.3s echo string.3 sed 's/.//' >string.3 <<'//GO.SYSIN DD string.3' -.TH STRING 3 -.SH NAME -strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, index, rindex \- string operations -.SH SYNOPSIS -.B char *strcat(s1, s2) -.br -.B char *s1, *s2; -.PP -.B char *strncat(s1, s2, n) -.br -.B char *s1, *s2; -.PP -.B strcmp(s1, s2) -.br -.B char *s1, *s2; -.PP -.B strncmp(s1, s2, n) -.br -.B char *s1, *s2; -.PP -.B char *strcpy(s1, s2) -.br -.B char *s1, *s2; -.PP -.B char *strncpy(s1, s2, n) -.br -.B char *s1, *s2; -.PP -.B strlen(s) -.br -.B char *s; -.PP -.B char *index(s, c) -.br -.B char *s, c; -.PP -.B char *rindex(s, c) -.br -.B char *s; -.SH DESCRIPTION -These functions operate on null-terminated strings. -They do not check for overflow of any receiving string. -.PP -.I Strcat -appends a copy of string -.I s2 -to the end of string -.IR s1 . -.I Strncat -copies at most -.I n -characters. -Both return a pointer to the null-terminated result. -.PP -.I Strcmp -compares its arguments and returns an integer -greater than, equal to, or less than 0, -according as -.I s1 -is lexicographically greater than, equal to, or -less than -.IR s2 . -.I Strncmp -makes the same comparison but looks at at most -.I n -characters. -.PP -.I Strcpy -copies string -.I s2 -to -.I s1, -stopping after the null character has been moved. -.I Strncpy -copies exactly -.I n -characters, -truncating or null-padding -.I s2; -the target may not be null-terminated if the length -of -.I s2 -is -.I n -or more. -Both return -.IR s1 . -.PP -.I Strlen -returns the number of non-null characters in -.IR s . -.PP -.I Index -.RI ( rindex ) -returns a pointer to the first (last) -occurrence of character -.I c -in string -.I s, -or zero if -.I c -does not occur in the string. -.SH BUGS -.I Strcmp -uses native character comparison, which is signed -on PDP11's, unsigned on other machines. //GO.SYSIN DD string.3 echo swab.3 sed 's/.//' >swab.3 <<'//GO.SYSIN DD swab.3' -.TH SWAB 3 -.SH NAME -swab \- swap bytes -.SH SYNOPSIS -.B swab(from, to, nbytes) -.br -.B char *from, *to; -.SH DESCRIPTION -.I Swab -copies -.I nbytes -bytes pointed to by -.I from -to the position pointed to by -.I to, -exchanging adjacent even and odd bytes. -It is useful for carrying binary data between -PDP11's and other machines. -.I Nbytes -should be even. //GO.SYSIN DD swab.3 echo system.3 sed 's/.//' >system.3 <<'//GO.SYSIN DD system.3' -.TH SYSTEM 3 -.SH NAME -system \- issue a shell command -.SH SYNOPSIS -.B system(string) -.br -.B char *string; -.SH DESCRIPTION -.I System -causes the -.I string -to be given to -.IR sh (1) -as input as if the string had been typed as a command -at a terminal. -The current process waits until the shell has -completed, then returns the exit status of the shell. -.SH "SEE ALSO" -popen(3), -exec(2), wait(2) -.SH DIAGNOSTICS -Exit status 127 indicates the shell couldn't be executed. //GO.SYSIN DD system.3 echo ttyname.3 sed 's/.//' >ttyname.3 <<'//GO.SYSIN DD ttyname.3' -.TH TTYNAME 3 -.SH NAME -ttyname, isatty, ttyslot \- find name of a terminal -.SH SYNOPSIS -.B char *ttyname(fildes) -.PP -.B isatty(fildes) -.PP -.B ttyslot() -.SH DESCRIPTION -.I Ttyname -returns a pointer to the null-terminated path name -of the terminal device associated with file descriptor -.IR fildes . -.PP -.I Isatty -returns 1 if -.I fildes -is associated with a terminal device, 0 otherwise. -.PP -.I Ttyslot -returns the number of the entry in the -.IR ttys (5) -file for the control terminal of the -current process. -.SH FILES -/dev/* -.br -/etc/ttys -.SH SEE ALSO -ioctl(2), ttys(5) -.SH DIAGNOSTICS -.I Ttyname -returns a null pointer (0) if -.I fildes -does not describe a terminal device in directory `/dev'. -.PP -.I Ttyslot -returns 0 if `/etc/ttys' is inaccessible or if -it cannot determine the control terminal. -.SH BUGS -The return value points to static data -whose content is overwritten by each call. //GO.SYSIN DD ttyname.3 echo ungetc.3s sed 's/.//' >ungetc.3s <<'//GO.SYSIN DD ungetc.3s' -.TH UNGETC 3S -.SH NAME -ungetc \- push character back into input stream -.SH SYNOPSIS -.B #include -.PP -.B ungetc(c, stream) -.br -.SM -.B FILE -.B *stream; -.SH DESCRIPTION -.I Ungetc -pushes the character -.I c -back on an input stream. -That character will be returned by the next -.I getc -call on that stream. -.I Ungetc -returns -.IR c . -.PP -One character of pushback is guaranteed provided -something has been read from the stream and the stream is -actually buffered. -Attempts to push EOF are rejected. -.PP -.IR Fseek (3) -erases all memory of pushed back characters. -.SH "SEE ALSO" -getc(3), setbuf(3), fseek(3) -.SH DIAGNOSTICS -.I Ungetc -returns -.SM -.B EOF -if it can't push a character back. //GO.SYSIN DD ungetc.3s