home *** CD-ROM | disk | FTP | other *** search
/ Steganos Hacker Tools / SHT151.iso / programme / scanner / nmapNTsp1 / Win_2000.exe / nmapNT-src / nmapNT / winfix.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-15  |  1.9 KB  |  113 lines

  1. #include <winclude.h>
  2. #include <sys/timeb.h>
  3.  
  4. int gettimeofday(struct timeval *tv, struct timezone *tz)
  5. {
  6. //    time_t ltime;
  7.     struct _timeb timebuffer;
  8.  
  9.     _ftime( &timebuffer );
  10.  
  11.     tv->tv_sec=timebuffer.time;
  12.     tv->tv_usec=((timebuffer.time * 1000)+timebuffer.millitm)*100;
  13.     return 0;
  14. };
  15.  
  16. unsigned int sleep(unsigned int seconds)
  17. {
  18.     Sleep(1000*seconds);
  19.     return(0);
  20. };
  21.  
  22. void usleep(unsigned long usec)
  23. {
  24.     int actual;
  25.  
  26.     actual = usec/1000;
  27.  
  28.     Sleep(actual);
  29.     return;
  30. };
  31.  
  32. //strcasecmp
  33.  
  34. int strcasecmp(const char *s1, const char *s2)
  35. {
  36.     int ret;
  37.  
  38.     char *cp1,*cp2;
  39.     int i=0;
  40.  
  41.     cp1=malloc(strlen(s1)+1);
  42.     memset(cp1,0,strlen(s1)+1);
  43.     memcpy(cp1,s1,strlen(s1));
  44.     for (i=0; cp1[i]>0; i++)
  45.     {
  46.         if ('a' <= cp1[i] && cp1[i] <= 'z')
  47.             cp1[i] -= 32;
  48.     }
  49.  
  50.     cp2=malloc(strlen(s2)+1);
  51.     memset(cp2,0,strlen(s2)+1);
  52.     memcpy(cp2,s2,strlen(s2));
  53.     for (i=0; cp2[i]>0; i++)
  54.     {
  55.         if ('a' <= cp2[i] && cp2[i] <= 'z')
  56.             cp2[i] -= 32;
  57.     }
  58.  
  59.  
  60.     ret=strcmp(cp1,cp2);
  61.     return ret;
  62. }
  63.  
  64. int strncasecmp(const char *s1, const char *s2, size_t n)
  65. {
  66.     int ret;
  67.         char *cp1,*cp2;
  68.     int i=0;
  69.  
  70.     cp1=malloc(strlen(s1)+1);
  71.     memset(cp1,0,strlen(s1)+1);
  72.     memcpy(cp1,s1,strlen(s1));
  73.     for (i=0; cp1[i]>0; i++)
  74.     {
  75.         if ('a' <= cp1[i] && cp1[i] <= 'z')
  76.             cp1[i] -= 32;
  77.     }
  78.  
  79.     cp2=malloc(strlen(s2)+1);
  80.     memset(cp2,0,strlen(s2)+1);
  81.     memcpy(cp2,s2,strlen(s2));
  82.     for (i=0; cp2[i]>0; i++)
  83.     {
  84.         if ('a' <= cp2[i] && cp2[i] <= 'z')
  85.             cp2[i] -= 32;
  86.     }
  87.  
  88.  
  89.  
  90.     ret=strncmp(cp1,cp2,n);
  91.     return ret;
  92. }
  93.  
  94. void StartWinsock()
  95. {
  96.     WORD werd;
  97.     WSADATA data;
  98.  
  99.     werd = MAKEWORD( 1, 1 );
  100. //    printf("Attempting to start winsock... ");
  101.     if( (WSAStartup(werd, &data)) !=0 ){
  102.         printf("failed to start winsock.\n");
  103.         exit(1);
  104.     }
  105.     else{
  106. //        printf("started winsock.\n\n");
  107.     }
  108. }
  109.  
  110. void StopWinsock()
  111. {
  112.     WSACleanup();
  113. }