home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / ZINC_5.ZIP / WINSRC.ZIP / MISC.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-01  |  2.1 KB  |  105 lines

  1. //    Zinc Interface Library - MISC.CPP
  2. //    COPYRIGHT (C) 1990, 1991.  All Rights Reserved.
  3. //    Zinc Software Incorporated.  Pleasant Grove, Utah  USA
  4.  
  5. #pragma inline
  6.  
  7. #include "ui_gen.hpp"
  8. #include <dos.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11.  
  12. int EXPORT _countryCode;
  13. struct ui_country_info EXPORT _countryInfo;
  14.  
  15. void EXPORT ui_getcountryinfo()
  16. {
  17.     static int gotInfo = FALSE;
  18.  
  19.     if (!gotInfo)
  20.     {
  21.         gotInfo = TRUE;
  22.         _DX = (USHORT) &_countryInfo;
  23.         _AX = 0x3800;
  24.         geninterrupt(0x21);
  25.         _countryCode = (_AL == 0xFF) ? _BX : _AL;
  26.     }
  27. }
  28.  
  29. int EXPORT ui_parse_range(char *buffer, int offset, char *minValue, char *maxValue)
  30. {
  31.     // Get the minimum value.
  32.     int position = 0;
  33.     while (buffer[offset] != '\0' &&
  34.         (buffer[offset] != '.' || buffer[offset+1] != '.') &&
  35.         buffer[offset] != '/')
  36.         minValue[position++] = buffer[offset++];
  37.     minValue[position] = '\0';
  38.  
  39.     // See if it is a standalone value.
  40.     if (buffer[offset] == '/' || buffer[offset] == '\0')
  41.     {
  42.         strcpy(maxValue, minValue);
  43.         return(++offset);
  44.     }
  45.  
  46.     // Increment the offset.
  47.     while (buffer[offset] && buffer[offset] == '.')
  48.         offset++;
  49.  
  50.     // Get the maximum value.
  51.     position = 0;
  52.     while (buffer[offset] != '\0' && buffer[offset] != '/')
  53.         maxValue[position++] = buffer[offset++];
  54.     maxValue[position] = '\0';
  55.  
  56.     // Return the offset.
  57.     return(++offset);
  58. }
  59.  
  60. char * EXPORT ui_strdup(const char *srcString)
  61. {
  62.     // strdup using new instead of malloc.
  63.     if (!srcString || srcString[0] == '\0')
  64.         return (NULL);
  65.     char *destString = new char[strlen(srcString) + 1];
  66.     strcpy(destString, srcString);
  67.     return (destString);
  68. }
  69.  
  70. int EXPORT ui_strlen(const char *string)
  71. {
  72.     int index = 0;
  73.  
  74.     // strlen that checks for null.
  75.     while (*string)
  76.     {
  77.         index++;
  78.         string++;
  79.     }
  80.     return (index);
  81. }
  82.  
  83. void EXPORT ui_strrepc(char *str, int c, int repc)
  84. {
  85.     // Replace a character (c) in a string (str) to a new character (repc).
  86.     if (!str)
  87.         return;
  88.  
  89.     while (*str)
  90.     {
  91.         if (*str == c)
  92.             *str = repc;
  93.         str++;
  94.     }
  95. }
  96.  
  97. USHORT EXPORT ui_time()
  98. {
  99. #ifdef ZIL_MSWINDOWS
  100.     return(GetTickCount());
  101. #else
  102.     return(*((USHORT far *)0x46CL));
  103. #endif
  104. }
  105.