# 2.11BSD#431 - /usr/src/lib/libc/stdio/freopen.c

##### Functions

    freopen           X

       1: /*
       2:  * Copyright (c) 1980 Regents of the University of California.
       3:  * All rights reserved.  The Berkeley software License Agreement
       4:  * specifies the terms and conditions for redistribution.
       5:  */
       6:
       7: #if defined(LIBC_SCCS) && !defined(lint)
       8: static char sccsid[] = "@(#)freopen.c	5.2 (Berkeley) 3/9/86";
       9: #endif LIBC_SCCS and not lint
      10:
      11: #include <sys/types.h>
      12: #include <sys/file.h>
      13: #include <stdio.h>
      14:
      15: FILE *
      16: freopen(file, mode, iop)
      17:     char *file;
      18:     register char *mode;
      19:     register FILE *iop;
      20: {
      21:     register f, rw, oflags;
      22:
      23:     rw = (mode[1] == '+');
      24:
      25:     fclose(iop);
      26:
      27:     switch (*mode) {
      28:     case 'a':
      29:         oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
      30:         break;
      31:     case 'r':
      32:         oflags = rw ? O_RDWR : O_RDONLY;
      33:         break;
      34:     case 'w':
      35:         oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
      36:         break;
      37:     default:
      38:         return (NULL);
      39:     }
      40:
      41:     f = open(file, oflags, 0666);
      42:     if (f < 0)
      43:         return (NULL);
      44:
      45:     if (*mode == 'a')
      46:         lseek(f, (off_t)0, L_XTND);
      47:
      48:     iop->_cnt = 0;
      49:     iop->_file = f;
      50:     iop->_bufsiz = 0;
      51:     if (rw)
      52:         iop->_flag = _IORW;
      53:     else if (*mode == 'r')
      54:         iop->_flag = _IOREAD;
      55:     else
      56:         iop->_flag = _IOWRT;
      57:     iop->_base = iop->_ptr = NULL;
      58:     return (iop);
      59: }

#### Defined functions

freopen defined in line 15; used 125 times

