Annotation of dietlibc/t.c, revision 1.144
1.56 fefe 1: #define _GNU_SOURCE
1.47 fefe 2: #define _FILE_OFFSET_BITS 64
1.1 cvs 3: #include <unistd.h>
4: #include <endian.h>
5: #include <stdlib.h>
6: #include <dirent.h>
7: #include <pwd.h>
1.40 fefe 8: #include <shadow.h>
1.1 cvs 9: #include <stdio.h>
10: #include <assert.h>
11: #include <sys/mount.h>
1.7 fefe 12: #include <time.h>
1.9 fefe 13: #include <sys/stat.h>
1.10 fefe 14: #include <stdio.h>
1.12 fefe 15: #include <arpa/inet.h>
1.13 fefe 16: #include <sys/sem.h>
1.14 fefe 17: #include <sys/shm.h>
1.17 fefe 18: #include <math.h>
1.20 fefe 19: #include <termios.h>
1.22 fefe 20: #include <netdb.h>
1.38 fefe 21: #include <sys/mman.h>
1.45 fefe 22: #include <ctype.h>
1.49 fefe 23: #include <mntent.h>
1.53 fefe 24: #include <regex.h>
1.56 fefe 25: #include <sys/types.h>
26: #include <sys/msg.h>
1.63 fefe 27: #include <string.h>
1.76 fefe 28: #include <sys/socket.h>
29: #include <netdb.h>
1.86 fefe 30: #include <signal.h>
1.88 fefe 31: #include <sys/io.h>
1.97 fefe 32: #include <getopt.h>
1.101 fefe 33: #include <arpa/nameser.h>
34: #include <resolv.h>
1.102 fefe 35: #include <fnmatch.h>
1.109 fefe 36: #include <stdarg.h>
1.118 fefe 37: #include <sys/wait.h>
1.133 fefe 38: #include <libgen.h>
1.144 ! fefe 39: #include <math.h>
1.121 fefe 40: #include <errno.h>
41: #include <syslog.h>
42: #include <sys/un.h>
43: #include <fcntl.h>
44:
45: #if 0
46: static const char* Ident;
47: static int Option;
48: static int Facility;
49: static struct sockaddr_un sock;
50: static int fd=-1;
51:
52: static void syslogconnect(void) {
53: sock.sun_family=AF_UNIX;
54: strcpy(sock.sun_path,"/dev/log");
55: if ((fd=socket(AF_UNIX,SOCK_STREAM,0))==-1) return;
56: if (connect(fd,(struct sockaddr*)&sock,sizeof(sock))==-1) {
57: int save=errno;
58: close(fd);
59: fd=-1;
1.109 fefe 60: }
1.121 fefe 61: fcntl(fd,F_SETFL,FD_CLOEXEC); /* doesn't work? too bad */
1.109 fefe 62: }
1.107 fefe 63:
1.121 fefe 64: void openlog(const char *ident, int option, int facility) {
65: Ident=ident;
66: Option=option;
67: Facility=facility;
68: syslogconnect();
1.116 fefe 69: }
70:
1.121 fefe 71: void syslog(int priority, const char *format, ...) {
72: /* write(fd,"<13>Jun 29 19:21:32 leitner: fnord",...) */
73: }
74:
75: void closelog(void) {
76: }
77: #endif
78:
1.139 fefe 79: void foo(int tmp,...) {
80: long long l;
81: va_list va;
82: va_start(va,tmp);
83: l=va_arg(va,long long);
84: if (l!=-1) write(2,"kaputt\n",7);
85: }
86:
87: extern int __lltostr(char *s, int size, unsigned long long i, int base, char UpCase);
88:
1.97 fefe 89: int main(int argc,char *argv[]) {
1.144 ! fefe 90: #if 0
! 91: char buf[101];
! 92: __dtostr(M_PI,buf,100,6);
! 93: #endif
! 94: printf("%d\n",strcasecmp("foo","FOO"));
! 95: #if 0
1.143 fefe 96: printf("%.24s", "Sun Jan 2 08:29:13 1994\n");
1.144 ! fefe 97: #endif
1.143 fefe 98: #if 0
99: printf("%.*s\n",13,"fnord");
100: #endif
1.141 fefe 101: #if 0
1.140 fefe 102: double d=strtod(argv[1],0);
103: printf("%g|\n",d);
1.141 fefe 104: #endif
1.140 fefe 105: #if 0
1.139 fefe 106: char buf[100];
107: printf("%d\n",__lltostr(buf,30,-1ll,10,0));
108: puts(buf);
1.140 fefe 109: #endif
110: #if 0
1.139 fefe 111: printf("%lld\n",-1ll);
112: #endif
1.143 fefe 113: #if 0
1.139 fefe 114: char *str="e";
115: setbuf(stdout,0);
116: printf("foo\n");
117: fputc(toupper(*str++),stdout);
118: printf("bar\n");
1.138 fefe 119: #endif
1.137 fefe 120: #if 0
1.136 fefe 121: fwrite("foobar",6,1,stdout);
1.137 fefe 122: #endif
1.136 fefe 123: #if 0
1.135 fefe 124: char x[5];
125: x[4]='x';
126: fgets(x,4,stdin);
127: puts(x);
128: printf("%c\n",x[4]);
1.136 fefe 129: #endif
1.134 fefe 130: #if 0
1.133 fefe 131: char* paths[]={"/usr/lib","/usr/","usr","/",".",".."};
132: char* want[]={"/usr","/",".","/",".","."};
133: int i;
134: for (i=0; i<6; ++i) {
135: printf("%s\t%s\t%s\n",paths[i],want[i],dirname(strdup(paths[i])));
136: }
1.134 fefe 137: #endif
1.133 fefe 138: #if 0
139: char* paths[]={"/usr/lib","/usr/","usr","/",".",".."};
140: char* want[]={"lib","usr","usr","/",".",".."};
141: int i;
142: for (i=0; i<6; ++i) {
143: printf("%s\t%s\t%s\n",paths[i],want[i],basename(strdup(paths[i])));
144: }
145: #endif
146: #if 0
1.132 fefe 147: int i;
148: for (i=0; i<255; ++i) {
149: int a=isalpha(i);
150: int b=(i>='a' && i<='z') || (i>='A' && i<='Z');
151: if (a!=b) printf("%d: %d %d\n",i,a,b);
152: }
1.133 fefe 153: #endif
1.131 fefe 154: #if 0
1.130 fefe 155: char* name;
156: int ptyfd,ttyfd;
157: int i=openpty(&ptyfd,&ttyfd,0,0,0);
158: if (i<0) perror("openpty");
159: printf("%d %d\n",ptyfd,ttyfd);
160: printf("%s %s\n",ttyname(ptyfd),ttyname(ttyfd));
1.131 fefe 161: #endif
1.129 fefe 162: #if 0
163: printf("0x%8.7lx\n",0xfefe);
164: #endif
165: #if 0
1.128 fefe 166: puts(ttyname(0));
1.129 fefe 167: #endif
1.125 fefe 168: #if 0
169: char buf[1024];
170: struct hostent* r;
171: while (r=gethostent_r(buf,1024)) {
172: if (r && r->h_name) {
173: printf("name %s\n", r->h_name);
174: }
175: if (r && (r->h_addr_list)[0]) {
176: struct in_addr address;
177: address = *((struct in_addr *) (r->h_addr_list)[0]);
178: printf("addr %s\n", inet_ntoa(address));
179: }
180: }
181: #endif
182: #if 0
1.124 fefe 183: char *tmp;
184: printf("%lu\n",strtol("0xf0000000",&tmp,0));
1.125 fefe 185: #endif
1.128 fefe 186: #if 0
1.123 fefe 187: struct mntent* me;
1.127 fefe 188: FILE* f=fopen("/etc/fstab","r");
1.123 fefe 189: while (me=getmntent(f)) {
1.139 fefe 190: printf("%s\n",hasmntopt(me,"defaults"));
1.123 fefe 191: printf("%s %s %s %s %d %d\n",me->mnt_fsname,me->mnt_dir,me->mnt_type,me->mnt_opts,me->mnt_freq,me->mnt_passno);
1.139 fefe 192: break;
1.123 fefe 193: }
1.124 fefe 194: #endif
1.123 fefe 195: #if 0
196: char *tmp;
197: printf("%x\n",strtol("0Xffff",&tmp,16));
198: #endif
1.122 fefe 199: // putchar('c');
200: // write(1,"fnord\n",6);
1.132 fefe 201: #if 0
1.121 fefe 202: struct addrinfo *ai;
1.131 fefe 203: getaddrinfo("nagus","22",0,&ai);
1.121 fefe 204: #endif
1.122 fefe 205: #if 0
1.121 fefe 206: struct hostent host,*res;
207: char buf[4096];
208: int fnord;
209:
1.131 fefe 210: gethostbyname2_r("nagus",AF_INET,&host,buf,4096,&res,&fnord);
1.122 fefe 211: #endif
1.121 fefe 212: #if 0
1.119 fefe 213: char buf[128];
1.120 fefe 214: strcpy(buf,"/tmp/fnord/foo.XXXXXXX");
1.119 fefe 215: printf("%d\n",mkdtemp(buf));
216: printf("%s\n",buf);
1.120 fefe 217: #endif
1.119 fefe 218: #if 0
1.118 fefe 219: printf("%d\n",WEXITSTATUS(system("exit 17")));
1.119 fefe 220: #endif
1.113 fefe 221: #if 0
1.109 fefe 222: fnord("fnord","foo\n","bar\n",0);
1.112 fefe 223: assert(0);
1.113 fefe 224: #endif
1.105 fefe 225: #if 0
226: printf("%hd %hhd\n",-5,-1234567);
227: #endif
1.103 fefe 228: #if 0
1.102 fefe 229: printf("%d\n",fnmatch("*.o", "x.o", FNM_PATHNAME));
230: printf("%d\n",fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME));
1.103 fefe 231: #endif
1.102 fefe 232: #if 0
1.101 fefe 233: char buf[1024];
234: int len;
235: len=res_search("fu-berlin.de",ns_c_in,ns_t_ns,buf,sizeof(buf));
1.102 fefe 236: #endif
1.114 fefe 237: #if 0
1.100 fefe 238: regex_t t;
239: regmatch_t rm;
1.103 fefe 240: // regcomp(&t,"^ *read",0);
1.113 fefe 241: regcomp(&t,"\\<foo\\>",0);
242: printf("%d\n",regexec(&t," blub foo,",1,&rm,0));
1.100 fefe 243: printf("ofs %d\n",rm.rm_so);
1.101 fefe 244: #endif
1.100 fefe 245: #if 0
1.98 fefe 246: char buf[100];
1.99 fefe 247: printf("%d\n",fread(buf,1,0,stdin));
1.100 fefe 248: #endif
1.99 fefe 249: #if 0
250: char buf[100];
1.98 fefe 251: memset(buf,17,100);
252: buf[0]=0;
253: strncat(buf,"foobarbaz23",10);
254: puts(buf);
1.99 fefe 255: #endif
1.98 fefe 256: #if 0
1.97 fefe 257: int aflag = 0;
258: int bflag = 0;
259: char *cvalue = NULL;
260: int index;
261: int c;
262:
263: opterr = 1;
264:
265: while ((c = getopt (argc, argv, "abc:")) != -1)
266: switch (c)
267: {
268: case 'a':
269: aflag = 1;
270: break;
271: case 'b':
272: bflag = 1;
273: break;
274: case 'c':
275: cvalue = optarg;
276: break;
277: case '?':
278: if (isprint (optopt))
279: fprintf (stderr, "Unknown option `-%c'.\n", optopt);
280: else
281: fprintf (stderr,
282: "Unknown option character `\\x%x'.\n",
283: optopt);
284: return 1;
285: default:
286: abort ();
287: }
1.96 fefe 288:
1.97 fefe 289: printf ("aflag = %d, bflag = %d, cvalue = %s\n",
290: aflag, bflag, cvalue);
291:
292: for (index = optind; index < argc; index++)
293: printf ("Non-option argument %s\n", argv[index]);
294: return 0;
1.98 fefe 295: #endif
1.97 fefe 296: #if 0
1.96 fefe 297: char *t="foobar";
298: char *c;
299: char buf[1000];
300: puts(strcat(strcpy(buf,"HOME="),t));
1.97 fefe 301: #endif
1.89 fefe 302: #if 0
303: struct netent* n=getnetbyname("loopback");
304: printf("%s %s\n",n->n_name,inet_ntoa(*(struct in_addr*)&n->n_net));
305: #endif
306: #if 0
1.88 fefe 307: fprintf(stdout,"foo\n");
308: sleep(1);
309: fprintf(stdout,"bar");
310: fprintf(stderr,"blonk");
311: sleep(1);
312: fprintf(stdout,"\rbz");
313: sleep(1);
314: fprintf(stdout,"\n");
315: sleep(1);
1.89 fefe 316: #endif
1.87 fefe 317: #if 0
1.86 fefe 318: sigset_t s; /* sigsetops */
319:
320: sigemptyset(&s);
321: sigaddset(&s,SIGCHLD);
322: sigaddset(&s,SIGHUP);
323: sigsuspend(&s);
1.87 fefe 324: #endif
1.85 fefe 325: #if 0
1.84 fefe 326: char buf[1024];
327: FILE *f=popen("uname -srm","r");
328: fgets(buf,1023,f);
329: pclose(f);
330: write(1,buf,strlen(buf));
1.85 fefe 331: #endif
1.84 fefe 332: #if 0
1.82 fefe 333: char type[64];
1.83 fefe 334: char filename[256];
335: int major,minor;
1.82 fefe 336: int len;
1.83 fefe 337: printf("%d\n",sscanf("GET / HTTP/1.0\r\n","%4[A-Z] %255[^ \t\r\n] HTTP/%d.%d",type,filename,&major,&minor));
338: printf("%s %s %d %d\n",type,filename,major,minor);
1.84 fefe 339: #endif
1.82 fefe 340: #if 0
1.81 fefe 341: char buf[100];
342: char ip[16];
343: memset(ip,0,16);
344: printf("%p %p\n",inet_ntop(AF_INET6,ip,buf,100),buf);
345: puts(buf);
1.82 fefe 346: #endif
1.127 fefe 347: #if 0
1.76 fefe 348: struct addrinfo *ai;
1.78 fefe 349: struct addrinfo hints;
1.79 fefe 350: char buf[16];
1.78 fefe 351: hints.ai_family = AF_UNSPEC;
1.79 fefe 352: hints.ai_flags = AI_PASSIVE|AI_CANONNAME;
1.78 fefe 353: hints.ai_socktype = SOCK_STREAM;
1.126 fefe 354: printf("%d\n",getaddrinfo("xorn.continuum.local","ssh",0,&ai));
1.76 fefe 355: while (ai) {
356: printf("found host %s, port %d, family %s, socktype %s\n",ai->ai_canonname,
357: ntohs(ai->ai_family==AF_INET6?((struct sockaddr_in6*)ai->ai_addr)->sin6_port:
358: ((struct sockaddr_in*)ai->ai_addr)->sin_port),
359: ai->ai_family==AF_INET6?"PF_INET6":"PF_INET",
360: ai->ai_socktype==SOCK_STREAM?"SOCK_STREAM":"SOCK_DGRAM");
1.80 fefe 361: {
362: char buf[100];
363: inet_ntop(ai->ai_family,ai->ai_family==AF_INET6?
364: (char*)&(((struct sockaddr_in6*)ai->ai_addr)->sin6_addr):
365: (char*)&(((struct sockaddr_in*)ai->ai_addr)->sin_addr),buf,100);
366: printf(" %s\n",buf);
367: }
1.76 fefe 368: ai=ai->ai_next;
369: }
1.81 fefe 370: #endif
1.76 fefe 371: #if 0
1.71 fefe 372: int i=foo;
1.75 fefe 373: printf("load average is %3.2f\n",0.0);
1.76 fefe 374: #endif
1.70 fefe 375: #if 0
1.69 fefe 376: struct dirent **namelist;
377: int n;
1.16 fefe 378:
1.69 fefe 379: n = scandir(".", &namelist, 0, alphasort);
380: if (n < 0)
381: perror("scandir");
382: else {
383: while(n--) {
384: printf("%s\n", namelist[n]->d_name);
385: free(namelist[n]);
386: }
387: free(namelist);
388: }
1.70 fefe 389: #endif
1.68 fefe 390: #if 0
1.67 fefe 391: char foo[10]="none,zlib";
392: char *tmp,*tmp2=foo;
393: while (tmp=strsep(&tmp2,",")) {
394: puts(tmp);
395: }
1.68 fefe 396: #endif
1.65 fefe 397: #if 0
1.61 fefe 398: char foo[10];
1.64 fefe 399: printf("%d %d\n",abs(-3),abs(23));
1.63 fefe 400: strcpy(foo,"foo");
401: strncat(foo,"barbaz",3);
402: foo[6]=0;
403: puts(foo);
1.65 fefe 404: #endif
1.115 fefe 405: #if 0
1.58 fefe 406: struct hostent * host;
407: struct in_addr i;
1.57 fefe 408:
1.131 fefe 409: host = gethostbyname2("nagus",AF_INET);
1.57 fefe 410:
1.58 fefe 411: if (!host)
412: printf("host null\n");
1.57 fefe 413:
1.58 fefe 414: if (host && host->h_name) {
415: printf("name %s\n", host->h_name);
416: }
417: if (host && (host->h_addr_list)[0]) {
418: struct in_addr address;
419: address = *((struct in_addr *) (host->h_addr_list)[0]);
420: printf("addr %s\n", inet_ntoa(address));
421: }
1.59 fefe 422: #endif
1.57 fefe 423: #if 0
1.56 fefe 424: struct msgbuf bla;
425: bla.mtype=0;
426: bla.mtext[0]='x';
427: msgsnd(327680,&bla,5,IPC_NOWAIT);
1.57 fefe 428: #endif
1.55 fefe 429: #if 0
1.54 fefe 430: char buf[PATH_MAX];
431: printf("%s\n",realpath("../../incoming/..///.zshrc",buf));
1.55 fefe 432: #endif
1.73 fefe 433: #if 0
1.53 fefe 434: regex_t t;
1.68 fefe 435: regcomp(&t,"^OpenSSH_2\\.5\\.[012]",5);
1.65 fefe 436: printf("%d\n",regexec(&t,"OpenSSH_2.5.2p2",0,0,0));
1.56 fefe 437: #endif
1.53 fefe 438: #if 0
1.52 fefe 439: float my_float = 9.2334;
440: char buffer[100];
441:
442: sprintf(buffer, "%.2f", my_float);
443: fprintf(stdout, "%s", buffer);
1.53 fefe 444: #endif
1.52 fefe 445: #if 0
1.51 fefe 446: printf("%d\n",setenv("foo","bar",0));
447: printf("%d\n",setenv("foo","bar",1));
448: execlp("printenv","printenv","foo",0);
1.52 fefe 449: #endif
1.106 fefe 450: #if 0
1.59 fefe 451: printf("%d\n",fnmatch("*c*","bin",0));
1.50 fefe 452: if (!fnmatch("s*", "sub", 0))
453: printf("s* sub\n");
454: if (!fnmatch("s*", "glob", 0))
455: printf("s* glob\n");
456: if (!fnmatch("s*b", "sub", 0))
457: printf("s*b sub\n");
458: if (!fnmatch("s*h", "sub", 0))
459: printf("s*h sub\n");
1.51 fefe 460: #endif
1.49 fefe 461: #if 0
1.48 fefe 462: char*tmp;
463: int n=asprintf(&tmp,"foo %s %d\n","bar",23);
464: write(1,tmp,n);
465: free(tmp);
1.49 fefe 466: #endif
1.41 fefe 467: #if 0
1.40 fefe 468: struct passwd *p=getpwnam("leitner");
1.41 fefe 469: struct spwd *s=getspnam("leitner");
1.39 fefe 470: printf("%g\n",30.0123);
1.41 fefe 471: #endif
1.43 fefe 472: #if 0
1.42 fefe 473: initgroups("root",100);
1.43 fefe 474: #endif
1.38 fefe 475: #if 0
1.37 fefe 476: time_t t=time(0);
477: puts(asctime(localtime(&t)));
1.38 fefe 478: #endif
1.135 fefe 479: #if 0
1.134 fefe 480: struct servent *foo=getservbyname("pop-3","tcp");
1.36 fefe 481: if (foo)
482: printf("found service %s on port %d\n",foo->s_name,foo->s_port);
1.37 fefe 483: #endif
1.121 fefe 484: #if 0
1.33 fefe 485: char buf[128];
1.120 fefe 486: strcpy(buf,"/tmp/blub/foo.XXXXXXX");
1.33 fefe 487: printf("%d\n",mkstemp(buf));
1.34 fefe 488: printf("%s\n",buf);
489: unlink(buf);
1.35 fefe 490: #endif
1.33 fefe 491: #if 0
1.32 fefe 492: char buf[512]="foo";
493: strncat(buf,"barbaz",3);
494: puts(buf);
1.33 fefe 495: #endif
1.32 fefe 496: #if 0
1.31 fefe 497: time_t oink=time(0);
498: struct tm *duh=localtime(&oink);
499: strftime(buf,512,"%A %B %Y\n",duh);
500: puts(buf);
1.32 fefe 501: #endif
1.126 fefe 502: #if 0
1.28 fefe 503: struct in_addr bar;
504: struct hostent *foo;
1.125 fefe 505: inet_aton("160.45.10.8",&bar);
506: /* foo=gethostbyname("zeit.fu-berlin.de"); */
507: foo=gethostbyaddr(&bar,4,AF_INET);
1.30 fefe 508: if (foo)
509: printf("%s -> %s\n",foo->h_name,inet_ntoa(*(struct in_addr*)foo->h_addr));
1.22 fefe 510: /* printf("%g %g\n",1e-10,1e10); */
1.31 fefe 511: #endif
1.18 fefe 512: #if 0
1.17 fefe 513: double d=0.0;
514: long long t=0x12345678ABCDEF01;
515: d/=0.0;
516: printf("%d %llx\n",__isnan(d),t,*(long long*)&d);
1.18 fefe 517: #endif
1.17 fefe 518: #if 0
1.16 fefe 519: int i,j;
520: long a,b,c;
521: int *res;
522: printf("%p\n",malloc(0));
523: qsort(array,2,sizeof(int),compint);
524: for (i=0; i<SIZE; ++i)
525: array[i]=rand();
526: rdtscl(a);
527: qsort(array,SIZE,sizeof(int),compint);
528: rdtscl(b);
529: j=array[LOOKFOR];
530: res=bsearch(&j,array,SIZE,sizeof(int),compint);
531: rdtscl(c);
532: printf("%lu cycles sort, %lu cycles bsearch\n",b-a,c-b);
533: for (i=0; i<SIZE-1; ++i)
534: if (array[i]>array[i+1]) {
535: printf("qsort does not work, index %d: %d > %d\n",i,array[i],array[i+1]);
536: return 1;
537: }
538: if (*res!=j)
539: printf("besearch does not work, returned %p (%d) instead of %p (%d)\n",res,res?*res:-1,array+LOOKFOR,j);
540: /* printf("array={%d,%d,%d,%d,%d}\n",array[0],array[1],array[2],array[3],array[4]); */
1.17 fefe 541: #endif
1.13 fefe 542: #if 0
1.12 fefe 543: struct in_addr duh;
544: printf("%d\n",inet_aton(argv[1]?argv[1]:"10.0.0.1",&duh));
545: printf("%x\n",duh.s_addr);
1.13 fefe 546: #endif
1.12 fefe 547: /* printf("%-19s %10lu %9lu %9lu %3d%% %s\n","/dev/ide/host0/bus0/target0/lun0/part2",8393688,705683,1337084,85,"/"); */
1.11 fefe 548: #if 0
1.10 fefe 549: char buf[100];
550: fgets(buf,100,stdin); printf("got %d bytes\n",strlen(buf));
551: fgets(buf,100,stdin); printf("got %d bytes\n",strlen(buf));
1.11 fefe 552: #endif
1.9 fefe 553: #if 0
1.7 fefe 554: struct tm duh;
555: time_t t;
1.8 fefe 556: time(&t);
557: gmtime_r(&t,&duh);
558: printf("%s\n",asctime(&duh));
1.9 fefe 559: #endif
1.8 fefe 560: #if 0
1.7 fefe 561: char buf[30];
562: duh.tm_sec=42;
563: duh.tm_min=23;
564: duh.tm_hour=17;
565: duh.tm_mday=2;
566: duh.tm_mon=7;
567: duh.tm_year=100;
568: t=mktime(&duh);
569: printf("%s\n",asctime_r(&duh,buf));
1.8 fefe 570: #endif
1.2 fefe 571: #if 0
1.1 cvs 572: int i;
573: for (i=0; i<5; i++) {
574: fprintf(stdout,"first message\n");
575: fprintf(stdout,"second message\n");
576: fprintf(stdout,"third message\n");
577: printf("foo %d\n",i);
578: }
1.2 fefe 579: #endif
1.1 cvs 580: #if 0
581: char buf[1024];
582: sscanf("foo bar","%s",buf);
583: printf("%s\n",buf);
584: #endif
585: #if 0
586: mount("/dev/scsi/host0/bus0/target2/lun0/cd", "/cd", "iso9660", MS_MGC_VAL|MS_RDONLY, NULL);
587: perror("mount");
588: #endif
589: #if 0
590: char *t="<4>Linux version 2.4.0-test10 (leitner@hellhound) (gcc version 2.95.2 19991024 (release))";
591: int i=strtol(t+1,&t,10);
592: printf("%d %s\n",i,t);
593: #endif
594: #if 0
595: char **tmp;
1.115 fefe 596: putenv("A=foo");
1.1 cvs 597: for (tmp=environ; *tmp; tmp++)
598: puts(*tmp);
599: #endif
600: #if 0
601: char buf[1024];
602: printf("%d\n",fprintf(stderr,"duh\n"));
603: #endif
604: #if 0
605: struct passwd *p=getpwuid(100);
606: puts(p->pw_name);
607: #endif
608: #if 0
609: int pid;
610: char name[32];
611: sscanf("1 (init","%d (%15c",&pid,name);
612: printf("pid %d name %s\n",pid,name);
613: #endif
1.109 fefe 614: #if 0
1.1 cvs 615: DIR *d=opendir("/proc");
616: if (d) {
617: struct dirent *D;
618: while (D=readdir(d))
619: puts(D->d_name);
620: closedir(d);
621: }
622: #endif
623: #if 0
624: char buf[1024];
625: int fd=open("/etc/passwd",0);
626: pread(fd,buf,30,32);
627: close(fd);
628: write(1,buf,32);
629: #endif
630: #if 0
631: char *argv[] = {"echo","foo",0};
632: char buf[100];
633: buf[5]='x';
634: sprintf(buf,"foo\n");
635: if (buf[5] == 'x')
636: exit(0);
637: else
638: exit(1);
639: execvp(argv[0],argv);
640: #endif
1.10 fefe 641: #if 0
1.1 cvs 642: struct stat64 f;
643: char buf[128];
644: fstat64(0,&f);
645: fprintf(stderr,"%d %d\n",f.st_size,sizeof(f));
646: return 0;
647: #endif
648: #if 0
649: FILE *f=fopen("foo","w");
650: fputc('a',f);
651: fputc('b',f);
652: fputc('c',f);
653: #endif
654: /* fprintf(stdout,"foo\n"); */
655: }
LinuxTV legacy CVS <linuxtv.org/cvs>