~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to tools/sfio/features/stdio

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
################################################################
 
2
## Need to hide certain names such as _doprnt, _doscan
 
3
################################################################
 
4
 
 
5
#pragma weak note{ compile system supports symbol transform }end link{
 
6
#       main() { return _xyz(); }
 
7
#       #pragma weak   _xyz =  __xyz
 
8
#       #define         _xyz    __xyz
 
9
#       _xyz() { return 0; }
 
10
#}end
 
11
 
 
12
################################################################
 
13
## To emulate old-style stdio at binary level
 
14
################################################################
 
15
 
 
16
tst - output{
 
17
        #include        <stdio.h>
 
18
        main() { printf("#define _siz_fpos_t    %d\n", sizeof(fpos_t)); exit(0); }
 
19
}end
 
20
 
 
21
FILE _cnt note{ field FILE.__cnt exists }end compile{
 
22
        #include        <stdio.h>
 
23
        main() { return (stdin->__cnt == 0) ? 0 : -1; }
 
24
}end
 
25
FILE _ptr note{ field FILE.__ptr exists }end compile{
 
26
        #include        <stdio.h>
 
27
        main() { return (stdin->__ptr == 0) ? 0 : -1; }
 
28
}end
 
29
FILE _file note{ field FILE.__file exists }end compile{
 
30
        #include        <stdio.h>
 
31
        main() { return (stdin->__file == 0) ? 0 : -1; }
 
32
}end
 
33
FILE _flag note{ field FILE.__flag exists }end compile{
 
34
        #include        <stdio.h>
 
35
        main() { return (stdin->__flag == 0) ? 0 : -1; }
 
36
}end
 
37
 
 
38
FILE cnt note{ field FILE._cnt exists }end compile{
 
39
        #include        <stdio.h>
 
40
        main() { return (stdin->_cnt == 0) ? 0 : -1; }
 
41
}end
 
42
FILE ptr note{ field FILE._ptr exists }end compile{
 
43
        #include        <stdio.h>
 
44
        main() { return (stdin->_ptr == 0) ? 0 : -1; }
 
45
}end
 
46
FILE file note{ field FILE._file exists }end compile{
 
47
        #include        <stdio.h>
 
48
        main() { return (stdin->_file == 0) ? 0 : -1; }
 
49
}end
 
50
FILE flag note{ field FILE._flag exists }end compile{
 
51
        #include        <stdio.h>
 
52
        main() { return (stdin->_flag == 0) ? 0 : -1; }
 
53
}end
 
54
FILE flags note{ field FILE._flags exists }end compile{
 
55
        #include        <stdio.h>
 
56
        main() { return (stdin->_flags == 0) ? 0 : -1; }
 
57
}end
 
58
 
 
59
cat{
 
60
        #if _FILE__cnt && ! _FILE_cnt
 
61
        #define _FILE_cnt       1
 
62
        #define _cnt            __cnt
 
63
        #endif
 
64
        #if _FILE__ptr && ! _FILE_ptr
 
65
        #define _FILE_ptr       1
 
66
        #define _ptr            __ptr
 
67
        #endif
 
68
        #if _FILE__flag && ! _FILE_flag
 
69
        #define _FILE_flag      1
 
70
        #define _flag           __flag
 
71
        #endif
 
72
        #if _FILE__file && ! _FILE_file
 
73
        #define _FILE_file      1
 
74
        #define _file           __file
 
75
        #endif
 
76
}end
 
77
 
 
78
############################################################################
 
79
# To emulate Linux-stdio at binary level
 
80
############################################################################
 
81
FILE readptr note{ fields FILE._IO_read_ptr/end exist }end execute{
 
82
        #include        <stdio.h>
 
83
        main()
 
84
        { if(sizeof(stdin->_IO_read_ptr) != sizeof(char*) ) return 1;
 
85
          if(sizeof(stdin->_IO_read_end) != sizeof(char*) ) return 1;
 
86
          return 0;
 
87
        }
 
88
}end
 
89
FILE writeptr note{ fields FILE._IO_write_ptr/end exist }end execute{
 
90
        #include        <stdio.h>
 
91
        main()
 
92
        { if(sizeof(stdin->_IO_write_ptr) != sizeof(char*) ) return 1;
 
93
          if(sizeof(stdin->_IO_write_end) != sizeof(char*) ) return 1;
 
94
          return 0;
 
95
        }
 
96
}end
 
97
FILE flags note{ field FILE._flags exists }end compile{
 
98
        #include        <stdio.h>
 
99
        main()
 
100
        { return stdin->_flags == 0 ? 1 : 0;
 
101
        }
 
102
}end
 
103
FILE fileno note{ field FILE._fileno exists }end compile{
 
104
        #include        <stdio.h>
 
105
        main()
 
106
        { return stdin->_fileno == 0 ? 1 : 0;
 
107
        }
 
108
}end
 
