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