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.
 
 
 
 

98 lines
2.0 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 <stdio.h>
  12. #define rdtscl(low) \
  13. __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
  14. int main(int argc,char* argv[]) {
  15. char ip[16];
  16. int i;
  17. if ((i=scan_ip6(argv[1],ip))) {
  18. char buf[128];
  19. buf[fmt_ip6(buf,ip)]=0;
  20. puts(buf);
  21. }
  22. #if 0
  23. char buf[100];
  24. strcpy(buf,"foobarbaz");
  25. buf[fmt_fill(buf,3,5,100)]=0;
  26. printf("\"%s\"\n",buf);
  27. #endif
  28. #if 0
  29. unsigned long len;
  30. char *c=mmap_read("/etc/passwd",&len);
  31. printf("got map %p of len %lu\n",c,len);
  32. #endif
  33. #if 0
  34. char c;
  35. printf("%d\n",buffer_getc(buffer_0,&c));
  36. printf("%c\n",c);
  37. #endif
  38. #if 0
  39. char buf[100]="01234567890123456789012345678901234567890123456789";
  40. long a,b,c;
  41. #endif
  42. #if 0
  43. buf[ip4_fmt(buf,ip4loopback)]=0;
  44. buffer_puts(buffer_1small,buf);
  45. buffer_flush(buffer_1small);
  46. #endif
  47. #if 0
  48. buf[0]=0;
  49. buf[fmt_8long(buf,0)]=0;
  50. puts(buf);
  51. rdtscl(a);
  52. c=str_len(buf);
  53. rdtscl(b);
  54. /*byte_zero_djb(buf,j); */
  55. // printf("\n%lu %d\n",b-a,c);
  56. #endif
  57. #if 0
  58. buffer_puts(buffer_1small,"hello, world\n");
  59. buffer_flush(buffer_1small);
  60. #endif
  61. #if 0
  62. int s=socket_tcp4();
  63. char ip[4]={127,0,0,1};
  64. int t=socket_connect4(s,ip,80);
  65. #endif
  66. #if 0
  67. char buf[100]="foo bar baz fnord ";
  68. char buf2[100]="foo braz fnord";
  69. long a,b,c;
  70. long i=0,j=0,k=0;
  71. double d;
  72. uint32 l,m,n;
  73. stralloc sa={0};
  74. stralloc_copys(&sa,"fnord");
  75. stralloc_catlong0(&sa,-23,5);
  76. stralloc_append(&sa,"\n");
  77. printf("%d %d\n",str_equal("fnord","fnord1"),str_equal("fnord1","fnord"));
  78. write(1,sa.s,sa.len);
  79. printf("%d %d\n",stralloc_starts(&sa,"fnord"),stralloc_starts(&sa,"fnord\na"));
  80. l=0xdeadbeef;
  81. uint32_pack_big((char*)&m,l);
  82. uint32_unpack_big((char*)&m,&n);
  83. printf("%x %x %x\n",l,m,n);
  84. rdtscl(a);
  85. /* i=scan_double("3.1415",&d); */
  86. rdtscl(b);
  87. /*byte_zero_djb(buf,j); */
  88. rdtscl(c);
  89. printf("%lu %lu\n",b-a,c-b);
  90. #endif
  91. }