2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)flag.c 2.10 05/06/12 Copyright 1986-2003 J. Schilling */
15 * Copyright (c) 1986-2003 J. Schilling
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License version 2
20 * as published by the Free Software Foundation.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License along with
28 * this program; see the file COPYING. If not, write to the Free Software
29 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 EXPORT int _io_glflag; /* global default flag */
40 LOCAL int _fl_inc = 10; /* increment for expanding flag struct */
41 EXPORT int _fl_max = FL_INIT; /* max fd currently in _io_myfl */
42 LOCAL _io_fl _io_smyfl[FL_INIT]; /* initial static space */
43 EXPORT _io_fl *_io_myfl = _io_smyfl; /* init to static space */
45 LOCAL int _more_flags __PR((FILE *));
51 register int f = fileno(fp);
52 register int n = _fl_max;
58 if (_io_myfl == _io_smyfl) {
59 np = (_io_fl *) malloc(n * sizeof (*np));
60 fillbytes(np, n * sizeof (*np), '\0');
61 movebytes(_io_smyfl, np, sizeof (_io_smyfl)/sizeof (*np));
63 np = (_io_fl *) realloc(_io_myfl, n * sizeof (*np));
65 fillbytes(&np[_fl_max], (n-_fl_max)*sizeof (*np), '\0');
70 return (_io_get_my_flag(fp));
80 register int f = fileno(fp);
84 return (_more_flags(fp));
88 if (fl->fl_io == 0 || fl->fl_io == fp)
89 return (fl->fl_flags);
91 while (fl && fl->fl_io != fp)
97 return (fl->fl_flags);
101 _io_set_my_flag(fp, flag)
105 register int f = fileno(fp);
107 register _io_fl *fl2;
110 (void) _more_flags(fp);
114 if (fl->fl_io != (FILE *)0) {
117 while (fl && fl->fl_io != fp)
120 if ((fl = (_io_fl *) malloc(sizeof (*fl))) == 0)
122 fl->fl_next = fl2->fl_next;
131 _io_add_my_flag(fp, flag)
135 int oflag = _io_get_my_flag(fp);
139 _io_set_my_flag(fp, oflag);
142 #endif /* DO_MYFLAG */