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 _countryCode;
- struct ui_country_info near _countryInfo; // Make "near" to force into DGROUP.
-
- struct dos2_country
- {
- int date_format;
- char currency[2];
- char thousands[2];
- char decimal[2];
- char reserved[24];
- };
-
- void ui_getcountryinfo()
- {
- static int gotInfo = FALSE;
- static struct dos2_country near dos2_country;
-
- if (!gotInfo)
- {
- gotInfo = TRUE;
- if (_osmajor == 2)
- _DX = (USHORT) &dos2_country;
- else
- _DX = (USHORT) &_countryInfo;
- _AX = 0x3800;
- geninterrupt(0x21);
- _countryCode = (_AL == 0xFF) ? _BX : _AL;
- if (_osmajor == 2)
- {
- memset( &_countryInfo, '\0', sizeof(_countryInfo) );
- _countryInfo.co_date = dos2_country.date_format;
- strcpy(_countryInfo.co_curr, dos2_country.currency);
- strcpy(_countryInfo.co_thsep, dos2_country.thousands);
- strcpy(_countryInfo.co_desep, dos2_country.decimal);
- _countryInfo.co_dtsep[0] = '/';
- _countryInfo.co_tmsep[0] = ':';
- /* Leave co_currstyle set to 0. */
- _countryInfo.co_digits = 2;
- /* Leave co_time set to 0. */
- /* Leave co_case set to 0. */
- _countryInfo.co_dasep[0] = ',';
- }
- }
- }
-
- int 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 *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 ui_strlen(const char *string)
- {
- int index = 0;
-
- // strlen that checks for null.
- while (*string)
- {
- index++;
- string++;
- }
- return (index);
- }
-
- void ui_strrepc(char *str, int c, int repc)
- {
- // Replace a character (c) in a string (str) to a new character (repc).
- while (*str)
- {
- if (*str == c)
- *str = repc;
- str++;
- }
- }
-
- USHORT ui_time()
- {
- return(*((USHORT far *)0x46CL));
- }
-
-