home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dokpr1.zip / mlib.h < prev    next >
C/C++ Source or Header  |  1995-11-07  |  5KB  |  140 lines

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *                                                                        *
  4.  *          This code is copyright (c)  1994  & 1995                      *
  5.  *                     Athena Design, Inc.                                *
  6.  *                                                                        *
  7.  *                                                                        *
  8.  *                ALL RIGHTS RESERVED                                     *
  9.  *                                                                        *
  10.  *                                                                        *
  11.  *                                                                        *
  12.  *                                                                        *
  13.  *                                                                        *
  14.  **************************************************************************/
  15. #ifndef _mh_TAG_MLIB__
  16.  
  17. #define _mh_TAG_MLIB__
  18.  
  19. #include "base.h"
  20.  
  21. #include "mmath.h"
  22. #include "mversion.h"
  23.  
  24. extern "C"
  25. {
  26. extern int MStrLen(const char *);
  27. extern int MByteLen(const char *s);
  28.  
  29. extern char *MStrNCpy(char *,const char *,int);
  30. //extern void BCopy(const void *,void *,int);
  31. extern void MMemSet(void *,int,int);
  32. extern int MStrCmp(const char *,const char *);
  33. extern void MStrUpr(char *);
  34. extern int MStrNCmp(const char *,const char *,int);
  35. extern int MStrCmpCI(const char *,const char *);
  36. extern int MStrNCmpCI(const char *,const char *,int);
  37. extern char *MStrCat(char *,const char *);
  38. extern char *MStrChr(char *,char);
  39. extern const char *MStrConstChr(const char *,char);
  40. extern int MStrCspn(const char *,const char *);
  41. extern int MStrCspnCI(const char *,const char *);
  42. extern int matchStrings(const char *isIn,const char *string,int exact,int caseSensitive);
  43. extern const char *passWhiteSpace(const char *);
  44. inline const char *passW(const char *s) {return passWhiteSpace(s);}
  45.  
  46. /*
  47. #if !defined(__HIGHC__) && !defined(M2MAC)
  48. inline void memset(void *vp,int v,int cnt)
  49. {
  50.     char *cp = (char *) vp;
  51.     
  52.     while (cnt--) *(cp++) = v;
  53. }
  54. #endif
  55. */
  56.  
  57. extern int MAtoI(const char *);
  58. extern float MAtoF(const char *);
  59. extern  char *MStrSubstitute( const char *target, const char *find, const char *replace, int caseSens = 0);
  60.  
  61. // sorts two integers
  62. extern void sort(int &,int &);
  63.  
  64. // these will have to be changed for non-byte-sized char sets
  65.  
  66.  
  67. #ifdef M2ASCII
  68. inline int isChar(char c) {
  69.     if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) return 1; else return 0;}
  70. inline int isNumberChar(char c) {if (c >= '0' && c <= '9') return 1; return 0;}
  71. inline const char *nextConstChar(const char *t) {return t + 1;}
  72. inline char *nextChar(char *t) {return t + 1;}
  73.  
  74. // return the position in the string of the nth character
  75. inline int charPos(const char *,int t) {return t;}
  76.  
  77. inline int MToUpper(int i) {if (i >= 'a' && i <= 'z') return i - 32; return i;}
  78.  
  79. inline void copyChar(const char *s,char *&t) {*(t++) = *s;}
  80. #endif
  81.  
  82. #ifndef M_PI
  83. #define M_PI 3.14159265358979323846
  84. #endif
  85.  
  86. inline int MWordAlign(int i) {return i + ((i & 1)|((i&2)^((i&1)<<1)));}
  87. inline double radtodeg(double d) {return (d / M_PI) * 180.0;}
  88. inline double degtorad(double d) {return (d / 180.0) * M_PI;}
  89.  
  90. // round a number to n digits.  n can be negative
  91. double MRound(double,int);
  92. double MRoundInt(double);
  93.  
  94. // does a bounds check for an input string and its maximum size
  95. // it reallocates the string if it needs more space
  96. void checkSizeChar(char *&,const char *,int &);
  97. void checkSize(char *&,int,int &);
  98.  
  99. #ifdef M2Z
  100. #define DEFAULTAPPNAME "Mesa2"
  101. #else
  102. #define DEFAULTAPPNAME "Mesa"
  103. #endif
  104.  
  105. int getIntDefault(const char *thing, int def,const char *  = DEFAULTAPPNAME);
  106. char *getDefault(const char *thing, const char *def ,const char * = DEFAULTAPPNAME );
  107. char *getBasicDefault(const char *thing);
  108. void *getDefaultData(const char *,int *,const char * = DEFAULTAPPNAME);
  109.  
  110. void setIntDefault( const char *thing, int def,const char *  = DEFAULTAPPNAME);
  111. void setDefault( const char *thing, const char *def,const char * = DEFAULTAPPNAME );
  112. void setDefaultData(const char *,const void *,int ,const char * = DEFAULTAPPNAME);
  113.  
  114. double MStrtod( const char *, char ** );
  115.  
  116. inline void MStrCpy(char *d,const char *s)
  117. {
  118.     while (*s)
  119.         *(d++) = *(s++);
  120.     
  121.     *d = 0;
  122. }
  123.  
  124. inline void BCopy(const void *sv, void *sd,int n)
  125. {
  126.     const char *s = (const char *) sv;
  127.     char *d = (char *) sd;
  128.     
  129.     while (n--)
  130.         *(d++) = *(s++);
  131. }
  132.  
  133.  
  134. const char *getMesaVersion();
  135. int getMesaRevision();
  136.  
  137. }
  138.  
  139. #endif
  140.