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