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