- in /usr/include/stdio.h line 70
- in /usr/ingres/source/monitor/clear.c line 20
- in /usr/ingres/source/monitor/eval.c line 36, 61
- in /usr/ingres/source/support/creatdb.c line 385, 468
- in /usr/ingres/source/support/usersetup.c line 79
- in /usr/src/bin/chpass/chpass.c line 177
- in /usr/src/bin/grep.c line 297
- in /usr/src/bin/od.c line 295
- in /usr/src/bin/passwd/passwd.c line 103
- in /usr/src/bin/tar.c line 345
- in /usr/src/bin/tcsh/mkprstr.c line 79-81(2)
- in /usr/src/bin/wall.c line 82
- in /usr/src/games/battlestar/mkstr.c line 85-87(2)
- in /usr/src/include/stdio.h line 57
- in /usr/src/lib/c2/c20.c line 98, 105
- in /usr/src/lib/ccom/c00.c line 77-82(2)
- in /usr/src/lib/ccom/c10.c line 51-56(2), 75
- in /usr/src/lib/ccom/cvopt.c line 52-57(2), 87, 95
- in /usr/src/lib/cpp/cpp.c line 1065
- in /usr/src/lib/mip/reader.c line 147
- in /usr/src/lib/mip/scan.c line 138
- in /usr/src/libexec/ftpd/ftpd.c line 73, 217
- in /usr/src/libexec/getNAME/getNAME.c line 46
- in /usr/src/local/zmodem/rz.c line 346
- in /usr/src/local/zmodem/sz.c line 522
- in /usr/src/new/PORT/hexdump/display.c line 276
- in /usr/src/new/l11/pass2.c line 845, 862
- in /usr/src/new/m11/macxrf.c line 107
- in /usr/src/new/nntp/inews/inews.c line 54
- in /usr/src/new/notes/src/gtext.c line 97-101(2)
- in /usr/src/new/pathalias/arpatxt.c line 118
- in /usr/src/new/pathalias/main.c line 127
- in /usr/src/new/pathalias/makedb.c line 93
- in /usr/src/new/pathalias/parse.y line 414-419(2)
- in /usr/src/old/512dumpdir.c line 172
- in /usr/src/old/dump/dumpdir.c line 84
- in /usr/src/old/num.c line 38
- in /usr/src/old/shortc/shortc.c line 108
- in /usr/src/sbin/dump/dumpdir.c line 92
- in /usr/src/ucb/PORT/pascal/pdx/process/resume.c line 162
- in /usr/src/ucb/PORT/pascal/px/utilities.c line 52
- in /usr/src/ucb/PORT/pascal/pxp/main.c line 199
- in /usr/src/ucb/PORT/pascal/pxp/yymain.c line 104-108(2)
- in /usr/src/ucb/PORT/pascal/utilities/pmerge.c line 105, 399
- in /usr/src/ucb/compress/compress.c line 564, 598, 658
- in /usr/src/ucb/error/errorfilter.c line 75
- in /usr/src/ucb/error/errormain.c line 221-223(2)
- in /usr/src/ucb/expand.c line 38
- in /usr/src/ucb/finger/finger.c line 124, 216
- in /usr/src/ucb/fold.c line 47
- in /usr/src/ucb/from.c line 59
- in /usr/src/ucb/head.c line 47
- in /usr/src/ucb/logger.c line 79
- in /usr/src/ucb/man/apropos.c line 103
- in /usr/src/ucb/mkstr.c line 79-81(2)
- in /usr/src/ucb/pascal/px/gather.c line 83, 106
- in /usr/src/ucb/sccs.c line 1213-1218(2)
- in /usr/src/ucb/sendbug/bugfiler.c line 99
- in /usr/src/ucb/strings.c line 68
- in /usr/src/ucb/unexpand.c line 43
- in /usr/src/ucb/vacation.c line 345-348(2)
- in /usr/src/ucb/vgrind/vfontedpr.c line 186
- in /usr/src/ucb/what.c line 33
- in /usr/src/ucb/xstr.c line 83-85(2)
- in /usr/src/usr.bin/f77/driver.c line 621-623(2)
- in /usr/src/usr.bin/lint/lpass2.c line 106
- in /usr/src/usr.bin/refer/hunt7.c line 67
- in /usr/src/usr.bin/spell/spellin.c line 36
- in /usr/src/usr.bin/tc.c line 90
- in /usr/src/usr.bin/tk.c line 62, 211-212(2)
- in /usr/src/usr.bin/uniq.c line 35-39(2)
- in /usr/src/usr.bin/uucp/cico.c line 862
- in /usr/src/usr.bin/uucp/uusend.c line 91
- in /usr/src/usr.lib/libF77/mkvers.c line 52
- in /usr/src/usr.lib/libI77/mkvers.c line 52
- in /usr/src/usr.lib/libI77/open.c line 104
- in /usr/src/usr.lib/libI77/util.c line 39
- in /usr/src/usr.lib/libU77/mkvers.c line 52
- in /usr/src/usr.sbin/htable/htable.c line 74
- in /usr/src/usr.sbin/lpr/filters/lpf.c line 177
- in /usr/src/usr.sbin/lpr/filters/vpf.c line 92
- in /usr/src/usr.sbin/lpr/filters/vpsf.c line 108
- in /usr/src/usr.sbin/named/named/ns_main.c line 962
- in /usr/src/usr.sbin/sendmail.MX/aux/newaliases.c line 88
- in /usr/src/usr.sbin/sendmail.MX/src/collect.c line 246, 252
- in /usr/src/usr.sbin/sendmail.MX/src/main.c line 1017
- in /usr/src/usr.sbin/sendmail.MX/src/savemail.c line 169
- in /usr/src/usr.sbin/sendmail.MX/src/srvrsmtp.c line 345
- in /usr/src/usr.sbin/sendmail/aux/newaliases.c line 88
- in /usr/src/usr.sbin/sendmail/src/collect.c line 240, 246
- in /usr/src/usr.sbin/sendmail/src/main.c line 1021
- in /usr/src/usr.sbin/sendmail/src/savemail.c line 163
- in /usr/src/usr.sbin/sendmail/src/srvrsmtp.c line 335

#### Defined variables

sccsid defined in line 8; never used

Last modified: 1986-03-10 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 502 |