Annotation of dietlibc/t.c, revision 1.128

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

LinuxTV legacy CVS <linuxtv.org/cvs>