109
u flow note{ uflow() does bump buffer }end execute{
 
110
        #include        <stdio.h>
 
111
        #if _STD_
 
112
        main(int argc, char** argv)
 
113
        #else
 
114
        main(argc,argv)
 
115
        int     argc;
 
116
        char**  argv;
 
117
        #endif
 
118
        { FILE* f;
 
119
          char  file[BUFSIZ];
 
120
          sprintf(file,"%s.D",argv[0]);
 
121
          if(!(f = fopen(file,"w+")) )
 
122
                exit(1);
 
123
          unlink(file);
 
124
          setbuf(f,file);
 
125
          fputs("123456789",f);
 
126
          fseek(f,0L,0);
 
127
          if(__uflow(f) == EOF)
 
128
                exit(1);
 
129
          if(*f->_IO_read_ptr == '1')
 
130
                exit(1);
 
131
          else  exit(0);
 
132
        }
 
133
}end
 
134
under flow note{ underflow() does not bump buffer }end execute{
 
135
        #include        <stdio.h>
 
136
        #if _STD_
 
137
        main(int argc, char** argv)
 
138
        #else
 
139
        main(argc,argv)
 
140
        int     argc;
 
141
        char**  argv;
 
142
        #endif
 
143
        { FILE* f;
 
144
          char  file[BUFSIZ];
 
145
          sprintf(file,"%s.D",argv[0]);
 
146
          if(!(f = fopen(file,"w+")) )
 
147
                exit(1);
 
148
          unlink(file);
 
149
          setbuf(f,file);
 
150
          fputs("123456789",f);
 
151
          fseek(f,0L,0);
 
152
          if(__underflow(f) == EOF)
 
153
                exit(1);
 
154
          if(*f->_IO_read_ptr == '1')
 
155
                exit(0);
 
156
          else  exit(1);
 
157
        }
 
158
}end
 
159
 
 
160
######################################################################
 
161
# To emulate BSD-style stdio
 
162
######################################################################
 
163
FILE p  note{ FILE._p field }end compile{
 
164
        #include <stdio.h>
 
165
        main() { return stdin->_p == 0 ? 0 : 1; }
 
166
}end
 
167
FILE r  note{ FILE._r field }end compile{
 
168
        #include <stdio.h>
 
169
        main() { return stdin->_r == 0 ? 0 : 1; }
 
170
}end
 
171
FILE w  note{ FILE._w field }end compile{
 
172
        #include <stdio.h>
 
173
        main() { return stdout->_w == 0 ? 0 : 1; }
 
174
}end
 
175
 
 
176
lib __swbuf
 
177
lib __srget
 
178
 
 
179
lib __uflow
 
180
lib __underflow
 
181
lib __overflow
 
182
 
 
183
lib _IO_getc
 
184
lib _IO_putc
 
185
 
 
186
lib clearerr_unlocked
 
187
lib feof_unlocked
 
188
lib ferror_unlocked
 
189
lib fflush_unlocked
 
190
lib fgetc_unlocked
 
191
lib fgets_unlocked
 
192
lib fileno_unlocked
 
193
lib fputc_unlocked
 
194
lib fputs_unlocked
 
195
lib fread_unlocked
 
196
lib fwrite_unlocked
 
197
lib getc_unlocked
 
198
lib getchar_unlocked
 
199
lib putc_unlocked
 
200
lib putchar_unlocked
 
201
 
 
202
lib __snprintf
 
203
lib __vsnprintf
 
204
 
 
205
# detect microsoft dll declaration of _iob
 
206
mac     _iob    stdio.h
 
207
msft    iob note{ microsoft's oddity }end compile{
 
208
        #include        <stdio.h>
 
209
        #if _mac__iob
 
210
        _CRTIMP extern FILE * __cdecl __p__iob(void);
 
211
        FILE* foo() { return &(_iob[0]); }
 
212
        #else
 
213
        this should fail;
 
214
        #endif
 
215
}end
 
216
 
 
217
dat     _iob,__iob      stdio.h
 
