Annotation of dietlibc/t.c, revision 1.50
1.47 fefe 1: #define _FILE_OFFSET_BITS 64
1.1 cvs 2: #include <unistd.h>
3: #include <endian.h>
4: #include <stdlib.h>
5: #include <dirent.h>
6: #include <pwd.h>
1.40 fefe 7: #include <shadow.h>
1.1 cvs 8: #include <stdio.h>
9: #include <assert.h>
10: #include <sys/mount.h>
1.7 fefe 11: #include <time.h>
1.9 fefe 12: #include <sys/stat.h>
1.10 fefe 13: #include <stdio.h>
1.12 fefe 14: #include <arpa/inet.h>
1.13 fefe 15: #include <sys/sem.h>
1.14 fefe 16: #include <sys/shm.h>
1.17 fefe 17: #include <math.h>
1.20 fefe 18: #include <termios.h>
1.22 fefe 19: #include <netdb.h>
1.38 fefe 20: #include <sys/mman.h>
1.45 fefe 21: #include <ctype.h>
1.49 fefe 22: #include <mntent.h>
1.1 cvs 23:
1.17 fefe 24: #if 0
1.16 fefe 25: int compint(const void *a,const void *b) {
26: /* printf("comparing %d with %d\n",*(int*)a,*(int*)b); */
27: return (*(int*)a-*(int*)b);
28: }
29:
30: #define SIZE 100000
31: #define LOOKFOR ((SIZE/2)-2)
32:
33: int array[SIZE];
34:
35: #define rdtscl(low) \
36: __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
37:
38: static unsigned int seed=1;
39:
40: static int rand() {
41: return ((seed = seed * 1103515245 + 12345) % ((unsigned int)RAND_MAX + 1));
42: }
1.17 fefe 43: #endif
1.16 fefe 44:
1.24 fefe 45: extern double atof(const char *c);
46:
1.12 fefe 47: int main(int argc,char *argv[]) {
1.50 ! fefe 48: if (!fnmatch("s*", "sub", 0))
! 49: printf("s* sub\n");
! 50: if (!fnmatch("s*", "glob", 0))
! 51: printf("s* glob\n");
! 52: if (!fnmatch("s*b", "sub", 0))
! 53: printf("s*b sub\n");
! 54: if (!fnmatch("s*h", "sub", 0))
! 55: printf("s*h sub\n");
1.49 fefe 56: #if 0
1.48 fefe 57: char*tmp;
58: int n=asprintf(&tmp,"foo %s %d\n","bar",23);
59: write(1,tmp,n);
60: free(tmp);
1.49 fefe 61: #endif
1.41 fefe 62: #if 0
1.40 fefe 63: struct passwd *p=getpwnam("leitner");
1.41 fefe 64: struct spwd *s=getspnam("leitner");
1.39 fefe 65: printf("%g\n",30.0123);
1.41 fefe 66: #endif
1.43 fefe 67: #if 0
1.42 fefe 68: initgroups("root",100);
1.43 fefe 69: #endif
1.38 fefe 70: #if 0
1.37 fefe 71: time_t t=time(0);
72: puts(asctime(localtime(&t)));
1.38 fefe 73: #endif
1.37 fefe 74: #if 0
1.36 fefe 75: struct servent *foo=getservbyname("ident","tcp");
76: if (foo)
77: printf("found service %s on port %d\n",foo->s_name,foo->s_port);
1.37 fefe 78: #endif
1.35 fefe 79: #if 0
1.33 fefe 80: char buf[128];
81: strcpy(buf,"/tmp/foo.XXXXXXX");
82: printf("%d\n",mkstemp(buf));
1.34 fefe 83: printf("%s\n",buf);
84: unlink(buf);
1.35 fefe 85: #endif
1.33 fefe 86: #if 0
1.32 fefe 87: char buf[512]="foo";
88: strncat(buf,"barbaz",3);
89: puts(buf);
1.33 fefe 90: #endif
1.32 fefe 91: #if 0
1.31 fefe 92: time_t oink=time(0);
93: struct tm *duh=localtime(&oink);
94: strftime(buf,512,"%A %B %Y\n",duh);
95: puts(buf);
1.32 fefe 96: #endif
1.31 fefe 97: #if 0
1.28 fefe 98: struct in_addr bar;
99: struct hostent *foo;
1.29 fefe 100: /* inet_aton("160.45.10.8",&bar); */
101: foo=gethostbyname("zeit.fu-berlin.de");
102: /* foo=gethostbyaddr(&bar,4,AF_INET); */
1.30 fefe 103: if (foo)
104: printf("%s -> %s\n",foo->h_name,inet_ntoa(*(struct in_addr*)foo->h_addr));
1.22 fefe 105: /* printf("%g %g\n",1e-10,1e10); */
1.31 fefe 106: #endif
1.18 fefe 107: #if 0
1.17 fefe 108: double d=0.0;
109: long long t=0x12345678ABCDEF01;
110: d/=0.0;
111: printf("%d %llx\n",__isnan(d),t,*(long long*)&d);
1.18 fefe 112: #endif
1.17 fefe 113: #if 0
1.16 fefe 114: int i,j;
115: long a,b,c;
116: int *res;
117: printf("%p\n",malloc(0));
118: qsort(array,2,sizeof(int),compint);
119: for (i=0; i<SIZE; ++i)
120: array[i]=rand();
121: rdtscl(a);
122: qsort(array,SIZE,sizeof(int),compint);
123: rdtscl(b);
124: j=array[LOOKFOR];
125: res=bsearch(&j,array,SIZE,sizeof(int),compint);
126: rdtscl(c);
127: printf("%lu cycles sort, %lu cycles bsearch\n",b-a,c-b);
128: for (i=0; i<SIZE-1; ++i)
129: if (array[i]>array[i+1]) {
130: printf("qsort does not work, index %d: %d > %d\n",i,array[i],array[i+1]);
131: return 1;
132: }
133: if (*res!=j)
134: printf("besearch does not work, returned %p (%d) instead of %p (%d)\n",res,res?*res:-1,array+LOOKFOR,j);
135: /* printf("array={%d,%d,%d,%d,%d}\n",array[0],array[1],array[2],array[3],array[4]); */
1.17 fefe 136: #endif
1.13 fefe 137: #if 0
1.12 fefe 138: struct in_addr duh;
139: printf("%d\n",inet_aton(argv[1]?argv[1]:"10.0.0.1",&duh));
140: printf("%x\n",duh.s_addr);
1.13 fefe 141: #endif
1.12 fefe 142: /* printf("%-19s %10lu %9lu %9lu %3d%% %s\n","/dev/ide/host0/bus0/target0/lun0/part2",8393688,705683,1337084,85,"/"); */
1.11 fefe 143: #if 0
1.10 fefe 144: char buf[100];
145: fgets(buf,100,stdin); printf("got %d bytes\n",strlen(buf));
146: fgets(buf,100,stdin); printf("got %d bytes\n",strlen(buf));
1.11 fefe 147: #endif
1.9 fefe 148: #if 0
1.7 fefe 149: struct tm duh;
150: time_t t;
1.8 fefe 151: time(&t);
152: gmtime_r(&t,&duh);
153: printf("%s\n",asctime(&duh));
1.9 fefe 154: #endif
1.8 fefe 155: #if 0
1.7 fefe 156: char buf[30];
157: duh.tm_sec=42;
158: duh.tm_min=23;
159: duh.tm_hour=17;
160: duh.tm_mday=2;
161: duh.tm_mon=7;
162: duh.tm_year=100;
163: t=mktime(&duh);
164: printf("%s\n",asctime_r(&duh,buf));
1.8 fefe 165: #endif
1.2 fefe 166: #if 0
1.1 cvs 167: int i;
168: for (i=0; i<5; i++) {
169: fprintf(stdout,"first message\n");
170: fprintf(stdout,"second message\n");
171: fprintf(stdout,"third message\n");
172: printf("foo %d\n",i);
173: }
1.2 fefe 174: #endif
1.1 cvs 175: #if 0
176: char buf[1024];
177: sscanf("foo bar","%s",buf);
178: printf("%s\n",buf);
179: #endif
180: #if 0
181: mount("/dev/scsi/host0/bus0/target2/lun0/cd", "/cd", "iso9660", MS_MGC_VAL|MS_RDONLY, NULL);
182: perror("mount");
183: #endif
184: #if 0
185: char *t="<4>Linux version 2.4.0-test10 (leitner@hellhound) (gcc version 2.95.2 19991024 (release))";
186: int i=strtol(t+1,&t,10);
187: printf("%d %s\n",i,t);
188: #endif
189: #if 0
190: char **tmp;
191: putenv("FOO");
192: assert(1==2);
193: for (tmp=environ; *tmp; tmp++)
194: puts(*tmp);
195: #endif
196: #if 0
197: char buf[1024];
198: printf("%d\n",fprintf(stderr,"duh\n"));
199: #endif
200: #if 0
201: struct passwd *p=getpwuid(100);
202: puts(p->pw_name);
203: #endif
204: #if 0
205: int pid;
206: char name[32];
207: sscanf("1 (init","%d (%15c",&pid,name);
208: printf("pid %d name %s\n",pid,name);
209: #endif
210: #if 0
211: DIR *d=opendir("/proc");
212: if (d) {
213: struct dirent *D;
214: while (D=readdir(d))
215: puts(D->d_name);
216: closedir(d);
217: }
218: #endif
219: #if 0
220: char buf[1024];
221: int fd=open("/etc/passwd",0);
222: pread(fd,buf,30,32);
223: close(fd);
224: write(1,buf,32);
225: #endif
226: #if 0
227: char *argv[] = {"echo","foo",0};
228: char buf[100];
229: buf[5]='x';
230: sprintf(buf,"foo\n");
231: if (buf[5] == 'x')
232: exit(0);
233: else
234: exit(1);
235: execvp(argv[0],argv);
236: #endif
1.10 fefe 237: #if 0
1.1 cvs 238: struct stat64 f;
239: char buf[128];
240: fstat64(0,&f);
241: fprintf(stderr,"%d %d\n",f.st_size,sizeof(f));
242: return 0;
243: #endif
244: #if 0
245: FILE *f=fopen("foo","w");
246: fputc('a',f);
247: fputc('b',f);
248: fputc('c',f);
249: #endif
250: /* fprintf(stdout,"foo\n"); */
251: }
LinuxTV legacy CVS <linuxtv.org/cvs>