home *** CD-ROM | disk | FTP | other *** search
- // Zinc Interface Library - MISC.CPP
- // COPYRIGHT (C) 1990, 1991. All Rights Reserved.
- // Zinc Software Incorporated. Pleasant Grove, Utah USA
-
- #pragma inline
-
- #include "ui_gen.hpp"
- #include <dos.h>
- #include <stdio.h>
- #include <string.h>
-
- int EXPORT _countryCode;
- struct ui_country_info EXPORT _countryInfo;
-
- void EXPORT ui_getcountryinfo()
- {
- static int gotInfo = FALSE;
-
- if (!gotInfo)
- {
- gotInfo = TRUE;
- _DX = (USHORT) &_countryInfo;
- _AX = 0x3800;
- geninterrupt(0x21);
- _countryCode = (_AL == 0xFF) ? _BX : _AL;
- }
- }
-
- int EXPORT ui_parse_range(char *buffer, int offset, char *minValue, char *maxValue)
- {
- // Get the minimum value.
- int position = 0;
- while (buffer[offset] != '\0' &&
- (buffer[offset] != '.' || buffer[offset+1] != '.') &&
- buffer[offset] != '/')
- minValue[position++] = buffer[offset++];
- minValue[position] = '\0';
-
- // See if it is a standalone value.
- if (buffer[offset] == '/' || buffer[offset] == '\0')
- {
- strcpy(maxValue, minValue);
- return(++offset);
- }
-
- // Increment the offset.
- while (buffer[offset] && buffer[offset] == '.')
- offset++;
-
- // Get the maximum value.
- position = 0;
- while (buffer[offset] != '\0' && buffer[offset] != '/')
- maxValue[position++] = buffer[offset++];
- maxValue[position] = '\0';
-
- // Return the offset.
- return(++offset);
- }
-
- char * EXPORT ui_strdup(const char *srcString)
- {
- // strdup using new instead of malloc.
- if (!srcString || srcString[0] == '\0')
- return (NULL);
- char *destString = new char[strlen(srcString) + 1];
- strcpy(destString, srcString);
- return (destString);
- }
-
- int EXPORT ui_strlen(const char *string)
- {
- int index = 0;
-
- // strlen that checks for null.
- while (*string)
- {
- index++;
- string++;
- }
- return (index);
- }
-
- void EXPORT ui_strrepc(char *str, int c, int repc)
- {
- // Replace a character (c) in a string (str) to a new character (repc).
- if (!str)
- return;
-
- while (*str)
- {
- if (*str == c)
- *str = repc;
- str++;
- }
- }
-
- USHORT EXPORT ui_time()
- {
- #ifdef ZIL_MSWINDOWS
- return(GetTickCount());
- #else
- return(*((USHORT far *)0x46CL));
- #endif
- }
-