Annotation of dietlibc/t.c, revision 1.141

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

LinuxTV legacy CVS <linuxtv.org/cvs>