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.
 
 
 
 

139 lines
2.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 <stdio.h>
  13. #include <unistd.h>
  14. #define rdtscl(low) \
  15. __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
  16. int main(int argc,char* argv[]) {
  17. char buf[]="00000000000000000000000000000001";
  18. char ip[16];
  19. if (scan_ip6_flat(buf,ip) != str_len(buf))
  20. buffer_putsflush(buffer_2,"parse error!\n");
  21. #if 0
  22. int fd=open_read("t.c");
  23. buffer b;
  24. char buf[1024];
  25. char line[20];
  26. int i;
  27. buffer_init(&b,read,fd,buf,1024);
  28. i=buffer_getline(&b,line,19);
  29. buffer_puts(buffer_1,"getline returned ");
  30. buffer_putulong(buffer_1,i);
  31. buffer_puts(buffer_1,"\n");
  32. buffer_puts(buffer_1,line);
  33. buffer_flush(buffer_1);
  34. #endif
  35. #if 0
  36. buffer_putulong(buffer_1,23);
  37. // buffer_putspace(buffer_1);
  38. buffer_putsflush(buffer_1,"\n");
  39. // buffer_flush(buffer_1);
  40. #endif
  41. #if 0
  42. long a,b,c;
  43. char buf[4096];
  44. char buf2[4096];
  45. memcpy(buf,buf2,4096);
  46. byte_copy(buf,4096,buf2);
  47. rdtscl(a);
  48. memcpy(buf,buf2,4096);
  49. rdtscl(b);
  50. byte_copy(buf,4096,buf2);
  51. rdtscl(c);
  52. printf("memcpy: %d - byte_copy: %d\n",b-a,c-b);
  53. #endif
  54. #if 0
  55. char ip[16];
  56. int i;
  57. if ((i=scan_ip6(argv[1],ip))) {
  58. char buf[128];
  59. buf[fmt_ip6(buf,ip)]=0;
  60. puts(buf);
  61. }
  62. #endif
  63. #if 0
  64. char buf[100];
  65. strcpy(buf,"foobarbaz");
  66. buf[fmt_fill(buf,3,5,100)]=0;
  67. printf("\"%s\"\n",buf);
  68. #endif
  69. #if 0
  70. unsigned long len;
  71. char *c=mmap_read("/etc/passwd",&len);
  72. printf("got map %p of len %lu\n",c,len);
  73. #endif
  74. #if 0
  75. char c;
  76. printf("%d\n",buffer_getc(buffer_0,&c));
  77. printf("%c\n",c);
  78. #endif
  79. #if 0
  80. char buf[100]="01234567890123456789012345678901234567890123456789";
  81. long a,b,c;
  82. #endif
  83. #if 0
  84. buf[ip4_fmt(buf,ip4loopback)]=0;
  85. buffer_puts(buffer_1small,buf);
  86. buffer_flush(buffer_1small);
  87. #endif
  88. #if 0
  89. buf[0]=0;
  90. buf[fmt_8long(buf,0)]=0;
  91. puts(buf);
  92. rdtscl(a);
  93. c=str_len(buf);
  94. rdtscl(b);
  95. /*byte_zero_djb(buf,j); */
  96. // printf("\n%lu %d\n",b-a,c);
  97. #endif
  98. #if 0
  99. buffer_puts(buffer_1small,"hello, world\n");
  100. buffer_flush(buffer_1small);
  101. #endif
  102. #if 0
  103. int s=socket_tcp4();
  104. char ip[4]={127,0,0,1};
  105. int t=socket_connect4(s,ip,80);
  106. #endif
  107. #if 0
  108. char buf[100]="foo bar baz fnord ";
  109. char buf2[100]="foo braz fnord";
  110. long a,b,c;
  111. long i=0,j=0,k=0;
  112. double d;
  113. uint32 l,m,n;
  114. stralloc sa={0};
  115. stralloc_copys(&sa,"fnord");
  116. stralloc_catlong0(&sa,-23,5);
  117. stralloc_append(&sa,"\n");
  118. printf("%d %d\n",str_equal("fnord","fnord1"),str_equal("fnord1","fnord"));
  119. write(1,sa.s,sa.len);
  120. printf("%d %d\n",stralloc_starts(&sa,"fnord"),stralloc_starts(&sa,"fnord\na"));
  121. l=0xdeadbeef;
  122. uint32_pack_big((char*)&m,l);
  123. uint32_unpack_big((char*)&m,&n);
  124. printf("%x %x %x\n",l,m,n);
  125. rdtscl(a);
  126. /* i=scan_double("3.1415",&d); */
  127. rdtscl(b);
  128. /*byte_zero_djb(buf,j); */
  129. rdtscl(c);
  130. printf("%lu %lu\n",b-a,c-b);
  131. #endif
  132. }