Annotation of dietlibc/t.c, revision 1.137

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

LinuxTV legacy CVS <linuxtv.org/cvs>