Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

181 lines
3.9 KiB

  1. #include "fmt.h"
  2. #include "scan.h"
  3. #include "str.h"
  4. #include "uint16.h"
  5. #include "uint32.h"
  6. #include "stralloc.h"
  7. #include "socket.h"
  8. #include "buffer.h"
  9. #include "ip4.h"
  10. #include "mmap.h"
  11. #include "open.h"
  12. #include "textcode.h"
  13. #include <stdio.h>
  14. #include <unistd.h>
  15. #define rdtscl(low) \
  16. __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
  17. int main(int argc,char* argv[]) {
  18. char buf[100];
  19. char buf2[100];
  20. unsigned int len,len2;
  21. buf[fmt_quotedprintable(buf,"zunächst einmal vielen Dank für die MUTT FAQ",44)]=0;
  22. buffer_puts(buffer_1,buf);
  23. buffer_putsflush(buffer_1,"\n");
  24. if ((buf[len2=scan_quotedprintable(buf,buf2,&len)])!=0) {
  25. buffer_putsflush(buffer_2,"parse error!\n");
  26. return 1;
  27. }
  28. buffer_put(buffer_1,buf2,len2);
  29. buffer_putsflush(buffer_1,"\n");
  30. return 0;
  31. #if 0
  32. char buf[100];
  33. char buf2[100];
  34. unsigned int len,len2;
  35. buf[fmt_base64(buf,"foo:bar",7)]=0;
  36. buffer_puts(buffer_1,buf);
  37. buffer_putsflush(buffer_1,"\n");
  38. if ((buf[len2=scan_base64(buf,buf2,&len)])!=0) {
  39. buffer_putsflush(buffer_2,"parse error!\n");
  40. return 1;
  41. }
  42. buffer_put(buffer_1,buf2,len2);
  43. buffer_putsflush(buffer_1,"\n");
  44. return 0;
  45. #endif
  46. #if 0
  47. unsigned long size;
  48. char* buf=mmap_read(argv[1],&size);
  49. if (buf) {
  50. unsigned int x=fmt_uuencoded(0,buf,size);
  51. unsigned int y;
  52. char* tmp=malloc(x+1);
  53. y=fmt_uuencoded(tmp,buf,size);
  54. write(1,tmp,x);
  55. }
  56. #endif
  57. #if 0
  58. char buf[]="00000000000000000000000000000001";
  59. char ip[16];
  60. if (scan_ip6_flat(buf,ip) != str_len(buf))
  61. buffer_putsflush(buffer_2,"parse error!\n");
  62. #endif
  63. #if 0
  64. int fd=open_read("t.c");
  65. buffer b;
  66. char buf[1024];
  67. char line[20];
  68. int i;
  69. buffer_init(&b,read,fd,buf,1024);
  70. i=buffer_getline(&b,line,19);
  71. buffer_puts(buffer_1,"getline returned ");
  72. buffer_putulong(buffer_1,i);
  73. buffer_puts(buffer_1,"\n");
  74. buffer_puts(buffer_1,line);
  75. buffer_flush(buffer_1);
  76. #endif
  77. #if 0
  78. buffer_putulong(buffer_1,23);
  79. // buffer_putspace(buffer_1);
  80. buffer_putsflush(buffer_1,"\n");
  81. // buffer_flush(buffer_1);
  82. #endif
  83. #if 0
  84. long a,b,c;
  85. char buf[4096];
  86. char buf2[4096];
  87. memcpy(buf,buf2,4096);
  88. byte_copy(buf,4096,buf2);
  89. rdtscl(a);
  90. memcpy(buf,buf2,4096);
  91. rdtscl(b);
  92. byte_copy(buf,4096,buf2);
  93. rdtscl(c);
  94. printf("memcpy: %d - byte_copy: %d\n",b-a,c-b);
  95. #endif
  96. #if 0
  97. char ip[16];
  98. int i;
  99. if ((i=scan_ip6(argv[1],ip))) {
  100. char buf[128];
  101. buf[fmt_ip6(buf,ip)]=0;
  102. puts(buf);
  103. }
  104. #endif
  105. #if 0
  106. char buf[100];
  107. strcpy(buf,"foobarbaz");
  108. buf[fmt_fill(buf,3,5,100)]=0;
  109. printf("\"%s\"\n",buf);
  110. #endif
  111. #if 0
  112. unsigned long len;
  113. char *c=mmap_read("/etc/passwd",&len);
  114. printf("got map %p of len %lu\n",c,len);
  115. #endif
  116. #if 0
  117. char c;
  118. printf("%d\n",buffer_getc(buffer_0,&c));
  119. printf("%c\n",c);
  120. #endif
  121. #if 0
  122. char buf[100]="01234567890123456789012345678901234567890123456789";
  123. long a,b,c;
  124. #endif
  125. #if 0
  126. buf[ip4_fmt(buf,ip4loopback)]=0;
  127. buffer_puts(buffer_1small,buf);
  128. buffer_flush(buffer_1small);
  129. #endif
  130. #if 0
  131. buf[0]=0;
  132. buf[fmt_8long(buf,0)]=0;
  133. puts(buf);
  134. rdtscl(a);
  135. c=str_len(buf);
  136. rdtscl(b);
  137. /*byte_zero_djb(buf,j); */
  138. // printf("\n%lu %d\n",b-a,c);
  139. #endif
  140. #if 0
  141. buffer_puts(buffer_1small,"hello, world\n");
  142. buffer_flush(buffer_1small);
  143. #endif
  144. #if 0
  145. int s=socket_tcp4();
  146. char ip[4]={127,0,0,1};
  147. int t=socket_connect4(s,ip,80);
  148. #endif
  149. #if 0
  150. char buf[100]="foo bar baz fnord ";
  151. char buf2[100]="foo braz fnord";
  152. long a,b,c;
  153. long i=0,j=0,k=0;
  154. double d;
  155. uint32 l,m,n;
  156. stralloc sa={0};
  157. stralloc_copys(&sa,"fnord");
  158. stralloc_catlong0(&sa,-23,5);
  159. stralloc_append(&sa,"\n");
  160. printf("%d %d\n",str_equal("fnord","fnord1"),str_equal("fnord1","fnord"));
  161. write(1,sa.s,sa.len);
  162. printf("%d %d\n",stralloc_starts(&sa,"fnord"),stralloc_starts(&sa,"fnord\na"));
  163. l=0xdeadbeef;
  164. uint32_pack_big((char*)&m,l);
  165. uint32_unpack_big((char*)&m,&n);
  166. printf("%x %x %x\n",l,m,n);
  167. rdtscl(a);
  168. /* i=scan_double("3.1415",&d); */
  169. rdtscl(b);
  170. /*byte_zero_djb(buf,j); */
  171. rdtscl(c);
  172. printf("%lu %lu\n",b-a,c-b);
  173. #endif
  174. }