218
native  iob note{ ok to use stdio's _iob }end compile{
 
219
        #define _doprnt         _____doprnt
 
220
        #define _doscan         _____doscan
 
221
        #define fclose          ____fclose
 
222
        #define fdopen          ____fdopen
 
223
        #define fflush          ____fflush
 
224
        #define fgetc           ____fgetc
 
225
        #define fgets           ____fgets
 
226
        #define _filbuf         _____filbuf
 
227
        #define _flsbuf         _____flsbuf
 
228
        #define _cleanup        _____cleanup
 
229
        #define fopen           ____fopen
 
230
        #define fprintf         ____fprintf
 
231
        #define fputc           ____fputc
 
232
        #define fputs           ____fputs
 
233
        #define fread           ____fread
 
234
        #define freopen         ____freopen
 
235
        #define fscanf          ____fscanf
 
236
        #define fseek           ____fseek
 
237
        #define ftell           ____ftell
 
238
        #define fgetpos         ____fgetpos
 
239
        #define fsetpos         ____fsetpos
 
240
        #define fpurge          ____fpurge
 
241
        #define fwrite          ____fwrite
 
242
        #define gets            ____gets
 
243
        #define getw            ____getw
 
244
        #define pclose          ____pclose
 
245
        #define popen           ____popen
 
246
        #define printf          ____printf
 
247
        #define puts            ____puts
 
248
        #define putw            ____putw
 
249
        #define rewind          ____rewind
 
250
        #define scanf           ____scanf
 
251
        #define setbuf          ____setbuf
 
252
        #define setbuffer       ____setbuffer
 
253
        #define setlinebuf      ____setlinebuf
 
254
        #define setvbuf         ____setvbuf
 
255
        #define sprintf         ____sprintf
 
256
        #define sscanf          ____sscanf
 
257
        #define tmpfile         ____tmpfile
 
258
        #define ungetc          ____ungetc
 
259
        #define vfprintf        ____vfprintf
 
260
        #define vfscanf         ____vfscanf
 
261
        #define vprintf         ____vprintf
 
262
        #define vscanf          ____vscanf
 
263
        #define vsprintf        ____vsprintf
 
264
        #define vsscanf         ____vsscanf
 
265
        #define flockfile       ____flockfile
 
266
        #define funlockfile     ____funlockfile
 
267
        #define ftrylockfile    ____ftrylockfile
 
268
        
 
269
        #include        <stdio.h>
 
270
        
 
271
        #undef IOB
 
272
        #if defined(_dat_iob) && !defined(IOB)
 
273
        #define IOB     iob
 
274
        #endif
 
275
        #if defined(_dat__iob) && !defined(IOB)
 
276
        #define IOB     _iob
 
277
        #endif
 
278
        #if defined(_dat___iob) && !defined(IOB)
 
279
        #define IOB     __iob
 
280
        #endif
 
281
        
 
282
        static void* addr() { return((void*)IOB); }
 
283
        int main() { addr(); exit(0); }
 
284
        
 
285
        #undef  _doprnt
 
286
        #undef  _doscan
 
287
        #undef  fclose
 
288
        #undef  fdopen
 
289
        #undef  fflush
 
290
        #undef  fgetc
 
291
        #undef  fgets
 
292
        #undef  _filbuf
 
293
        #undef  _flsbuf
 
294
        #undef  _cleanup
 
295
        #undef  fopen
 
296
        #undef  fprintf
 
297
        #undef  fputc
 
298
        #undef  fputs
 
299
        #undef  fread
 
300
        #undef  freopen
 
301
        #undef  fscanf
 
302
        #undef  fseek
 
303
        #undef  ftell
 
304
        #undef  fgetpos
 
305
        #undef  fsetpos
 
306
        #undef  fpurge
 
307
        #undef  fwrite
 
308
        #undef  gets
 
309
        #undef  getw
 
310
        #undef  pclose
 
311
        #undef  popen
 
312
        #undef  printf
 
313
        #undef  puts
 
314
        #undef  putw
 
315
        #undef  rewind
 
316
        #undef  scanf
 
317
        #undef  setbuf
 
318
        #undef  setbuffer
 
319
        #undef  setlinebuf
 
320
        #undef  setvbuf
 
321
        #undef  sprintf
 
322
        #undef  sscanf
 
323
        #undef  tmpfile
 
324
        #undef  ungetc
 
325
        #undef  vfprintf
 
326
        #undef  vfscanf
 
327
        #undef  vprintf
 
328
        #undef  vscanf
 
329
        #undef  vsprintf
 
330
        #undef  vsscanf
 
331
        #undef  flockfile
 
332
        #undef  funlockfile
 
333
        #undef  ftrylockfile
 
334
        
 
335
        void    _doprnt() {}
 
336
        void    _doscan() {}
 
337
        void    fclose() {}
 
338
        void    fdopen() {}
 
339
        void    fflush() {}
 
340
        void    fgetc() {}
 
341
        void    fgets() {}
 
342
        void    _filbuf() {}
 
343
        void    _flsbuf() {}
 
344
        void    _cleanup() {}
 
345
        void    fopen() {}
 
346
        void    fprintf() {}
 
347
        void    fputc() {}
 
348
        void    fputs() {}
 
349
        void    fread() {}
 
350
        void    freopen() {}
 
351
        void    fscanf() {}
 
352
        void    fseek() {}
 
353
        void    ftell() {}
 
354
        void    fgetpos() {}
 
355
        void    fsetpos() {}
 
356
        void    fpurge() {}
 
357
        void    fwrite() {}
 
358
        void    gets() {}
 
359
        void    getw() {}
 
360
        void    pclose() {}
 
361
        void    popen() {}
 
362
        void    printf() {}
 
363
        void    puts() {}
 
364
        void    putw() {}
 
365
        void    rewind() {}
 
366
        void    scanf() {}
 
367
        void    setbuf() {}
 
368
        void    setbuffer() {}
 
369
        void    setlinebuf() {}
 
370
        void    setvbuf() {}
 
371
        void    sprintf() {}
 
372
        void    sscanf() {}
 
373
        void    tmpfile() {}
 
374
        void    ungetc() {}
 
375
        void    vfprintf() {}
 
376
        void    vfscanf() {}
 
377
        void    vprintf() {}
 
378
        void    vscanf() {}
 
379
        void    vsprintf() {}
 
380
        void    vsscanf() {}
 
381
        void    flockfile() {}
 
382
        void    funlockfile() {}
 
383
        void    ftrylockfile() {}
 
384
}end