Annotation of coherent/a/usr/man/ALL/freopen, revision 1.1

1.1     ! root        1: 
        !             2: 
        !             3: freopen()                 STDIO Function                freopen()
        !             4: 
        !             5: 
        !             6: 
        !             7: 
        !             8: Open file stream for standard I/O
        !             9: 
        !            10: #iinncclluuddee <ssttddiioo.hh>
        !            11: FFIILLEE *ffrreeooppeenn (_n_a_m_e, _t_y_p_e, _f_p)
        !            12: cchhaarr *_n_a_m_e, *_t_y_p_e; FFIILLEE *_f_p;
        !            13: 
        !            14: ffrreeooppeenn  reinitializes the  file stream fp.   It closes  the file
        !            15: currently associated with it, opens or creates the file name, and
        !            16: returns  a  pointer  to the  structure  for  use  by other  STDIO
        !            17: routines.  name names a file.
        !            18: 
        !            19: _t_y_p_e is a  string that consists of one or  more of the characters
        !            20: ``rrwwaa'' (for, respectively, read, write, and append)  to indicate
        !            21: the mode of the stream.  For further discussion of the type vari-
        !            22: able, see  the entry for fopen.  freopen  differs from fopen only
        !            23: in  that  fp  specifies  the  stream  to  be  used.   Any  stream
        !            24: previously associated  with fp is  closed by ffcclloossee.   ffrreeooppeenn is
        !            25: usually used to change the meaning of ssttddiinn, ssttddoouutt, or ssttddeerrrr.
        !            26: 
        !            27: ***** Example *****
        !            28: 
        !            29: This example,  called mmaattcchh.cc, looks  in aarrggvv[22] for  the pattern
        !            30: given by  aarrggvv[11].  If the  pattern is found, the  line that con-
        !            31: tains the pattern is written into the file aarrggvv[33] or to ssttddoouutt.
        !            32: 
        !            33: 
        !            34: #include <stdio.h>
        !            35: #define MAXLINE 128
        !            36: char buffer[MAXLINE];
        !            37: 
        !            38: 
        !            39: 
        !            40: void fatal(message)
        !            41: char *message;
        !            42: {
        !            43:         fprintf(stderr, "match: %s\n", message);
        !            44:         exit(1);
        !            45: }
        !            46: 
        !            47: 
        !            48: 
        !            49: main(argc,argv)
        !            50: int argc; char *argv[];
        !            51: {
        !            52:         FILE *fpin, *fpout;
        !            53: 
        !            54: 
        !            55: 
        !            56:         if (argc != 3 && argc != 4)
        !            57:                 fatal("Usage: match pattern infile [outfile]");
        !            58:         if ((fpin = fopen(argv[2], "r")) == NULL)
        !            59:                 fatal("Cannot open input file");
        !            60: 
        !            61: 
        !            62: 
        !            63: 
        !            64: COHERENT Lexicon                                           Page 1
        !            65: 
        !            66: 
        !            67: 
        !            68: 
        !            69: freopen()                 STDIO Function                freopen()
        !            70: 
        !            71: 
        !            72: 
        !            73: 
        !            74: 
        !            75:         fpout = stdout;
        !            76:         if (argc == 4)
        !            77:                 if ((fpout = freopen(argv[3], "w", stdout)) == NULL)
        !            78:                         fatal("Cannot open output file");
        !            79: 
        !            80: 
        !            81: 
        !            82:         while (fgets(buffer, MAXLINE, fpin) != NULL) {
        !            83:                 if (pnmatch(buffer, argv[1], 1))
        !            84:                         fputs(buffer, stdout);
        !            85:         }
        !            86:         exit(0);
        !            87: }
        !            88: 
        !            89: 
        !            90: ***** See Also *****
        !            91: 
        !            92: fopen(), STDIO
        !            93: 
        !            94: ***** Diagnostics *****
        !            95: 
        !            96: freopen returns  NULL if  the type string  is nonsense or  if the
        !            97: file cannot be opened.  Currently, only 20 FFIILLEE structures can be
        !            98: allocated per program, including ssttddiinn, ssttddoouutt, and ssttddeerrrr.
        !            99: 
        !           100: 
        !           101: 
        !           102: 
        !           103: 
        !           104: 
        !           105: 
        !           106: 
        !           107: 
        !           108: 
        !           109: 
        !           110: 
        !           111: 
        !           112: 
        !           113: 
        !           114: 
        !           115: 
        !           116: 
        !           117: 
        !           118: 
        !           119: 
        !           120: 
        !           121: 
        !           122: 
        !           123: 
        !           124: 
        !           125: 
        !           126: 
        !           127: 
        !           128: 
        !           129: 
        !           130: COHERENT Lexicon                                           Page 2
        !           131: 
        !           132: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.