LIB.TXT
资源名称:os_source.zip [点击查看]
上传用户:datang2001
上传日期:2007-02-01
资源大小:53269k
文件大小:979k
源码类别:
操作系统开发
开发平台:
C/C++
- 47652 if (--width)
- 47653 c = getc(stream);
- 47654 }
- 47655
- 47656 if (width && c == '0' && base == 16) {
- 47657 *bufp++ = c;
- 47658 if (--width)
- 47659 c = getc(stream);
- 47660 if (c != 'x' && c != 'X') {
- 47661 if (type == 'i') base = 8;
- 47662 }
- 47663 else if (width) {
- 47664 *bufp++ = c;
- 47665 if (--width)
- 47666 c = getc(stream);
- 47667 }
- 47668 }
- 47669 else if (type == 'i') base = 10;
- 47670
- 47671 while (width) {
- 47672 if (((base == 10) && isdigit(c))
- 47673 || ((base == 16) && isxdigit(c))
- 47674 || ((base == 8) && isdigit(c) && (c < '8'))
- 47675 || ((base == 2) && isdigit(c) && (c < '2'))) {
- 47676 *bufp++ = c;
- 47677 if (--width)
- 47678 c = getc(stream);
- 47679 }
- 47680 else break;
- 47681 }
- 47682
- 47683 if (width && c != EOF) ungetc(c, stream);
- 47684 if (type == 'i') base = 0;
- 47685 *basep = base;
- 47686 *bufp = ' ';
- 47687 return bufp - 1;
- 47688 }
- 47690 #ifndef NOFLOAT
- 47691 /* The function f_collect() reads a string that has the format of a
- 47692 * floating-point number. The function returns as soon as a format-error
- 47693 * is encountered, leaving the offending character in the input. This means
- 47694 * that 1.el leaves the 'l' in the input queue. Since all detection of
- 47695 * format errors is done here, _doscan() doesn't call strtod() when it's
- 47696 * not necessary, although the use of the width field can cause incomplete
- 47697 * numbers to be passed to strtod(). (e.g. 1.3e+)
- 47698 */
- 47699 static char *
- 47700 f_collect(register int c, register FILE *stream, register unsigned int width)
- 47701 {
- 47702 register char *bufp = inp_buf;
- 47703 int digit_seen = 0;
- 47704
- 47705 if (c == '-' || c == '+') {
- 47706 *bufp++ = c;
- 47707 if (--width)
- 47708 c = getc(stream);
- 47709 }
- 47710
- 47711 while (width && isdigit(c)) {
- 47712 digit_seen++;
- 47713 *bufp++ = c;
- 47714 if (--width)
- 47715 c = getc(stream);
- 47716 }
- 47717 if (width && c == '.') {
- 47718 *bufp++ = c;
- 47719 if(--width)
- 47720 c = getc(stream);
- 47721 while (width && isdigit(c)) {
- 47722 digit_seen++;
- 47723 *bufp++ = c;
- 47724 if (--width)
- 47725 c = getc(stream);
- 47726 }
- 47727 }
- 47728
- 47729 if (!digit_seen) {
- 47730 if (width && c != EOF) ungetc(c, stream);
- 47731 return inp_buf - 1;
- 47732 }
- 47733 else digit_seen = 0;
- 47734
- 47735 if (width && (c == 'e' || c == 'E')) {
- 47736 *bufp++ = c;
- 47737 if (--width)
- 47738 c = getc(stream);
- 47739 if (width && (c == '+' || c == '-')) {
- 47740 *bufp++ = c;
- 47741 if (--width)
- 47742 c = getc(stream);
- 47743 }
- 47744 while (width && isdigit(c)) {
- 47745 digit_seen++;
- 47746 *bufp++ = c;
- 47747 if (--width)
- 47748 c = getc(stream);
- 47749 }
- 47750 if (!digit_seen) {
- 47751 if (width && c != EOF) ungetc(c,stream);
- 47752 return inp_buf - 1;
- 47753 }
- 47754 }
- 47755
- 47756 if (width && c != EOF) ungetc(c, stream);
- 47757 *bufp = ' ';
- 47758 return bufp - 1;
- 47759 }
- 47760 #endif /* NOFLOAT */
- 47761
- 47762
- 47763 /*
- 47764 * the routine that does the scanning
- 47765 */
- 47766
- 47767 int
- 47768 _doscan(register FILE *stream, const char *format, va_list ap)
- 47769 {
- 47770 int done = 0; /* number of items done */
- 47771 int nrchars = 0; /* number of characters read */
- 47772 int conv = 0; /* # of conversions */
- 47773 int base; /* conversion base */
- 47774 unsigned long val; /* an integer value */
- 47775 register char *str; /* temporary pointer */
- 47776 char *tmp_string; /* ditto */
- 47777 unsigned width = 0; /* width of field */
- 47778 int flags; /* some flags */
- 47779 int reverse; /* reverse the checking in [...] */
- 47780 int kind;
- 47781 register int ic = EOF; /* the input character */
- 47782 #ifndef NOFLOAT
- 47783 long double ld_val;
- 47784 #endif
- 47785
- 47786 if (!*format) return 0;
- 47787
- 47788 while (1) {
- 47789 if (isspace(*format)) {
- 47790 while (isspace(*format))
- 47791 format++; /* skip whitespace */
- 47792 ic = getc(stream);
- 47793 nrchars++;
- 47794 while (isspace (ic)) {
- 47795 ic = getc(stream);
- 47796 nrchars++;
- 47797 }
- 47798 if (ic != EOF) ungetc(ic,stream);
- 47799 nrchars--;
- 47800 }
- 47801 if (!*format) break; /* end of format */
- 47802
- 47803 if (*format != '%') {
- 47804 ic = getc(stream);
- 47805 nrchars++;
- 47806 if (ic != *format++) break; /* error */
- 47807 continue;
- 47808 }
- 47809 format++;
- 47810 if (*format == '%') {
- 47811 ic = getc(stream);
- 47812 nrchars++;
- 47813 if (ic == '%') {
- 47814 format++;
- 47815 continue;
- 47816 }
- 47817 else break;
- 47818 }
- 47819 flags = 0;
- 47820 if (*format == '*') {
- 47821 format++;
- 47822 flags |= FL_NOASSIGN;
- 47823 }
- 47824 if (isdigit (*format)) {
- 47825 flags |= FL_WIDTHSPEC;
- 47826 for (width = 0; isdigit (*format);)
- 47827 width = width * 10 + *format++ - '0';
- 47828 }
- 47829
- 47830 switch (*format) {
- 47831 case 'h': flags |= FL_SHORT; format++; break;
- 47832 case 'l': flags |= FL_LONG; format++; break;
- 47833 case 'L': flags |= FL_LONGDOUBLE; format++; break;
- 47834 }
- 47835 kind = *format;
- 47836 if ((kind != 'c') && (kind != '[') && (kind != 'n')) {
- 47837 do {
- 47838 ic = getc(stream);
- 47839 nrchars++;
- 47840 } while (isspace(ic));
- 47841 if (ic == EOF) break; /* outer while */
- 47842 } else if (kind != 'n') { /* %c or %[ */
- 47843 ic = getc(stream);
- 47844 if (ic == EOF) break; /* outer while */
- 47845 nrchars++;
- 47846 }
- 47847 switch (kind) {
- 47848 default:
- 47849 /* not recognized, like %q */
- 47850 return conv || (ic != EOF) ? done : EOF;
- 47851 break;
- 47852 case 'n':
- 47853 if (!(flags & FL_NOASSIGN)) { /* silly, though */
- 47854 if (flags & FL_SHORT)
- 47855 *va_arg(ap, short *) = (short) nrchars;
- 47856 else if (flags & FL_LONG)
- 47857 *va_arg(ap, long *) = (long) nrchars;
- 47858 else
- 47859 *va_arg(ap, int *) = (int) nrchars;
- 47860 }
- 47861 break;
- 47862 case 'p': /* pointer */
- 47863 set_pointer(flags);
- 47864 /* fallthrough */
- 47865 case 'b': /* binary */
- 47866 case 'd': /* decimal */
- 47867 case 'i': /* general integer */
- 47868 case 'o': /* octal */
- 47869 case 'u': /* unsigned */
- 47870 case 'x': /* hexadecimal */
- 47871 case 'X': /* ditto */
- 47872 if (!(flags & FL_WIDTHSPEC) || width > NUMLEN)
- 47873 width = NUMLEN;
- 47874 if (!width) return done;
- 47875
- 47876 str = o_collect(ic, stream, kind, width, &base);
- 47877 if (str < inp_buf
- 47878 || (str == inp_buf
- 47879 && (*str == '-'
- 47880 || *str == '+'))) return done;
- 47881
- 47882 /*
- 47883 * Although the length of the number is str-inp_buf+1
- 47884 * we don't add the 1 since we counted it already
- 47885 */
- 47886 nrchars += str - inp_buf;
- 47887
- 47888 if (!(flags & FL_NOASSIGN)) {
- 47889 if (kind == 'd' || kind == 'i')
- 47890 val = strtol(inp_buf, &tmp_string, base);
- 47891 else
- 47892 val = strtoul(inp_buf, &tmp_string, base);
- 47893 if (flags & FL_LONG)
- 47894 *va_arg(ap, unsigned long *) = (unsigned long) val;
- 47895 else if (flags & FL_SHORT)
- 47896 *va_arg(ap, unsigned short *) = (unsigned short) val;
- 47897 else
- 47898 *va_arg(ap, unsigned *) = (unsigned) val;
- 47899 }
- 47900 break;
- 47901 case 'c':
- 47902 if (!(flags & FL_WIDTHSPEC))
- 47903 width = 1;
- 47904 if (!(flags & FL_NOASSIGN))
- 47905 str = va_arg(ap, char *);
- 47906 if (!width) return done;
- 47907
- 47908 while (width && ic != EOF) {
- 47909 if (!(flags & FL_NOASSIGN))
- 47910 *str++ = (char) ic;
- 47911 if (--width) {
- 47912 ic = getc(stream);
- 47913 nrchars++;
- 47914 }
- 47915 }
- 47916
- 47917 if (width) {
- 47918 if (ic != EOF) ungetc(ic,stream);
- 47919 nrchars--;
- 47920 }
- 47921 break;
- 47922 case 's':
- 47923 if (!(flags & FL_WIDTHSPEC))
- 47924 width = 0xffff;
- 47925 if (!(flags & FL_NOASSIGN))
- 47926 str = va_arg(ap, char *);
- 47927 if (!width) return done;
- 47928
- 47929 while (width && ic != EOF && !isspace(ic)) {
- 47930 if (!(flags & FL_NOASSIGN))
- 47931 *str++ = (char) ic;
- 47932 if (--width) {
- 47933 ic = getc(stream);
- 47934 nrchars++;
- 47935 }
- 47936 }
- 47937 /* terminate the string */
- 47938 if (!(flags & FL_NOASSIGN))
- 47939 *str = ' ';
- 47940 if (width) {
- 47941 if (ic != EOF) ungetc(ic,stream);
- 47942 nrchars--;
- 47943 }
- 47944 break;
- 47945 case '[':
- 47946 if (!(flags & FL_WIDTHSPEC))
- 47947 width = 0xffff;
- 47948 if (!width) return done;
- 47949
- 47950 if ( *++format == '^' ) {
- 47951 reverse = 1;
- 47952 format++;
- 47953 } else
- 47954 reverse = 0;
- 47955
- 47956 for (str = Xtable; str < &Xtable[NR_CHARS]
- 47957 ; str++)
- 47958 *str = 0;
- 47959
- 47960 if (*format == ']') Xtable[*format++] = 1;
- 47961
- 47962 while (*format && *format != ']') {
- 47963 Xtable[*format++] = 1;
- 47964 if (*format == '-') {
- 47965 format++;
- 47966 if (*format
- 47967 && *format != ']'
- 47968 && *(format) >= *(format -2)) {
- 47969 int c;
- 47970
- 47971 for( c = *(format -2) + 1
- 47972 ; c <= *format ; c++)
- 47973 Xtable[c] = 1;
- 47974 format++;
- 47975 }
- 47976 else Xtable['-'] = 1;
- 47977 }
- 47978 }
- 47979 if (!*format) return done;
- 47980
- 47981 if (!(Xtable[ic] ^ reverse)) return done;
- 47982
- 47983 if (!(flags & FL_NOASSIGN))
- 47984 str = va_arg(ap, char *);
- 47985
- 47986 do {
- 47987 if (!(flags & FL_NOASSIGN))
- 47988 *str++ = (char) ic;
- 47989 if (--width) {
- 47990 ic = getc(stream);
- 47991 nrchars++;
- 47992 }
- 47993 } while (width && ic != EOF && (Xtable[ic] ^ reverse));
- 47994
- 47995 if (width) {
- 47996 if (ic != EOF) ungetc(ic, stream);
- 47997 nrchars--;
- 47998 }
- 47999 if (!(flags & FL_NOASSIGN)) { /* terminate string */
- 48000 *str = ' ';
- 48001 }
- 48002 break;
- 48003 #ifndef NOFLOAT
- 48004 case 'e':
- 48005 case 'E':
- 48006 case 'f':
- 48007 case 'g':
- 48008 case 'G':
- 48009 if (!(flags & FL_WIDTHSPEC) || width > NUMLEN)
- 48010 width = NUMLEN;
- 48011
- 48012 if (!width) return done;
- 48013 str = f_collect(ic, stream, width);
- 48014
- 48015 if (str < inp_buf
- 48016 || (str == inp_buf
- 48017 && (*str == '-'
- 48018 || *str == '+'))) return done;
- 48019
- 48020 /*
- 48021 * Although the length of the number is str-inp_buf+1
- 48022 * we don't add the 1 since we counted it already
- 48023 */
- 48024 nrchars += str - inp_buf;
- 48025
- 48026 if (!(flags & FL_NOASSIGN)) {
- 48027 ld_val = strtod(inp_buf, &tmp_string);
- 48028 if (flags & FL_LONGDOUBLE)
- 48029 *va_arg(ap, long double *) = (long double) ld_val;
- 48030 else
- 48031 if (flags & FL_LONG)
- 48032 *va_arg(ap, double *) = (double) ld_val;
- 48033 else
- 48034 *va_arg(ap, float *) = (float) ld_val;
- 48035 }
- 48036 break;
- 48037 #endif
- 48038 } /* end switch */
- 48039 conv++;
- 48040 if (!(flags & FL_NOASSIGN) && kind != 'n') done++;
- 48041 format++;
- 48042 }
- 48043 return conv || (ic != EOF) ? done : EOF;
- 48044 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/ecvt.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 48100 /* $Header: ecvt.c,v 1.4 90/02/27 16:47:28 eck Exp $ */
- 48101
- 48102 #ifndef NOFLOAT
- 48103
- 48104 #include "../ansi/ext_fmt.h"
- 48105 void _dbl_ext_cvt(double value, struct EXTEND *e);
- 48106 char *_ext_str_cvt(struct EXTEND *e, int ndigit, int *decpt, int * sign, int ecvtflag);
- 48107
- 48108 static char *
- 48109 cvt(long double value, int ndigit, int *decpt, int *sign, int ecvtflag)
- 48110 {
- 48111 struct EXTEND e;
- 48112
- 48113 _dbl_ext_cvt(value, &e);
- 48114 return _ext_str_cvt(&e, ndigit, decpt, sign, ecvtflag);
- 48115 }
- 48117 char *
- 48118 _ecvt(long double value, int ndigit, int *decpt, int *sign)
- 48119 {
- 48120
- 48121 return cvt(value, ndigit, decpt, sign, 1);
- 48122 }
- 48124 char *
- 48125 _fcvt(long double value, int ndigit, int *decpt, int *sign)
- 48126 {
- 48127 return cvt(value, ndigit, decpt, sign, 0);
- 48128 }
- 48130 #endif /* NOFLOAT */
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fclose.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 48200 /*
- 48201 * fclose.c - flush a stream and close the file
- 48202 */
- 48203 /* $Header: fclose.c,v 1.4 90/01/22 11:10:54 eck Exp $ */
- 48204
- 48205 #include <stdio.h>
- 48206 #include <stdlib.h>
- 48207 #include "loc_incl.h"
- 48208
- 48209 int _close(int d);
- 48210
- 48211 int
- 48212 fclose(FILE *fp)
- 48213 {
- 48214 register int i, retval = 0;
- 48215
- 48216 for (i=0; i<FOPEN_MAX; i++)
- 48217 if (fp == __iotab[i]) {
- 48218 __iotab[i] = 0;
- 48219 break;
- 48220 }
- 48221 if (i >= FOPEN_MAX)
- 48222 return EOF;
- 48223 if (fflush(fp)) retval = EOF;
- 48224 if (_close(fileno(fp))) retval = EOF;
- 48225 if ( io_testflag(fp,_IOMYBUF) && fp->_buf )
- 48226 free((void *)fp->_buf);
- 48227 if (fp != stdin && fp != stdout && fp != stderr)
- 48228 free((void *)fp);
- 48229 return retval;
- 48230 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/feof.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 48300 /*
- 48301 * feof.c - test if eof on a stream occurred
- 48302 */
- 48303 /* $Header: feof.c,v 1.2 89/12/18 15:00:39 eck Exp $ */
- 48304
- 48305 #include <stdio.h>
- 48306
- 48307 int
- 48308 (feof)(FILE *stream)
- 48309 {
- 48310 return feof(stream);
- 48311 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/ferror.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 48400 /*
- 48401 * ferror .c - test if an error on a stream occurred
- 48402 */
- 48403 /* $Header: ferror.c,v 1.2 89/12/18 15:00:47 eck Exp $ */
- 48404
- 48405 #include <stdio.h>
- 48406
- 48407 int
- 48408 (ferror)(FILE *stream)
- 48409 {
- 48410 return ferror(stream);
- 48411 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fflush.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 48500 /*
- 48501 * fflush.c - flush stream(s)
- 48502 */
- 48503 /* $Header: fflush.c,v 1.6 90/04/04 15:52:01 eck Exp $ */
- 48504
- 48505 #include <sys/types.h>
- 48506 #include <stdio.h>
- 48507 #include "loc_incl.h"
- 48508
- 48509 ssize_t _write(int d, const char *buf, size_t nbytes);
- 48510 off_t _lseek(int fildes, off_t offset, int whence);
- 48511
- 48512 int
- 48513 fflush(FILE *stream)
- 48514 {
- 48515 int count, c1, i, retval = 0;
- 48516
- 48517 if (!stream) {
- 48518 for(i= 0; i < FOPEN_MAX; i++)
- 48519 if (__iotab[i] && fflush(__iotab[i]))
- 48520 retval = EOF;
- 48521 return retval;
- 48522 }
- 48523
- 48524 if (!stream->_buf
- 48525 || (!io_testflag(stream, _IOREADING)
- 48526 && !io_testflag(stream, _IOWRITING)))
- 48527 return 0;
- 48528 if (io_testflag(stream, _IOREADING)) {
- 48529 /* (void) fseek(stream, 0L, SEEK_CUR); */
- 48530 int adjust = 0;
- 48531 if (stream->_buf && !io_testflag(stream,_IONBF))
- 48532 adjust = stream->_count;
- 48533 stream->_count = 0;
- 48534 _lseek(fileno(stream), (off_t) adjust, SEEK_CUR);
- 48535 if (io_testflag(stream, _IOWRITE))
- 48536 stream->_flags &= ~(_IOREADING | _IOWRITING);
- 48537 stream->_ptr = stream->_buf;
- 48538 return 0;
- 48539 } else if (io_testflag(stream, _IONBF)) return 0;
- 48540
- 48541 if (io_testflag(stream, _IOREAD)) /* "a" or "+" mode */
- 48542 stream->_flags &= ~_IOWRITING;
- 48543
- 48544 count = stream->_ptr - stream->_buf;
- 48545 stream->_ptr = stream->_buf;
- 48546
- 48547 if ( count <= 0 )
- 48548 return 0;
- 48549
- 48550 if (io_testflag(stream, _IOAPPEND)) {
- 48551 if (_lseek(fileno(stream), 0L, SEEK_END) == -1) {
- 48552 stream->_flags |= _IOERR;
- 48553 return EOF;
- 48554 }
- 48555 }
- 48556 c1 = _write(stream->_fd, (char *)stream->_buf, count);
- 48557
- 48558 stream->_count = 0;
- 48559
- 48560 if ( count == c1 )
- 48561 return 0;
- 48562
- 48563 stream->_flags |= _IOERR;
- 48564 return EOF;
- 48565 }
- 48567 void
- 48568 __cleanup(void)
- 48569 {
- 48570 register int i;
- 48571
- 48572 for(i= 0; i < FOPEN_MAX; i++)
- 48573 if (__iotab[i] && io_testflag(__iotab[i], _IOWRITING))
- 48574 (void) fflush(__iotab[i]);
- 48575 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fgetc.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 48600 /*
- 48601 * fgetc - get an unsigned character and return it as an int
- 48602 */
- 48603 /* $Header: fgetc.c,v 1.1 89/05/30 13:27:35 eck Exp $ */
- 48604
- 48605 #include <stdio.h>
- 48606
- 48607 int
- 48608 fgetc(FILE *stream)
- 48609 {
- 48610 return getc(stream);
- 48611 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fgetpos.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 48700 /*
- 48701 * fgetpos.c - get the position in the file
- 48702 */
- 48703 /* $Header: fgetpos.c,v 1.2 89/12/18 15:01:03 eck Exp $ */
- 48704
- 48705 #include <stdio.h>
- 48706
- 48707 int
- 48708 fgetpos(FILE *stream, fpos_t *pos)
- 48709 {
- 48710 *pos = ftell(stream);
- 48711 if (*pos == -1) return -1;
- 48712 return 0;
- 48713 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fgets.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 48800 /*
- 48801 * fgets.c - get a string from a file
- 48802 */
- 48803 /* $Header: fgets.c,v 1.3 89/12/18 15:01:11 eck Exp $ */
- 48804
- 48805 #include <stdio.h>
- 48806
- 48807 char *
- 48808 fgets(char *s, register int n, register FILE *stream)
- 48809 {
- 48810 register int ch;
- 48811 register char *ptr;
- 48812
- 48813 ptr = s;
- 48814 while (--n > 0 && (ch = getc(stream)) != EOF) {
- 48815 *ptr++ = ch;
- 48816 if ( ch == 'n')
- 48817 break;
- 48818 }
- 48819 if (ch == EOF) {
- 48820 if (feof(stream)) {
- 48821 if (ptr == s) return NULL;
- 48822 } else return NULL;
- 48823 }
- 48824 *ptr = ' ';
- 48825 return s;
- 48826 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fileno.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 48900 /*
- 48901 * fileno .c - map a stream to a file descriptor
- 48902 */
- 48903 /* $Header: fileno.c,v 1.1 89/12/18 14:59:31 eck Exp $ */
- 48904
- 48905 #include <stdio.h>
- 48906
- 48907 int
- 48908 (fileno)(FILE *stream)
- 48909 {
- 48910 return stream->_fd;
- 48911 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fillbuf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 49000 /*
- 49001 * fillbuf.c - fill a buffer
- 49002 */
- 49003 /* $Header: fillbuf.c,v 1.5 90/06/21 11:13:23 eck Exp $ */
- 49004
- 49005 #if defined(_POSIX_SOURCE)
- 49006 #include <sys/types.h>
- 49007 #endif
- 49008 #include <stdio.h>
- 49009 #include <stdlib.h>
- 49010 #include "loc_incl.h"
- 49011
- 49012 ssize_t _read(ssize_t d, char *buf, size_t nbytes);
- 49013
- 49014 int
- 49015 __fillbuf(register FILE *stream)
- 49016 {
- 49017 static unsigned char ch[FOPEN_MAX];
- 49018 register int i;
- 49019
- 49020 stream->_count = 0;
- 49021 if (fileno(stream) < 0) return EOF;
- 49022 if (io_testflag(stream, (_IOEOF | _IOERR ))) return EOF;
- 49023 if (!io_testflag(stream, _IOREAD))
- 49024 { stream->_flags |= _IOERR; return EOF; }
- 49025 if (io_testflag(stream, _IOWRITING))
- 49026 { stream->_flags |= _IOERR; return EOF; }
- 49027
- 49028 if (!io_testflag(stream, _IOREADING))
- 49029 stream->_flags |= _IOREADING;
- 49030
- 49031 if (!io_testflag(stream, _IONBF) && !stream->_buf) {
- 49032 stream->_buf = (unsigned char *) malloc(BUFSIZ);
- 49033 if (!stream->_buf) {
- 49034 stream->_flags |= _IONBF;
- 49035 }
- 49036 else {
- 49037 stream->_flags |= _IOMYBUF;
- 49038 stream->_bufsiz = BUFSIZ;
- 49039 }
- 49040 }
- 49041
- 49042 /* flush line-buffered output when filling an input buffer */
- 49043 for (i = 0; i < FOPEN_MAX; i++) {
- 49044 if (__iotab[i] && io_testflag(__iotab[i], _IOLBF))
- 49045 if (io_testflag(__iotab[i], _IOWRITING))
- 49046 (void) fflush(__iotab[i]);
- 49047 }
- 49048
- 49049 if (!stream->_buf) {
- 49050 stream->_buf = &ch[fileno(stream)];
- 49051 stream->_bufsiz = 1;
- 49052 }
- 49053 stream->_ptr = stream->_buf;
- 49054 stream->_count = _read(stream->_fd, (char *)stream->_buf, stream->_bufsiz);
- 49055
- 49056 if (stream->_count <= 0){
- 49057 if (stream->_count == 0) {
- 49058 stream->_flags |= _IOEOF;
- 49059 }
- 49060 else
- 49061 stream->_flags |= _IOERR;
- 49062
- 49063 return EOF;
- 49064 }
- 49065 stream->_count--;
- 49066
- 49067 return *stream->_ptr++;
- 49068 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/flushbuf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 49100 /*
- 49101 * flushbuf.c - flush a buffer
- 49102 */
- 49103 /* $Header: flushbuf.c,v 1.6 91/06/10 17:07:10 ceriel Exp $ */
- 49104
- 49105 #include <stdio.h>
- 49106 #include <stdlib.h>
- 49107 #include "loc_incl.h"
- 49108
- 49109 #include <sys/types.h>
- 49110
- 49111 off_t _lseek(int fildes, off_t offset, int whence);
- 49112 ssize_t _write(int d, const char *buf, size_t nbytes);
- 49113 int _isatty(int d);
- 49114 extern void (*_clean)(void);
- 49115
- 49116 static int
- 49117 do_write(int d, char *buf, int nbytes)
- 49118 {
- 49119 int c;
- 49120
- 49121 /* POSIX actually allows write() to return a positive value less
- 49122 than nbytes, so loop ...
- 49123 */
- 49124 while ((c = _write(d, buf, nbytes)) > 0 && c < nbytes) {
- 49125 nbytes -= c;
- 49126 buf += c;
- 49127 }
- 49128 return c > 0;
- 49129 }
- 49131 int
- 49132 __flushbuf(int c, FILE * stream)
- 49133 {
- 49134 _clean = __cleanup;
- 49135 if (fileno(stream) < 0) return EOF;
- 49136 if (!io_testflag(stream, _IOWRITE)) return EOF;
- 49137 if (io_testflag(stream, _IOREADING) && !feof(stream)) return EOF;
- 49138
- 49139 stream->_flags &= ~_IOREADING;
- 49140 stream->_flags |= _IOWRITING;
- 49141 if (!io_testflag(stream, _IONBF)) {
- 49142 if (!stream->_buf) {
- 49143 if (stream == stdout && _isatty(fileno(stdout))) {
- 49144 if (!(stream->_buf =
- 49145 (unsigned char *) malloc(BUFSIZ))) {
- 49146 stream->_flags |= _IONBF;
- 49147 } else {
- 49148 stream->_flags |= _IOLBF|_IOMYBUF;
- 49149 stream->_bufsiz = BUFSIZ;
- 49150 stream->_count = -1;
- 49151 }
- 49152 } else {
- 49153 if (!(stream->_buf =
- 49154 (unsigned char *) malloc(BUFSIZ))) {
- 49155 stream->_flags |= _IONBF;
- 49156 } else {
- 49157 stream->_flags |= _IOMYBUF;
- 49158 stream->_bufsiz = BUFSIZ;
- 49159 if (!io_testflag(stream, _IOLBF))
- 49160 stream->_count = BUFSIZ - 1;
- 49161 else stream->_count = -1;
- 49162 }
- 49163 }
- 49164 stream->_ptr = stream->_buf;
- 49165 }
- 49166 }
- 49167
- 49168 if (io_testflag(stream, _IONBF)) {
- 49169 char c1 = c;
- 49170
- 49171 stream->_count = 0;
- 49172 if (io_testflag(stream, _IOAPPEND)) {
- 49173 if (_lseek(fileno(stream), 0L, SEEK_END) == -1) {
- 49174 stream->_flags |= _IOERR;
- 49175 return EOF;
- 49176 }
- 49177 }
- 49178 if (_write(fileno(stream), &c1, 1) != 1) {
- 49179 stream->_flags |= _IOERR;
- 49180 return EOF;
- 49181 }
- 49182 return c;
- 49183 } else if (io_testflag(stream, _IOLBF)) {
- 49184 *stream->_ptr++ = c;
- 49185 if (c == 'n' || stream->_count == -stream->_bufsiz) {
- 49186 if (io_testflag(stream, _IOAPPEND)) {
- 49187 if (_lseek(fileno(stream), 0L, SEEK_END) == -1) {
- 49188 stream->_flags |= _IOERR;
- 49189 return EOF;
- 49190 }
- 49191 }
- 49192 if (! do_write(fileno(stream), (char *)stream->_buf,
- 49193 -stream->_count)) {
- 49194 stream->_flags |= _IOERR;
- 49195 return EOF;
- 49196 } else {
- 49197 stream->_ptr = stream->_buf;
- 49198 stream->_count = 0;
- 49199 }
- 49200 }
- 49201 } else {
- 49202 int count = stream->_ptr - stream->_buf;
- 49203
- 49204 stream->_count = stream->_bufsiz - 1;
- 49205 stream->_ptr = stream->_buf + 1;
- 49206
- 49207 if (count > 0) {
- 49208 if (io_testflag(stream, _IOAPPEND)) {
- 49209 if (_lseek(fileno(stream), 0L, SEEK_END) == -1) {
- 49210 stream->_flags |= _IOERR;
- 49211 return EOF;
- 49212 }
- 49213 }
- 49214 if (! do_write(fileno(stream), (char *)stream->_buf, count)) {
- 49215 *(stream->_buf) = c;
- 49216 stream->_flags |= _IOERR;
- 49217 return EOF;
- 49218 }
- 49219 }
- 49220 *(stream->_buf) = c;
- 49221 }
- 49222 return c;
- 49223 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fopen.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 49300 /*
- 49301 * fopen.c - open a stream
- 49302 */
- 49303 /* $Header: fopen.c,v 1.8 91/02/22 16:29:46 ceriel Exp $ */
- 49304
- 49305 #if defined(_POSIX_SOURCE)
- 49306 #include <sys/types.h>
- 49307 #endif
- 49308 #include <stdio.h>
- 49309 #include <stdlib.h>
- 49310 #include "loc_incl.h"
- 49311
- 49312 #define PMODE 0666
- 49313
- 49314 /* The next 3 defines are true in all UNIX systems known to me.
- 49315 */
- 49316 #define O_RDONLY 0
- 49317 #define O_WRONLY 1
- 49318 #define O_RDWR 2
- 49319
- 49320 /* Since the O_CREAT flag is not available on all systems, we can't get it
- 49321 * from the standard library. Furthermore, even if we know that <fcntl.h>
- 49322 * contains such a flag, it's not sure whether it can be used, since we
- 49323 * might be cross-compiling for another system, which may use an entirely
- 49324 * different value for O_CREAT (or not support such a mode). The safest
- 49325 * thing is to just use the Version 7 semantics for open, and use creat()
- 49326 * whenever necessary.
- 49327 *
- 49328 * Another problem is O_APPEND, for which the same holds. When "a"
- 49329 * open-mode is used, an lseek() to the end is done before every write()
- 49330 * system-call.
- 49331 *
- 49332 * The O_CREAT, O_TRUNC and O_APPEND given here, are only for convenience.
- 49333 * They are not passed to open(), so the values don't have to match a value
- 49334 * from the real world. It is enough when they are unique.
- 49335 */
- 49336 #define O_CREAT 0x010
- 49337 #define O_TRUNC 0x020
- 49338 #define O_APPEND 0x040
- 49339
- 49340 int _open(const char *path, int flags);
- 49341 int _creat(const char *path, Mode_t mode);
- 49342 int _close(int d);
- 49343
- 49344 FILE *
- 49345 fopen(const char *name, const char *mode)
- 49346 {
- 49347 register int i;
- 49348 int rwmode = 0, rwflags = 0;
- 49349 FILE *stream;
- 49350 int fd, flags = 0;
- 49351
- 49352 for (i = 0; __iotab[i] != 0 ; i++)
- 49353 if ( i >= FOPEN_MAX-1 )
- 49354 return (FILE *)NULL;
- 49355
- 49356 switch(*mode++) {
- 49357 case 'r':
- 49358 flags |= _IOREAD | _IOREADING;
- 49359 rwmode = O_RDONLY;
- 49360 break;
- 49361 case 'w':
- 49362 flags |= _IOWRITE | _IOWRITING;
- 49363 rwmode = O_WRONLY;
- 49364 rwflags = O_CREAT | O_TRUNC;
- 49365 break;
- 49366 case 'a':
- 49367 flags |= _IOWRITE | _IOWRITING | _IOAPPEND;
- 49368 rwmode = O_WRONLY;
- 49369 rwflags |= O_APPEND | O_CREAT;
- 49370 break;
- 49371 default:
- 49372 return (FILE *)NULL;
- 49373 }
- 49374
- 49375 while (*mode) {
- 49376 switch(*mode++) {
- 49377 case 'b':
- 49378 continue;
- 49379 case '+':
- 49380 rwmode = O_RDWR;
- 49381 flags |= _IOREAD | _IOWRITE;
- 49382 continue;
- 49383 /* The sequence may be followed by additional characters */
- 49384 default:
- 49385 break;
- 49386 }
- 49387 break;
- 49388 }
- 49389
- 49390 /* Perform a creat() when the file should be truncated or when
- 49391 * the file is opened for writing and the open() failed.
- 49392 */
- 49393 if ((rwflags & O_TRUNC)
- 49394 || (((fd = _open(name, rwmode)) < 0)
- 49395 && (rwflags & O_CREAT))) {
- 49396 if (((fd = _creat(name, PMODE)) > 0) && flags | _IOREAD) {
- 49397 (void) _close(fd);
- 49398 fd = _open(name, rwmode);
- 49399 }
- 49400
- 49401 }
- 49402
- 49403 if (fd < 0) return (FILE *)NULL;
- 49404
- 49405 if (( stream = (FILE *) malloc(sizeof(FILE))) == NULL ) {
- 49406 _close(fd);
- 49407 return (FILE *)NULL;
- 49408 }
- 49409
- 49410 if ((flags & (_IOREAD | _IOWRITE)) == (_IOREAD | _IOWRITE))
- 49411 flags &= ~(_IOREADING | _IOWRITING);
- 49412
- 49413 stream->_count = 0;
- 49414 stream->_fd = fd;
- 49415 stream->_flags = flags;
- 49416 stream->_buf = NULL;
- 49417 __iotab[i] = stream;
- 49418 return stream;
- 49419 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fprintf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 49500 /*
- 49501 * fprintf - write output on a stream
- 49502 */
- 49503 /* $Header: fprintf.c,v 1.3 89/12/18 15:01:54 eck Exp $ */
- 49504
- 49505 #include <stdio.h>
- 49506 #include <stdarg.h>
- 49507 #include "loc_incl.h"
- 49508
- 49509 int
- 49510 fprintf(FILE *stream, const char *format, ...)
- 49511 {
- 49512 va_list ap;
- 49513 int retval;
- 49514
- 49515 va_start(ap, format);
- 49516
- 49517 retval = _doprnt (format, ap, stream);
- 49518
- 49519 va_end(ap);
- 49520
- 49521 return retval;
- 49522 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fputc.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 49600 /*
- 49601 * fputc.c - print an unsigned character
- 49602 */
- 49603 /* $Header: fputc.c,v 1.1 89/05/30 13:28:45 eck Exp $ */
- 49604
- 49605 #include <stdio.h>
- 49606
- 49607 int
- 49608 fputc(int c, FILE *stream)
- 49609 {
- 49610 return putc(c, stream);
- 49611 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fputs.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 49700 /*
- 49701 * fputs - print a string
- 49702 */
- 49703 /* $Header: fputs.c,v 1.2 89/12/18 15:02:01 eck Exp $ */
- 49704
- 49705 #include <stdio.h>
- 49706
- 49707 int
- 49708 fputs(register const char *s, register FILE *stream)
- 49709 {
- 49710 register int i = 0;
- 49711
- 49712 while (*s)
- 49713 if (putc(*s++, stream) == EOF) return EOF;
- 49714 else i++;
- 49715
- 49716 return i;
- 49717 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fread.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 49800 /*
- 49801 * fread.c - read a number of members into an array
- 49802 */
- 49803 /* $Header: fread.c,v 1.2 89/12/18 15:02:09 eck Exp $ */
- 49804
- 49805 #include <stdio.h>
- 49806
- 49807 size_t
- 49808 fread(void *ptr, size_t size, size_t nmemb, register FILE *stream)
- 49809 {
- 49810 register char *cp = ptr;
- 49811 register int c;
- 49812 size_t ndone = 0;
- 49813 register size_t s;
- 49814
- 49815 if (size)
- 49816 while ( ndone < nmemb ) {
- 49817 s = size;
- 49818 do {
- 49819 if ((c = getc(stream)) != EOF)
- 49820 *cp++ = c;
- 49821 else
- 49822 return ndone;
- 49823 } while (--s);
- 49824 ndone++;
- 49825 }
- 49826
- 49827 return ndone;
- 49828 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/freopen.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 49900 /*
- 49901 * freopen.c - open a file and associate a stream with it
- 49902 */
- 49903 /* $Header: freopen.c,v 1.8 90/08/28 13:44:48 eck Exp $ */
- 49904
- 49905 #if defined(_POSIX_SOURCE)
- 49906 #include <sys/types.h>
- 49907 #endif
- 49908 #include <stdio.h>
- 49909 #include <stdlib.h>
- 49910 #include "loc_incl.h"
- 49911
- 49912 #define PMODE 0666
- 49913
- 49914 /* Do not "optimize" this file to use the open with O_CREAT if the file
- 49915 * does not exist. The reason is given in fopen.c.
- 49916 */
- 49917 #define O_RDONLY 0
- 49918 #define O_WRONLY 1
- 49919 #define O_RDWR 2
- 49920
- 49921 #define O_CREAT 0x010
- 49922 #define O_TRUNC 0x020
- 49923 #define O_APPEND 0x040
- 49924
- 49925 int _open(const char *path, int flags);
- 49926 int _creat(const char *path, Mode_t mode);
- 49927 int _close(int d);
- 49928
- 49929 FILE *
- 49930 freopen(const char *name, const char *mode, FILE *stream)
- 49931 {
- 49932 register int i;
- 49933 int rwmode = 0, rwflags = 0;
- 49934 int fd, flags = stream->_flags & (_IONBF | _IOFBF | _IOLBF | _IOMYBUF);
- 49935
- 49936 (void) fflush(stream); /* ignore errors */
- 49937 (void) _close(fileno(stream));
- 49938
- 49939 switch(*mode++) {
- 49940 case 'r':
- 49941 flags |= _IOREAD;
- 49942 rwmode = O_RDONLY;
- 49943 break;
- 49944 case 'w':
- 49945 flags |= _IOWRITE;
- 49946 rwmode = O_WRONLY;
- 49947 rwflags = O_CREAT | O_TRUNC;
- 49948 break;
- 49949 case 'a':
- 49950 flags |= _IOWRITE | _IOAPPEND;
- 49951 rwmode = O_WRONLY;
- 49952 rwflags |= O_APPEND | O_CREAT;
- 49953 break;
- 49954 default:
- 49955 return (FILE *)NULL;
- 49956 }
- 49957
- 49958 while (*mode) {
- 49959 switch(*mode++) {
- 49960 case 'b':
- 49961 continue;
- 49962 case '+':
- 49963 rwmode = O_RDWR;
- 49964 flags |= _IOREAD | _IOWRITE;
- 49965 continue;
- 49966 /* The sequence may be followed by aditional characters */
- 49967 default:
- 49968 break;
- 49969 }
- 49970 break;
- 49971 }
- 49972
- 49973 if ((rwflags & O_TRUNC)
- 49974 || (((fd = _open(name, rwmode)) < 0)
- 49975 && (rwflags & O_CREAT))) {
- 49976 if (((fd = _creat(name, PMODE)) < 0) && flags | _IOREAD) {
- 49977 (void) _close(fd);
- 49978 fd = _open(name, rwmode);
- 49979 }
- 49980 }
- 49981
- 49982 if (fd < 0) {
- 49983 for( i = 0; i < FOPEN_MAX; i++) {
- 49984 if (stream == __iotab[i]) {
- 49985 __iotab[i] = 0;
- 49986 break;
- 49987 }
- 49988 }
- 49989 if (stream != stdin && stream != stdout && stream != stderr)
- 49990 free((void *)stream);
- 49991 return (FILE *)NULL;
- 49992 }
- 49993
- 49994 stream->_count = 0;
- 49995 stream->_fd = fd;
- 49996 stream->_flags = flags;
- 49997 return stream;
- 49998 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fscanf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50000 /*
- 50001 * fscanf.c - read formatted input from stream
- 50002 */
- 50003 /* $Header: fscanf.c,v 1.1 89/05/30 13:29:17 eck Exp $ */
- 50004
- 50005 #include <stdio.h>
- 50006 #include <stdarg.h>
- 50007 #include "loc_incl.h"
- 50008
- 50009 int
- 50010 fscanf(FILE *stream, const char *format, ...)
- 50011 {
- 50012 va_list ap;
- 50013 int retval;
- 50014
- 50015 va_start(ap, format);
- 50016
- 50017 retval = _doscan(stream, format, ap);
- 50018
- 50019 va_end(ap);
- 50020
- 50021 return retval;
- 50022 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fseek.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50100 /*
- 50101 * fseek.c - perform an fseek
- 50102 */
- 50103 /* $Header: fseek.c,v 1.4 90/01/22 11:12:00 eck Exp $ */
- 50104
- 50105 #include <stdio.h>
- 50106
- 50107 #if (SEEK_CUR != 1) || (SEEK_END != 2) || (SEEK_SET != 0)
- 50108 #error SEEK_* values are wrong
- 50109 #endif
- 50110
- 50111 #include "loc_incl.h"
- 50112
- 50113 #include <sys/types.h>
- 50114
- 50115 off_t _lseek(int fildes, off_t offset, int whence);
- 50116
- 50117 int
- 50118 fseek(FILE *stream, long int offset, int whence)
- 50119 {
- 50120 int adjust = 0;
- 50121 long pos;
- 50122
- 50123 stream->_flags &= ~(_IOEOF | _IOERR);
- 50124 /* Clear both the end of file and error flags */
- 50125
- 50126 if (io_testflag(stream, _IOREADING)) {
- 50127 if (whence == SEEK_CUR
- 50128 && stream->_buf
- 50129 && !io_testflag(stream,_IONBF))
- 50130 adjust = stream->_count;
- 50131 stream->_count = 0;
- 50132 } else if (io_testflag(stream,_IOWRITING)) {
- 50133 fflush(stream);
- 50134 } else /* neither reading nor writing. The buffer must be empty */
- 50135 /* EMPTY */ ;
- 50136
- 50137 pos = _lseek(fileno(stream), offset - adjust, whence);
- 50138 if (io_testflag(stream, _IOREAD) && io_testflag(stream, _IOWRITE))
- 50139 stream->_flags &= ~(_IOREADING | _IOWRITING);
- 50140
- 50141 stream->_ptr = stream->_buf;
- 50142 return ((pos == -1) ? -1 : 0);
- 50143 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fsetpos.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50200 /*
- 50201 * fsetpos.c - set the position in the file
- 50202 */
- 50203 /* $Header: fsetpos.c,v 1.1 89/05/30 13:29:34 eck Exp $ */
- 50204
- 50205 #include <stdio.h>
- 50206
- 50207 int
- 50208 fsetpos(FILE *stream, fpos_t *pos)
- 50209 {
- 50210 return fseek(stream, *pos, SEEK_SET);
- 50211 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/ftell.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50300 /*
- 50301 * ftell.c - obtain the value of the file-position indicator of a stream
- 50302 */
- 50303 /* $Header: ftell.c,v 1.4 90/01/22 11:12:12 eck Exp $ */
- 50304
- 50305 #include <stdio.h>
- 50306
- 50307 #if (SEEK_CUR != 1) || (SEEK_SET != 0) || (SEEK_END != 2)
- 50308 #error SEEK_* values are wrong
- 50309 #endif
- 50310
- 50311 #include "loc_incl.h"
- 50312
- 50313 #include <sys/types.h>
- 50314
- 50315 off_t _lseek(int fildes, off_t offset, int whence);
- 50316
- 50317 long ftell(FILE *stream)
- 50318 {
- 50319 long result;
- 50320 int adjust = 0;
- 50321
- 50322 if (io_testflag(stream,_IOREADING))
- 50323 adjust = -stream->_count;
- 50324 else if (io_testflag(stream,_IOWRITING)
- 50325 && stream->_buf
- 50326 && !io_testflag(stream,_IONBF))
- 50327 adjust = stream->_ptr - stream->_buf;
- 50328 else adjust = 0;
- 50329
- 50330 result = _lseek(fileno(stream), (off_t)0, SEEK_CUR);
- 50331
- 50332 if ( result == -1 )
- 50333 return result;
- 50334
- 50335 result += (long) adjust;
- 50336 return result;
- 50337 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/fwrite.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50400 /*
- 50401 * fwrite.c - write a number of array elements on a file
- 50402 */
- 50403 /* $Header: fwrite.c,v 1.3 89/12/18 15:02:39 eck Exp $ */
- 50404
- 50405 #include <stdio.h>
- 50406
- 50407 size_t
- 50408 fwrite(const void *ptr, size_t size, size_t nmemb,
- 50409 register FILE *stream)
- 50410 {
- 50411 register const unsigned char *cp = ptr;
- 50412 register size_t s;
- 50413 size_t ndone = 0;
- 50414
- 50415 if (size)
- 50416 while ( ndone < nmemb ) {
- 50417 s = size;
- 50418 do {
- 50419 if (putc((int)*cp, stream)
- 50420 == EOF)
- 50421 return ndone;
- 50422 cp++;
- 50423 }
- 50424 while (--s);
- 50425 ndone++;
- 50426 }
- 50427 return ndone;
- 50428 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/getc.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50500 /*
- 50501 * getc.c - read an unsigned character
- 50502 */
- 50503 /* $Header: getc.c,v 1.2 89/12/18 15:02:45 eck Exp $ */
- 50504
- 50505 #include <stdio.h>
- 50506
- 50507 int
- 50508 (getc)(FILE *stream)
- 50509 {
- 50510 return getc(stream);
- 50511 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/getchar.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50600 /*
- 50601 * getchar.c - read a character from the standard input stream
- 50602 */
- 50603 /* $Header: getchar.c,v 1.2 89/12/18 15:02:53 eck Exp $ */
- 50604
- 50605 #include <stdio.h>
- 50606
- 50607 int
- 50608 (getchar)(void)
- 50609 {
- 50610 return getchar();
- 50611 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/gets.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50700 /*
- 50701 * gets.c - read a line from a stream
- 50702 */
- 50703 /* $Header: gets.c,v 1.2 89/12/18 15:03:00 eck Exp $ */
- 50704
- 50705 #include <stdio.h>
- 50706
- 50707 char *
- 50708 gets(char *s)
- 50709 {
- 50710 register FILE *stream = stdin;
- 50711 register int ch;
- 50712 register char *ptr;
- 50713
- 50714 ptr = s;
- 50715 while ((ch = getc(stream)) != EOF && ch != 'n')
- 50716 *ptr++ = ch;
- 50717
- 50718 if (ch == EOF) {
- 50719 if (feof(stream)) {
- 50720 if (ptr == s) return NULL;
- 50721 } else return NULL;
- 50722 }
- 50723
- 50724 *ptr = ' ';
- 50725 return s;
- 50726 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/icompute.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50800 /*
- 50801 * icompute.c - compute an integer
- 50802 */
- 50803 /* $Header: icompute.c,v 1.1 89/12/18 14:59:38 eck Exp $ */
- 50804
- 50805 #include "loc_incl.h"
- 50806
- 50807 /* This routine is used in doprnt.c as well as in tmpfile.c and tmpnam.c. */
- 50808
- 50809 char *
- 50810 _i_compute(unsigned long val, int base, char *s, int nrdigits)
- 50811 {
- 50812 int c;
- 50813
- 50814 c= val % base ;
- 50815 val /= base ;
- 50816 if (val || nrdigits > 1)
- 50817 s = _i_compute(val, base, s, nrdigits - 1);
- 50818 *s++ = (c>9 ? c-10+'a' : c+'0');
- 50819 return s;
- 50820 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/perror.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 50900 /*
- 50901 * perror.c - print an error message on the standard error output
- 50902 */
- 50903 /* $Header: perror.c,v 1.1 89/05/30 13:31:30 eck Exp $ */
- 50904
- 50905 #if defined(_POSIX_SOURCE)
- 50906 #include <sys/types.h>
- 50907 #endif
- 50908 #include <stdio.h>
- 50909 #include <errno.h>
- 50910 #include <stdio.h>
- 50911 #include <string.h>
- 50912 #include "loc_incl.h"
- 50913
- 50914 ssize_t _write(int d, const char *buf, size_t nbytes);
- 50915
- 50916 void
- 50917 perror(const char *s)
- 50918 {
- 50919 char *p;
- 50920 int fd;
- 50921
- 50922 p = strerror(errno);
- 50923 fd = fileno(stderr);
- 50924 fflush(stdout);
- 50925 fflush(stderr);
- 50926 if (s && *s) {
- 50927 _write(fd, s, strlen(s));
- 50928 _write(fd, ": ", 2);
- 50929 }
- 50930 _write(fd, p, strlen(p));
- 50931 _write(fd, "n", 1);
- 50932 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/printf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51000 /*
- 51001 * printf - write on the standard output stream
- 51002 */
- 51003 /* $Header: printf.c,v 1.3 89/12/18 15:03:08 eck Exp $ */
- 51004
- 51005 #include <stdio.h>
- 51006 #include <stdarg.h>
- 51007 #include "loc_incl.h"
- 51008
- 51009 int
- 51010 printf(const char *format, ...)
- 51011 {
- 51012 va_list ap;
- 51013 int retval;
- 51014
- 51015 va_start(ap, format);
- 51016
- 51017 retval = _doprnt(format, ap, stdout);
- 51018
- 51019 va_end(ap);
- 51020
- 51021 return retval;
- 51022 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/putc.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51100 /*
- 51101 * putc.c - print (or buffer) one character
- 51102 */
- 51103 /* $Header: putc.c,v 1.2 89/12/18 15:03:15 eck Exp $ */
- 51104
- 51105 #include <stdio.h>
- 51106
- 51107 int
- 51108 (putc)(int c, FILE *stream)
- 51109 {
- 51110 return putc(c, stream);
- 51111 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/putchar.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51200 /*
- 51201 * putchar.c - print (or buffer) a character on the standard output stream
- 51202 */
- 51203 /* $Header: putchar.c,v 1.2 89/12/18 15:03:23 eck Exp $ */
- 51204
- 51205 #include <stdio.h>
- 51206
- 51207 int
- 51208 (putchar)(int c)
- 51209 {
- 51210 return putchar(c);
- 51211 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/puts.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51300 /*
- 51301 * puts.c - print a string onto the standard output stream
- 51302 */
- 51303 /* $Header: puts.c,v 1.2 89/12/18 15:03:30 eck Exp $ */
- 51304
- 51305 #include <stdio.h>
- 51306
- 51307 int
- 51308 puts(register const char *s)
- 51309 {
- 51310 register FILE *file = stdout;
- 51311 register int i = 0;
- 51312
- 51313 while (*s) {
- 51314 if (putc(*s++, file) == EOF) return EOF;
- 51315 else i++;
- 51316 }
- 51317 if (putc('n', file) == EOF) return EOF;
- 51318 return i + 1;
- 51319 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/remove.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51400 /*
- 51401 * remove.c - remove a file
- 51402 */
- 51403 /* $Header: remove.c,v 1.2 90/01/22 11:12:44 eck Exp $ */
- 51404
- 51405 #include <stdio.h>
- 51406
- 51407 int _unlink(const char *path);
- 51408
- 51409 int
- 51410 remove(const char *filename) {
- 51411 return _unlink(filename);
- 51412 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/rewind.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51500 /*
- 51501 * rewind.c - set the file position indicator of a stream to the start
- 51502 */
- 51503 /* $Header: rewind.c,v 1.1 89/05/30 13:32:52 eck Exp $ */
- 51504
- 51505 #include <stdio.h>
- 51506 #include "loc_incl.h"
- 51507
- 51508 void
- 51509 rewind(FILE *stream)
- 51510 {
- 51511 (void) fseek(stream, 0L, SEEK_SET);
- 51512 clearerr(stream);
- 51513 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/scanf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51600 /*
- 51601 * scanf.c - read formatted input from the standard input stream
- 51602 */
- 51603 /* $Header: scanf.c,v 1.1 89/05/30 13:33:03 eck Exp $ */
- 51604
- 51605 #include <stdio.h>
- 51606 #include <stdarg.h>
- 51607 #include "loc_incl.h"
- 51608
- 51609 int
- 51610 scanf(const char *format, ...)
- 51611 {
- 51612 va_list ap;
- 51613 int retval;
- 51614
- 51615 va_start(ap, format);
- 51616
- 51617 retval = _doscan(stdin, format, ap);
- 51618
- 51619 va_end(ap);
- 51620
- 51621 return retval;
- 51622 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/setbuf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51700 /*
- 51701 * setbuf.c - control buffering of a stream
- 51702 */
- 51703 /* $Header: setbuf.c,v 1.2 89/06/26 10:36:22 eck Exp $ */
- 51704
- 51705 #include <stdio.h>
- 51706 #include "loc_incl.h"
- 51707
- 51708 void
- 51709 setbuf(register FILE *stream, char *buf)
- 51710 {
- 51711 (void) setvbuf(stream, buf, (buf ? _IOFBF : _IONBF), (size_t) BUFSIZ);
- 51712 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/setvbuf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51800 /*
- 51801 * setbuf.c - control buffering of a stream
- 51802 */
- 51803 /* $Id: setvbuf.c,v 1.8 1995/12/18 11:02:18 ceriel Exp $ */
- 51804
- 51805 #include <stdio.h>
- 51806 #include <stdlib.h>
- 51807 #include "loc_incl.h"
- 51808
- 51809 extern void (*_clean)(void);
- 51810
- 51811 int
- 51812 setvbuf(register FILE *stream, char *buf, int mode, size_t size)
- 51813 {
- 51814 int retval = 0;
- 51815
- 51816 _clean = __cleanup;
- 51817 if (mode != _IOFBF && mode != _IOLBF && mode != _IONBF)
- 51818 return EOF;
- 51819
- 51820 if (stream->_buf && io_testflag(stream,_IOMYBUF) )
- 51821 free((void *)stream->_buf);
- 51822
- 51823 stream->_flags &= ~(_IOMYBUF | _IONBF | _IOLBF);
- 51824
- 51825 if (buf && size <= 0) retval = EOF;
- 51826 if (!buf && (mode != _IONBF)) {
- 51827 if (size <= 0 || (buf = (char *) malloc(size)) == NULL) {
- 51828 retval = EOF;
- 51829 } else {
- 51830 stream->_flags |= _IOMYBUF;
- 51831 }
- 51832 }
- 51833
- 51834 stream->_buf = (unsigned char *) buf;
- 51835
- 51836 stream->_count = 0;
- 51837 stream->_flags |= mode;
- 51838 stream->_ptr = stream->_buf;
- 51839
- 51840 if (!buf) {
- 51841 stream->_bufsiz = 1;
- 51842 } else {
- 51843 stream->_bufsiz = size;
- 51844 }
- 51845
- 51846 return retval;
- 51847 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/sprintf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 51900 /*
- 51901 * sprintf - print formatted output on an array
- 51902 */
- 51903 /* $Header: sprintf.c,v 1.2 89/12/18 15:03:52 eck Exp $ */
- 51904
- 51905 #include <stdio.h>
- 51906 #include <stdarg.h>
- 51907 #include "loc_incl.h"
- 51908
- 51909 int
- 51910 sprintf(char * s, const char *format, ...)
- 51911 {
- 51912 va_list ap;
- 51913 int retval;
- 51914 FILE tmp_stream;
- 51915
- 51916 va_start(ap, format);
- 51917
- 51918 tmp_stream._fd = -1;
- 51919 tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING;
- 51920 tmp_stream._buf = (unsigned char *) s;
- 51921 tmp_stream._ptr = (unsigned char *) s;
- 51922 tmp_stream._count = 32767;
- 51923
- 51924 retval = _doprnt(format, ap, &tmp_stream);
- 51925 putc(' ',&tmp_stream);
- 51926
- 51927 va_end(ap);
- 51928
- 51929 return retval;
- 51930 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/sscanf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52000 /*
- 52001 * sscanf - read formatted output from a string
- 52002 */
- 52003 /* $Header: sscanf.c,v 1.3 90/09/26 13:17:39 eck Exp $ */
- 52004
- 52005 #include <stdio.h>
- 52006 #include <stdarg.h>
- 52007 #include <string.h>
- 52008 #include "loc_incl.h"
- 52009
- 52010 int sscanf(const char *s, const char *format, ...)
- 52011 {
- 52012 va_list ap;
- 52013 int retval;
- 52014 FILE tmp_stream;
- 52015
- 52016 va_start(ap, format);
- 52017
- 52018 tmp_stream._fd = -1;
- 52019 tmp_stream._flags = _IOREAD + _IONBF + _IOREADING;
- 52020 tmp_stream._buf = (unsigned char *) s;
- 52021 tmp_stream._ptr = (unsigned char *) s;
- 52022 tmp_stream._count = strlen(s);
- 52023
- 52024 retval = _doscan(&tmp_stream, format, ap);
- 52025
- 52026 va_end(ap);
- 52027
- 52028 return retval;
- 52029 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/tmpfile.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52100 /*
- 52101 * tmpfile.c - create and open a temporary file
- 52102 */
- 52103 /* $Header: tmpfile.c,v 1.3 90/01/22 11:13:15 eck Exp $ */
- 52104
- 52105 #if defined(_POSIX_SOURCE)
- 52106 #include <sys/types.h>
- 52107 #endif
- 52108 #include <stdio.h>
- 52109 #include <string.h>
- 52110 #include "loc_incl.h"
- 52111
- 52112 pid_t _getpid(void);
- 52113
- 52114 FILE *
- 52115 tmpfile(void) {
- 52116 static char name_buffer[L_tmpnam] = "/tmp/tmp." ;
- 52117 static char *name = NULL;
- 52118 FILE *file;
- 52119
- 52120 if (!name) {
- 52121 name = name_buffer + strlen(name_buffer);
- 52122 name = _i_compute(_getpid(), 10, name, 5);
- 52123 *name = ' ';
- 52124 }
- 52125
- 52126 file = fopen(name_buffer,"wb+");
- 52127 if (!file) return (FILE *)NULL;
- 52128 (void) remove(name_buffer);
- 52129 return file;
- 52130 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/tmpnam.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52200 /*
- 52201 * tmpnam.c - create a unique filename
- 52202 */
- 52203 /* $Header: tmpnam.c,v 1.4 91/02/26 09:28:39 ceriel Exp $ */
- 52204
- 52205 #if defined(_POSIX_SOURCE)
- 52206 #include <sys/types.h>
- 52207 #endif
- 52208 #include <stdio.h>
- 52209 #include <string.h>
- 52210 #include "loc_incl.h"
- 52211
- 52212 pid_t _getpid(void);
- 52213
- 52214 char *
- 52215 tmpnam(char *s) {
- 52216 static char name_buffer[L_tmpnam] = "/tmp/tmp.";
- 52217 static unsigned long count = 0;
- 52218 static char *name = NULL;
- 52219
- 52220 if (!name) {
- 52221 name = name_buffer + strlen(name_buffer);
- 52222 name = _i_compute((unsigned long)_getpid(), 10, name, 5);
- 52223 *name++ = '.';
- 52224 *name = ' ';
- 52225 }
- 52226 if (++count > TMP_MAX) count = 1; /* wrap-around */
- 52227 *_i_compute(count, 10, name, 3) = ' ';
- 52228 if (s) return strcpy(s, name_buffer);
- 52229 else return name_buffer;
- 52230 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/ungetc.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52300 /*
- 52301 * ungetc.c - push a character back onto an input stream
- 52302 */
- 52303 /* $Header: ungetc.c,v 1.3 90/03/28 16:33:05 eck Exp $ */
- 52304
- 52305 #include <stdio.h>
- 52306 #include "loc_incl.h"
- 52307
- 52308 int
- 52309 ungetc(int ch, FILE *stream)
- 52310 {
- 52311 unsigned char *p;
- 52312
- 52313 if (ch == EOF || !io_testflag(stream,_IOREADING))
- 52314 return EOF;
- 52315 if (stream->_ptr == stream->_buf) {
- 52316 if (stream->_count != 0) return EOF;
- 52317 stream->_ptr++;
- 52318 }
- 52319 stream->_count++;
- 52320 p = --(stream->_ptr); /* ??? Bloody vax assembler !!! */
- 52321 /* ungetc() in sscanf() shouldn't write in rom */
- 52322 if (*p != (unsigned char) ch)
- 52323 *p = (unsigned char) ch;
- 52324 return ch;
- 52325 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/vfprintf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52400 /*
- 52401 * vfprintf - formatted output without ellipsis
- 52402 */
- 52403 /* $Header: vfprintf.c,v 1.2 89/12/18 15:04:07 eck Exp $ */
- 52404
- 52405 #include <stdio.h>
- 52406 #include <stdarg.h>
- 52407 #include "loc_incl.h"
- 52408
- 52409 int
- 52410 vfprintf(FILE *stream, const char *format, va_list arg)
- 52411 {
- 52412 return _doprnt (format, arg, stream);
- 52413 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/vprintf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52500 /*
- 52501 * vprintf - formatted output without ellipsis to the standard output stream
- 52502 */
- 52503 /* $Header: vprintf.c,v 1.3 89/12/18 15:04:14 eck Exp $ */
- 52504
- 52505 #include <stdio.h>
- 52506 #include <stdarg.h>
- 52507 #include "loc_incl.h"
- 52508
- 52509 int
- 52510 vprintf(const char *format, va_list arg)
- 52511 {
- 52512 return _doprnt(format, arg, stdout);
- 52513 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/vsprintf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52600 /*
- 52601 * vsprintf - print formatted output without ellipsis on an array
- 52602 */
- 52603 /* $Header: vsprintf.c,v 1.2 90/11/13 10:56:53 eck Exp $ */
- 52604
- 52605 #include <stdio.h>
- 52606 #include <stdarg.h>
- 52607 #include "loc_incl.h"
- 52608
- 52609 int
- 52610 vsprintf(char *s, const char *format, va_list arg)
- 52611 {
- 52612 int retval;
- 52613 FILE tmp_stream;
- 52614
- 52615 tmp_stream._fd = -1;
- 52616 tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING;
- 52617 tmp_stream._buf = (unsigned char *) s;
- 52618 tmp_stream._ptr = (unsigned char *) s;
- 52619 tmp_stream._count = 32767;
- 52620
- 52621 retval = _doprnt(format, arg, &tmp_stream);
- 52622 putc(' ',&tmp_stream);
- 52623
- 52624 return retval;
- 52625 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/vscanf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52700 /*
- 52701 * vscanf.c - read formatted input from the standard input stream
- 52702 */
- 52703
- 52704 #include <stdio.h>
- 52705 #include <stdarg.h>
- 52706 #include "loc_incl.h"
- 52707
- 52708 int
- 52709 vscanf(const char *format, va_list ap)
- 52710 {
- 52711 return _doscan(stdin, format, ap);
- 52712 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/stdio/vsscanf.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52800 /*
- 52801 * vsscanf - read formatted output from a string
- 52802 */
- 52803
- 52804 #include <stdio.h>
- 52805 #include <stdarg.h>
- 52806 #include <string.h>
- 52807 #include "loc_incl.h"
- 52808
- 52809 int vsscanf(const char *s, const char *format, va_list ap)
- 52810 {
- 52811 FILE tmp_stream;
- 52812
- 52813 tmp_stream._fd = -1;
- 52814 tmp_stream._flags = _IOREAD + _IONBF + _IOREADING;
- 52815 tmp_stream._buf = (unsigned char *) s;
- 52816 tmp_stream._ptr = (unsigned char *) s;
- 52817 tmp_stream._count = strlen(s);
- 52818
- 52819 return _doscan(&tmp_stream, format, ap);
- 52820 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/_exit.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 52900 .sect .text
- 52901 .extern ___exit
- 52902 .define __exit
- 52903 .align 2
- 52904
- 52905 __exit:
- 52906 jmp ___exit
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/access.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53000 .sect .text
- 53001 .extern __access
- 53002 .define _access
- 53003 .align 2
- 53004
- 53005 _access:
- 53006 jmp __access
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/alarm.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53100 .sect .text
- 53101 .extern __alarm
- 53102 .define _alarm
- 53103 .align 2
- 53104
- 53105 _alarm:
- 53106 jmp __alarm
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/brk.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53200 .sect .text
- 53201 .extern __brk
- 53202 .define _brk
- 53203 .align 2
- 53204
- 53205 _brk:
- 53206 jmp __brk
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/cfgetispeed.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53300 .sect .text
- 53301 .extern __cfgetispeed
- 53302 .define _cfgetispeed
- 53303 .align 2
- 53304
- 53305 _cfgetispeed:
- 53306 jmp __cfgetispeed
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/cfgetospeed.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53400 .sect .text
- 53401 .extern __cfgetospeed
- 53402 .define _cfgetospeed
- 53403 .align 2
- 53404
- 53405 _cfgetospeed:
- 53406 jmp __cfgetospeed
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/cfsetispeed.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53500 .sect .text
- 53501 .extern __cfsetispeed
- 53502 .define _cfsetispeed
- 53503 .align 2
- 53504
- 53505 _cfsetispeed:
- 53506 jmp __cfsetispeed
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/cfsetospeed.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53600 .sect .text
- 53601 .extern __cfsetospeed
- 53602 .define _cfsetospeed
- 53603 .align 2
- 53604
- 53605 _cfsetospeed:
- 53606 jmp __cfsetospeed
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/chdir.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53700 .sect .text
- 53701 .extern __chdir
- 53702 .define _chdir
- 53703 .align 2
- 53704
- 53705 _chdir:
- 53706 jmp __chdir
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/chmod.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53800 .sect .text
- 53801 .extern __chmod
- 53802 .define _chmod
- 53803 .align 2
- 53804
- 53805 _chmod:
- 53806 jmp __chmod
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/chown.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 53900 .sect .text
- 53901 .extern __chown
- 53902 .define _chown
- 53903 .align 2
- 53904
- 53905 _chown:
- 53906 jmp __chown
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/chroot.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54000 .sect .text
- 54001 .extern __chroot
- 54002 .define _chroot
- 54003 .align 2
- 54004
- 54005 _chroot:
- 54006 jmp __chroot
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/close.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54100 .sect .text
- 54101 .extern __close
- 54102 .define _close
- 54103 .align 2
- 54104
- 54105 _close:
- 54106 jmp __close
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/closedir.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54200 .sect .text
- 54201 .extern __closedir
- 54202 .define _closedir
- 54203 .align 2
- 54204
- 54205 _closedir:
- 54206 jmp __closedir
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/creat.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54300 .sect .text
- 54301 .extern __creat
- 54302 .define _creat
- 54303 .align 2
- 54304
- 54305 _creat:
- 54306 jmp __creat
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/dup.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54400 .sect .text
- 54401 .extern __dup
- 54402 .define _dup
- 54403 .align 2
- 54404
- 54405 _dup:
- 54406 jmp __dup
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/dup2.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54500 .sect .text
- 54501 .extern __dup2
- 54502 .define _dup2
- 54503 .align 2
- 54504
- 54505 _dup2:
- 54506 jmp __dup2
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/execl.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54600 .sect .text
- 54601 .extern __execl
- 54602 .define _execl
- 54603 .align 2
- 54604
- 54605 _execl:
- 54606 jmp __execl
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/execle.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54700 .sect .text
- 54701 .extern __execle
- 54702 .define _execle
- 54703 .align 2
- 54704
- 54705 _execle:
- 54706 jmp __execle
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/execv.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54800 .sect .text
- 54801 .extern __execv
- 54802 .define _execv
- 54803 .align 2
- 54804
- 54805 _execv:
- 54806 jmp __execv
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/execve.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 54900 .sect .text
- 54901 .extern __execve
- 54902 .define _execve
- 54903 .align 2
- 54904
- 54905 _execve:
- 54906 jmp __execve
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/fcntl.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55000 .sect .text
- 55001 .extern __fcntl
- 55002 .define _fcntl
- 55003 .align 2
- 55004
- 55005 _fcntl:
- 55006 jmp __fcntl
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/fork.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55100 .sect .text
- 55101 .extern __fork
- 55102 .define _fork
- 55103 .align 2
- 55104
- 55105 _fork:
- 55106 jmp __fork
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/fpathconf.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55200 .sect .text
- 55201 .extern __fpathconf
- 55202 .define _fpathconf
- 55203 .align 2
- 55204
- 55205 _fpathconf:
- 55206 jmp __fpathconf
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/fstat.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55300 .sect .text
- 55301 .extern __fstat
- 55302 .define _fstat
- 55303 .align 2
- 55304
- 55305 _fstat:
- 55306 jmp __fstat
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/getcwd.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55400 .sect .text
- 55401 .extern __getcwd
- 55402 .define _getcwd
- 55403 .align 2
- 55404
- 55405 _getcwd:
- 55406 jmp __getcwd
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/getegid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55500 .sect .text
- 55501 .extern __getegid
- 55502 .define _getegid
- 55503 .align 2
- 55504
- 55505 _getegid:
- 55506 jmp __getegid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/geteuid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55600 .sect .text
- 55601 .extern __geteuid
- 55602 .define _geteuid
- 55603 .align 2
- 55604
- 55605 _geteuid:
- 55606 jmp __geteuid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/getgid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55700 .sect .text
- 55701 .extern __getgid
- 55702 .define _getgid
- 55703 .align 2
- 55704
- 55705 _getgid:
- 55706 jmp __getgid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/getgroups.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55800 .sect .text
- 55801 .extern __getgroups
- 55802 .define _getgroups
- 55803 .align 2
- 55804
- 55805 _getgroups:
- 55806 jmp __getgroups
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/getpgrp.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 55900 .sect .text
- 55901 .extern __getpgrp
- 55902 .define _getpgrp
- 55903 .align 2
- 55904
- 55905 _getpgrp:
- 55906 jmp __getpgrp
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/getpid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56000 .sect .text
- 56001 .extern __getpid
- 56002 .define _getpid
- 56003 .align 2
- 56004
- 56005 _getpid:
- 56006 jmp __getpid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/getppid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56100 .sect .text
- 56101 .extern __getppid
- 56102 .define _getppid
- 56103 .align 2
- 56104
- 56105 _getppid:
- 56106 jmp __getppid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/getuid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56200 .sect .text
- 56201 .extern __getuid
- 56202 .define _getuid
- 56203 .align 2
- 56204
- 56205 _getuid:
- 56206 jmp __getuid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/ioctl.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56300 .sect .text
- 56301 .extern __ioctl
- 56302 .define _ioctl
- 56303 .align 2
- 56304
- 56305 _ioctl:
- 56306 jmp __ioctl
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/isatty.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56400 .sect .text
- 56401 .extern __isatty
- 56402 .define _isatty
- 56403 .align 2
- 56404
- 56405 _isatty:
- 56406 jmp __isatty
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/kill.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56500 .sect .text
- 56501 .extern __kill
- 56502 .define _kill
- 56503 .align 2
- 56504
- 56505 _kill:
- 56506 jmp __kill
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/link.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56600 .sect .text
- 56601 .extern __link
- 56602 .define _link
- 56603 .align 2
- 56604
- 56605 _link:
- 56606 jmp __link
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/lseek.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56700 .sect .text
- 56701 .extern __lseek
- 56702 .define _lseek
- 56703 .align 2
- 56704
- 56705 _lseek:
- 56706 jmp __lseek
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/mkdir.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56800 .sect .text
- 56801 .extern __mkdir
- 56802 .define _mkdir
- 56803 .align 2
- 56804
- 56805 _mkdir:
- 56806 jmp __mkdir
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/mkfifo.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 56900 .sect .text
- 56901 .extern __mkfifo
- 56902 .define _mkfifo
- 56903 .align 2
- 56904
- 56905 _mkfifo:
- 56906 jmp __mkfifo
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/mknod.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57000 .sect .text
- 57001 .extern __mknod
- 57002 .define _mknod
- 57003 .align 2
- 57004
- 57005 _mknod:
- 57006 jmp __mknod
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/mktemp.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57100 .sect .text
- 57101 .extern __mktemp
- 57102 .define _mktemp
- 57103 .align 2
- 57104
- 57105 _mktemp:
- 57106 jmp __mktemp
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/mount.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57200 .sect .text
- 57201 .extern __mount
- 57202 .define _mount
- 57203 .align 2
- 57204
- 57205 _mount:
- 57206 jmp __mount
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/open.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57300 .sect .text
- 57301 .extern __open
- 57302 .define _open
- 57303 .align 2
- 57304
- 57305 _open:
- 57306 jmp __open
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/opendir.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57400 .sect .text
- 57401 .extern __opendir
- 57402 .define _opendir
- 57403 .align 2
- 57404
- 57405 _opendir:
- 57406 jmp __opendir
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/pathconf.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57500 .sect .text
- 57501 .extern __pathconf
- 57502 .define _pathconf
- 57503 .align 2
- 57504
- 57505 _pathconf:
- 57506 jmp __pathconf
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/pause.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57600 .sect .text
- 57601 .extern __pause
- 57602 .define _pause
- 57603 .align 2
- 57604
- 57605 _pause:
- 57606 jmp __pause
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/pipe.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57700 .sect .text
- 57701 .extern __pipe
- 57702 .define _pipe
- 57703 .align 2
- 57704
- 57705 _pipe:
- 57706 jmp __pipe
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/ptrace.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57800 .sect .text
- 57801 .extern __ptrace
- 57802 .define _ptrace
- 57803 .align 2
- 57804
- 57805 _ptrace:
- 57806 jmp __ptrace
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/read.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 57900 .sect .text
- 57901 .extern __read
- 57902 .define _read
- 57903 .align 2
- 57904
- 57905 _read:
- 57906 jmp __read
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/readdir.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58000 .sect .text
- 58001 .extern __readdir
- 58002 .define _readdir
- 58003 .align 2
- 58004
- 58005 _readdir:
- 58006 jmp __readdir
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/reboot.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58100 .sect .text
- 58101 .extern __reboot
- 58102 .define _reboot
- 58103 .align 2
- 58104
- 58105 _reboot:
- 58106 jmp __reboot
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/rename.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58200 .sect .text
- 58201 .extern __rename
- 58202 .define _rename
- 58203 .align 2
- 58204
- 58205 _rename:
- 58206 jmp __rename
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/rewinddir.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58300 .sect .text
- 58301 .extern __rewinddir
- 58302 .define _rewinddir
- 58303 .align 2
- 58304
- 58305 _rewinddir:
- 58306 jmp __rewinddir
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/rmdir.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58400 .sect .text
- 58401 .extern __rmdir
- 58402 .define _rmdir
- 58403 .align 2
- 58404
- 58405 _rmdir:
- 58406 jmp __rmdir
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sbrk.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58500 .sect .text
- 58501 .extern __sbrk
- 58502 .define _sbrk
- 58503 .align 2
- 58504
- 58505 _sbrk:
- 58506 jmp __sbrk
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/seekdir.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58600 .sect .text
- 58601 .extern __seekdir
- 58602 .define _seekdir
- 58603 .align 2
- 58604
- 58605 _seekdir:
- 58606 jmp __seekdir
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/setgid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58700 .sect .text
- 58701 .extern __setgid
- 58702 .define _setgid
- 58703 .align 2
- 58704
- 58705 _setgid:
- 58706 jmp __setgid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/setsid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58800 .sect .text
- 58801 .extern __setsid
- 58802 .define _setsid
- 58803 .align 2
- 58804
- 58805 _setsid:
- 58806 jmp __setsid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/setuid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 58900 .sect .text
- 58901 .extern __setuid
- 58902 .define _setuid
- 58903 .align 2
- 58904
- 58905 _setuid:
- 58906 jmp __setuid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigaction.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59000 .sect .text
- 59001 .extern __sigaction
- 59002 .define _sigaction
- 59003 .align 2
- 59004
- 59005 _sigaction:
- 59006 jmp __sigaction
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigaddset.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59100 .sect .text
- 59101 .extern __sigaddset
- 59102 .define _sigaddset
- 59103 .align 2
- 59104
- 59105 _sigaddset:
- 59106 jmp __sigaddset
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigdelset.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59200 .sect .text
- 59201 .extern __sigdelset
- 59202 .define _sigdelset
- 59203 .align 2
- 59204
- 59205 _sigdelset:
- 59206 jmp __sigdelset
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigemptyset.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59300 .sect .text
- 59301 .extern __sigemptyset
- 59302 .define _sigemptyset
- 59303 .align 2
- 59304
- 59305 _sigemptyset:
- 59306 jmp __sigemptyset
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigfillset.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59400 .sect .text
- 59401 .extern __sigfillset
- 59402 .define _sigfillset
- 59403 .align 2
- 59404
- 59405 _sigfillset:
- 59406 jmp __sigfillset
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigismember.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59500 .sect .text
- 59501 .extern __sigismember
- 59502 .define _sigismember
- 59503 .align 2
- 59504
- 59505 _sigismember:
- 59506 jmp __sigismember
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigpending.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59600 .sect .text
- 59601 .extern __sigpending
- 59602 .define _sigpending
- 59603 .align 2
- 59604
- 59605 _sigpending:
- 59606 jmp __sigpending
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigprocmask.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59700 .sect .text
- 59701 .extern __sigprocmask
- 59702 .define _sigprocmask
- 59703 .align 2
- 59704
- 59705 _sigprocmask:
- 59706 jmp __sigprocmask
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigreturn.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59800 .sect .text
- 59801 .extern __sigreturn
- 59802 .define _sigreturn
- 59803 .align 2
- 59804
- 59805 _sigreturn:
- 59806 jmp __sigreturn
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sigsuspend.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 59900 .sect .text
- 59901 .extern __sigsuspend
- 59902 .define _sigsuspend
- 59903 .align 2
- 59904
- 59905 _sigsuspend:
- 59906 jmp __sigsuspend
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sleep.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60000 .sect .text
- 60001 .extern __sleep
- 60002 .define _sleep
- 60003 .align 2
- 60004
- 60005 _sleep:
- 60006 jmp __sleep
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/stat.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60100 .sect .text
- 60101 .extern __stat
- 60102 .define _stat
- 60103 .align 2
- 60104
- 60105 _stat:
- 60106 jmp __stat
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/stime.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60200 .sect .text
- 60201 .extern __stime
- 60202 .define _stime
- 60203 .align 2
- 60204
- 60205 _stime:
- 60206 jmp __stime
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/sync.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60300 .sect .text
- 60301 .extern __sync
- 60302 .define _sync
- 60303 .align 2
- 60304
- 60305 _sync:
- 60306 jmp __sync
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/tcdrain.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60400 .sect .text
- 60401 .extern __tcdrain
- 60402 .define _tcdrain
- 60403 .align 2
- 60404
- 60405 _tcdrain:
- 60406 jmp __tcdrain
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/tcflow.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60500 .sect .text
- 60501 .extern __tcflow
- 60502 .define _tcflow
- 60503 .align 2
- 60504
- 60505 _tcflow:
- 60506 jmp __tcflow
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/tcflush.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60600 .sect .text
- 60601 .extern __tcflush
- 60602 .define _tcflush
- 60603 .align 2
- 60604
- 60605 _tcflush:
- 60606 jmp __tcflush
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/tcgetattr.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60700 .sect .text
- 60701 .extern __tcgetattr
- 60702 .define _tcgetattr
- 60703 .align 2
- 60704
- 60705 _tcgetattr:
- 60706 jmp __tcgetattr
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/tcsendbreak.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60800 .sect .text
- 60801 .extern __tcsendbreak
- 60802 .define _tcsendbreak
- 60803 .align 2
- 60804
- 60805 _tcsendbreak:
- 60806 jmp __tcsendbreak
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/tcsetattr.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 60900 .sect .text
- 60901 .extern __tcsetattr
- 60902 .define _tcsetattr
- 60903 .align 2
- 60904
- 60905 _tcsetattr:
- 60906 jmp __tcsetattr
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/time.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61000 .sect .text
- 61001 .extern __time
- 61002 .define _time
- 61003 .align 2
- 61004
- 61005 _time:
- 61006 jmp __time
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/times.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61100 .sect .text
- 61101 .extern __times
- 61102 .define _times
- 61103 .align 2
- 61104
- 61105 _times:
- 61106 jmp __times
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/umask.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61200 .sect .text
- 61201 .extern __umask
- 61202 .define _umask
- 61203 .align 2
- 61204
- 61205 _umask:
- 61206 jmp __umask
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/umount.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61300 .sect .text
- 61301 .extern __umount
- 61302 .define _umount
- 61303 .align 2
- 61304
- 61305 _umount:
- 61306 jmp __umount
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/uname.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61400 .sect .text
- 61401 .extern __uname
- 61402 .define _uname
- 61403 .align 2
- 61404
- 61405 _uname:
- 61406 jmp __uname
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/unlink.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61500 .sect .text
- 61501 .extern __unlink
- 61502 .define _unlink
- 61503 .align 2
- 61504
- 61505 _unlink:
- 61506 jmp __unlink
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/utime.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61600 .sect .text
- 61601 .extern __utime
- 61602 .define _utime
- 61603 .align 2
- 61604
- 61605 _utime:
- 61606 jmp __utime
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/wait.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61700 .sect .text
- 61701 .extern __wait
- 61702 .define _wait
- 61703 .align 2
- 61704
- 61705 _wait:
- 61706 jmp __wait
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/waitpid.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61800 .sect .text
- 61801 .extern __waitpid
- 61802 .define _waitpid
- 61803 .align 2
- 61804
- 61805 _waitpid:
- 61806 jmp __waitpid
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syscall/write.s
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 61900 .sect .text
- 61901 .extern __write
- 61902 .define _write
- 61903 .align 2
- 61904
- 61905 _write:
- 61906 jmp __write
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/syslib.h
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62000 /* syslib.h - System library common definitions. */
- 62001
- 62002 #define _SYSTEM
- 62003
- 62004 #include <lib.h>
- 62005 #include <minix/com.h>
- 62006 #include <minix/syslib.h>
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_abort.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62100 #include "syslib.h"
- 62101 #include <stdarg.h>
- 62102 #include <unistd.h>
- 62103
- 62104 PUBLIC int sys_abort(int how, ...)
- 62105 {
- 62106 /* Something awful has happened. Abandon ship. */
- 62107
- 62108 message m;
- 62109 va_list ap;
- 62110
- 62111 va_start(ap, how);
- 62112 if ((m.m1_i1 = how) == RBT_MONITOR) m.m1_p1 = va_arg(ap, char *);
- 62113 va_end(ap);
- 62114
- 62115 return(_taskcall(SYSTASK, SYS_ABORT, &m));
- 62116 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_copy.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62200 #include "syslib.h"
- 62201
- 62202 PUBLIC int sys_copy(src_proc, src_seg, src_vir,
- 62203 dst_proc, dst_seg, dst_vir, bytes)
- 62204 int src_proc; /* source process */
- 62205 int src_seg; /* source segment: T, D, or S */
- 62206 phys_bytes src_vir; /* source virtual address (phys addr for ABS)*/
- 62207 int dst_proc; /* dest process */
- 62208 int dst_seg; /* dest segment: T, D, or S */
- 62209 phys_bytes dst_vir; /* dest virtual address (phys addr for ABS) */
- 62210 phys_bytes bytes; /* how many bytes */
- 62211 {
- 62212 /* Transfer a block of data. The source and destination can each either be a
- 62213 * process (including MM) or absolute memory, indicate by setting 'src_proc'
- 62214 * or 'dst_proc' to ABS.
- 62215 */
- 62216
- 62217 message copy_mess;
- 62218
- 62219 if (bytes == 0L) return(OK);
- 62220 copy_mess.SRC_SPACE = src_seg;
- 62221 copy_mess.SRC_PROC_NR = src_proc;
- 62222 copy_mess.SRC_BUFFER = (long) src_vir;
- 62223
- 62224 copy_mess.DST_SPACE = dst_seg;
- 62225 copy_mess.DST_PROC_NR = dst_proc;
- 62226 copy_mess.DST_BUFFER = (long) dst_vir;
- 62227
- 62228 copy_mess.COPY_BYTES = (long) bytes;
- 62229 return(_taskcall(SYSTASK, SYS_COPY, ©_mess));
- 62230 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_endsig.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62300 #include "syslib.h"
- 62301
- 62302 PUBLIC int sys_endsig(proc)
- 62303 int proc;
- 62304 {
- 62305 message m;
- 62306
- 62307 m.m1_i1 = proc;
- 62308 return(_taskcall(SYSTASK, SYS_ENDSIG, &m));
- 62309 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_exec.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62400 #include "syslib.h"
- 62401
- 62402 PUBLIC int sys_exec(proc, ptr, traced, prog_name, initpc)
- 62403 int proc; /* process that did exec */
- 62404 char *ptr; /* new stack pointer */
- 62405 int traced; /* is tracing enabled? */
- 62406 char *prog_name; /* name of the new program */
- 62407 vir_bytes initpc;
- 62408 {
- 62409 /* A process has exec'd. Tell the kernel. */
- 62410
- 62411 message m;
- 62412
- 62413 m.m1_i1 = proc;
- 62414 m.m1_i2 = traced;
- 62415 m.m1_p1 = ptr;
- 62416 m.m1_p2 = prog_name;
- 62417 m.m1_p3 = (char *)initpc;
- 62418 return(_taskcall(SYSTASK, SYS_EXEC, &m));
- 62419 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_fork.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62500 #include "syslib.h"
- 62501
- 62502 PUBLIC int sys_fork(parent, child, pid, child_base_or_shadow)
- 62503 int parent; /* process doing the fork */
- 62504 int child; /* which proc has been created by the fork */
- 62505 int pid; /* process id assigned by MM */
- 62506 phys_clicks child_base_or_shadow; /* position for child [VM386];
- 62507 * memory allocated for shadow [68000] */
- 62508 {
- 62509 /* A process has forked. Tell the kernel. */
- 62510
- 62511 message m;
- 62512
- 62513 m.m1_i1 = parent;
- 62514 m.m1_i2 = child;
- 62515 m.m1_i3 = pid;
- 62516 m.m1_p1 = (char *) child_base_or_shadow;
- 62517 return(_taskcall(SYSTASK, SYS_FORK, &m));
- 62518 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_fresh.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62600 #include "syslib.h"
- 62601
- 62602 PUBLIC int sys_fresh(proc, ptr, dc, basep, sizep)
- 62603 int proc; /* process whose map is to be changed */
- 62604 struct mem_map *ptr; /* pointer to new map */
- 62605 phys_clicks dc; /* size of initialized data */
- 62606 phys_clicks *basep, *sizep; /* base and size for free_mem() */
- 62607 {
- 62608 /* Create a fresh process image for exec(). Tell the kernel. */
- 62609
- 62610 message m;
- 62611 int r;
- 62612
- 62613 m.m1_i1 = proc;
- 62614 m.m1_i2 = (int) dc;
- 62615 m.m1_p1 = (char *) ptr;
- 62616 r = _taskcall(SYSTASK, SYS_FRESH, &m);
- 62617 *basep = (phys_clicks) m.m1_i1;
- 62618 *sizep = (phys_clicks) m.m1_i2;
- 62619 return(r);
- 62620 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_getmap.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62700 #include "syslib.h"
- 62701
- 62702 PUBLIC int sys_getmap(proc, ptr)
- 62703 int proc; /* process whose map is to be fetched */
- 62704 struct mem_map *ptr; /* pointer to new map */
- 62705 {
- 62706 /* Want to know map of a process, ask the kernel. */
- 62707
- 62708 message m;
- 62709
- 62710 m.m1_i1 = proc;
- 62711 m.m1_p1 = (char *) ptr;
- 62712 return(_taskcall(SYSTASK, SYS_GETMAP, &m));
- 62713 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_getsp.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62800 #include "syslib.h"
- 62801
- 62802 PUBLIC int sys_getsp(proc, newsp)
- 62803 int proc; /* process whose sp is wanted */
- 62804 vir_bytes *newsp; /* place to put sp read from kernel */
- 62805 {
- 62806 /* Ask the kernel what the sp is. */
- 62807
- 62808 message m;
- 62809 int r;
- 62810
- 62811 m.m1_i1 = proc;
- 62812 r = _taskcall(SYSTASK, SYS_GETSP, &m);
- 62813 *newsp = (vir_bytes) m.STACK_PTR;
- 62814 return(r);
- 62815 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_kill.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 62900 #include "syslib.h"
- 62901
- 62902 PUBLIC int sys_kill(proc, signr)
- 62903 int proc; /* which proc has exited */
- 62904 int signr; /* signal number: 1 - 16 */
- 62905 {
- 62906 /* A proc has to be signaled via MM. Tell the kernel. */
- 62907 message m;
- 62908
- 62909 m.m6_i1 = proc;
- 62910 m.m6_i2 = signr;
- 62911 return(_taskcall(SYSTASK, SYS_KILL, &m));
- 62912 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_newmap.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 63000 #include "syslib.h"
- 63001
- 63002 PUBLIC int sys_newmap(proc, ptr)
- 63003 int proc; /* process whose map is to be changed */
- 63004 struct mem_map *ptr; /* pointer to new map */
- 63005 {
- 63006 /* A process has been assigned a new memory map. Tell the kernel. */
- 63007
- 63008 message m;
- 63009
- 63010 m.m1_i1 = proc;
- 63011 m.m1_p1 = (char *) ptr;
- 63012 return(_taskcall(SYSTASK, SYS_NEWMAP, &m));
- 63013 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_oldsig.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 63100 #include "syslib.h"
- 63101
- 63102 PUBLIC int sys_oldsig(proc, sig, sighandler)
- 63103 int proc; /* process to be signaled */
- 63104 int sig; /* signal number: 1 to _NSIG */
- 63105 sighandler_t sighandler; /* pointer to signal handler in user space */
- 63106 {
- 63107 /* A proc has to be signaled. Tell the kernel. This function is obsolete. */
- 63108
- 63109 message m;
- 63110
- 63111 m.m6_i1 = proc;
- 63112 m.m6_i2 = sig;
- 63113 m.m6_f1 = sighandler;
- 63114 return(_taskcall(SYSTASK, SYS_OLDSIG, &m));
- 63115 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_sendsig.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 63200 #include "syslib.h"
- 63201
- 63202 PUBLIC int sys_sendsig(proc, smp)
- 63203 int proc;
- 63204 struct sigmsg *smp;
- 63205 {
- 63206 message m;
- 63207
- 63208 m.m1_i1 = proc;
- 63209 m.m1_p1 = (char *) smp;
- 63210 return(_taskcall(SYSTASK, SYS_SENDSIG, &m));
- 63211 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_sigret.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 63300 #include "syslib.h"
- 63301
- 63302 PUBLIC int sys_sigreturn(proc, scp, flags)
- 63303 int proc;
- 63304 vir_bytes scp;
- 63305 int flags;
- 63306 {
- 63307 message m;
- 63308
- 63309 m.m1_i1 = proc;
- 63310 m.m1_i2 = flags;
- 63311 m.m1_p1 = (char *) scp;
- 63312 return(_taskcall(SYSTASK, SYS_SIGRETURN, &m));
- 63313 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_times.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 63400 #include "syslib.h"
- 63401
- 63402 PUBLIC int sys_times(proc, ptr)
- 63403 int proc; /* proc whose times are needed */
- 63404 clock_t ptr[5]; /* pointer to time buffer */
- 63405 {
- 63406 /* Fetch the accounting info for a proc. */
- 63407 message m;
- 63408 int r;
- 63409
- 63410 m.m1_i1 = proc;
- 63411 m.m1_p1 = (char *)ptr;
- 63412 r = _taskcall(SYSTASK, SYS_TIMES, &m);
- 63413 ptr[0] = m.USER_TIME;
- 63414 ptr[1] = m.SYSTEM_TIME;
- 63415 ptr[2] = m.CHILD_UTIME;
- 63416 ptr[3] = m.CHILD_STIME;
- 63417 ptr[4] = m.BOOT_TICKS;
- 63418 return(r);
- 63419 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_trace.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 63500 #include "syslib.h"
- 63501
- 63502 PUBLIC int sys_trace(req, procnr, addr, data_p)
- 63503 int req, procnr;
- 63504 long addr, *data_p;
- 63505 {
- 63506 message m;
- 63507 int r;
- 63508
- 63509 m.m2_i1 = procnr;
- 63510 m.m2_i2 = req;
- 63511 m.m2_l1 = addr;
- 63512 if (data_p) m.m2_l2 = *data_p;
- 63513 r = _taskcall(SYSTASK, SYS_TRACE, &m);
- 63514 if (data_p) *data_p = m.m2_l2;
- 63515 return(r);
- 63516 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/sys_xit.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 63600 #include "syslib.h"
- 63601
- 63602 PUBLIC int sys_xit(parent, proc, basep, sizep)
- 63603 int parent; /* parent of exiting process */
- 63604 int proc; /* which process has exited */
- 63605 phys_clicks *basep; /* where to return base of shadow [68000] */
- 63606 phys_clicks *sizep; /* where to return size of shadow [68000] */
- 63607 {
- 63608 /* A process has exited. Tell the kernel. */
- 63609
- 63610 message m;
- 63611 int r;
- 63612
- 63613 m.m1_i1 = parent;
- 63614 m.m1_i2 = proc;
- 63615 r = _taskcall(SYSTASK, SYS_XIT, &m);
- 63616 *basep = (phys_clicks) m.m1_i1;
- 63617 *sizep = (phys_clicks) m.m1_i2;
- 63618 return(r);
- 63619 }
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- src/lib/syslib/taskcall.c
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 63700 /* _taskcall() is the same as _syscall() except it returns negative error
- 63701 * codes directly and not in errno. This is a better interface for MM and
- 63702 * FS.
- 63703 */
- 63704
- 63705 #include <lib.h>
- 63706 #include <minix/syslib.h>
- 63707
- 63708 PUBLIC int _taskcall(who, syscallnr, msgptr)
- 63709 int who;
- 63710 int syscallnr;
- 63711 register message *msgptr;
- 63712 {
- 63713 int status;
- 63714
- 63715 msgptr->m_type = syscallnr;
- 63716 status = _sendrec(who, msgptr);
- 63717 if (status != 0) return(status);
- 63718 return(msgptr->m_type);
- 63719 }