Annotation of dietlibc/t.c, revision 1.129

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

LinuxTV legacy CVS <linuxtv.org/cvs>