home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Multimedia Jumpstart 1.1a / CD_ROM.BIN / develpmt / source / hotspot / viewer / util.c < prev   
Encoding:
C/C++ Source or Header  |  1993-10-05  |  2.3 KB  |  83 lines

  1. /**************************************************************************
  2.  *
  3.  *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4.  *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5.  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6.  *  PURPOSE.
  7.  *
  8.  *  Copyright (c) 1993  Microsoft Corporation.  All Rights Reserved.
  9.  * 
  10.  **************************************************************************/
  11. /******************
  12.     
  13.     util.c --
  14.     
  15.     Utility functions for use in DLL: FindToken, StrToInt
  16.     
  17. ******************/ 
  18.  
  19. #include <windows.h>
  20. #include <mmsystem.h>
  21. #include <digitalv.h>
  22. #include <viewer.h>
  23. #include <string.h>
  24.  
  25. #include "hotspot.h"
  26.  
  27. /*********************************************************************************************
  28.     FUNCTION:   FindToken(LPSTR, char)
  29.     
  30.     PURPOSE:    Like C library strtok() function; 
  31.                 accepts one char instead of a string of chars                
  32. *********************************************************************************************/
  33. LPSTR FindToken(LPSTR psz, char c)
  34. {
  35.     static int len;
  36.     int i = 0;
  37.     static int start = 0;
  38.     static char far retbuf[129];
  39.     static char far storebuf[512];
  40.     
  41.     if (psz != NULL)
  42.         {
  43.         len = lstrlen(psz);
  44.         _fmemcpy(storebuf, psz, len);
  45.         i = start = 0;
  46.         }
  47.     i = 0;
  48.     while (storebuf[i+start] != c && i+start < len)
  49.         {   
  50.         retbuf[i] = storebuf[i+start];        
  51.         ++i;
  52.         }
  53.     retbuf[i] = 0;
  54.     start = start + i + 1;
  55.     if (i == 0)
  56.         return NULL;
  57.     else        
  58.         return (retbuf);
  59. }
  60.  
  61. /*********************************************************************************************
  62.     FUNCTION:   StrToInt(LPSTR)
  63.     
  64.     PURPOSE:    Converts a LPSTR to an int; like C library atol() function
  65. *********************************************************************************************/
  66. int StrToInt(LPSTR lpstr)
  67. {
  68.     static int ret = 0;    
  69.     int ten = 1;    
  70.     int i;            
  71.     int len = lstrlen(lpstr);
  72.  
  73.     ret = 0;      
  74.     for (i = len - 1; i > -1; i--)
  75.         {
  76.         ret = ret + (ten * (lpstr[i] - '0'));
  77.         ten = ten * 10;
  78.         }
  79.     return (ret);
  80. }
  81.  
  82.  
  83.