home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / FSGFX.ZIP / MYMISC.C < prev    next >
C/C++ Source or Header  |  1990-03-06  |  1KB  |  62 lines

  1. /* mymisc.c */
  2. /* miscellaneous functions which are missing or don't function
  3. properly from MSC 5.1 */
  4. extern long myfilelength(int handle);
  5. long myfilelength(int handle)
  6. {
  7.     long oldposition,newposition;
  8.     oldposition = lseek(handle,0L,SEEK_CUR); save current position 
  9.     newposition = lseek(handle,0L,SEEK_END); determine length of file 
  10.     lseek(handle,oldposition,SEEK_SET);      restore current position 
  11.     return(newposition);
  12. }
  13. int strindex(s, t)
  14. char s[];
  15. char t[];
  16. {
  17. int i, j, k;
  18.  
  19. for (i = 0; s[i] != '\0'; i++)
  20. {
  21. for (j = i, k = 0; t[k] != '\0' && s[j]==t[k]; j++, k++)
  22.     ;
  23.     if (k>0 && t[k] == '\0')
  24.         return i;
  25. }
  26. return -1;
  27. }
  28.  
  29.  
  30. convertuchartobin(a,temp)
  31. unsigned char a;
  32. char temp[];
  33. {
  34.         int i;
  35.         unsigned char b;
  36.         b = 0x80;
  37.         for(i = 0; i<8; i++)
  38.                 {
  39.                 if(a & b)
  40.                         temp[i] = '1';
  41.                 else
  42.                         temp[i] = '0';
  43.                 b = b >> 1;
  44.                 }
  45. }
  46.  
  47. int rjustifystring(char string[])
  48. {
  49.     int i,j;
  50.     char temp[80];
  51.     j = strlen(string);
  52.     if (j < 8)
  53.     {
  54.         for(i=0; i <(8-j); i++)
  55.             temp[i] = 0x20;
  56.         temp[i] = 0;
  57.         strcat(temp,string);
  58.         strcpy(string,temp);
  59.     }
  60. }
  61.  
  62.