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