Annotation of dietlibc/t.c, revision 1.139

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

LinuxTV legacy CVS <linuxtv.org/cvs>