home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / xdme_1.84_src.lha / XDME / Lib / include / Dyn.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-13  |  2.6 KB  |  90 lines

  1. /******************************************************************************
  2.  
  3.     MODULE
  4.     DYN.h
  5.  
  6.     DESCRIPTION
  7.     Header File for ``Dynamic Strings''
  8.  
  9.     HISTORY
  10.     29-09-94 b_noll created
  11.     13-11-94 b_noll renamed fields
  12.  
  13. ******************************************************************************/
  14.  
  15. #ifndef DYN_H
  16. #define DYN_H 1
  17.  
  18. /**************************************
  19.         Includes
  20. **************************************/
  21.  
  22. #ifndef   EXEC_TYPES_H
  23. #include <exec/types.h>
  24. #endif /* EXEC_TYPES_H */
  25.  
  26. #include <stdarg.h>
  27.  
  28. /**************************************
  29.         Defines & Structures
  30. **************************************/
  31.  
  32. struct _DSTR {
  33.     int   Size;
  34.     int   Length;
  35.     UBYTE str[1];
  36. }; /* struct DSTR */
  37. #define DSTR struct _DSTR *
  38. #define EmptyDyn NULL
  39.  
  40. /**************************************
  41.         Prototypes
  42. **************************************/
  43.  
  44. void  DynInit    (DSTR *pstr);
  45. void  DynClear    (DSTR *pstr);
  46. void  DynDelete (DSTR *pstr);
  47. void  DynReset    (DSTR *pstr);
  48. void  DynErase    (DSTR *pstr);
  49. char *DynValue    (DSTR *pstr);
  50. int   DynSize    (DSTR *pstr);
  51. int   DynLen    (DSTR *pstr);
  52. BOOL  DynDel    (DSTR *pstr, int pos, int chars);
  53. BOOL  DynExpand (DSTR *pstr, int max);
  54. BOOL  DynIns    (DSTR *pstr, const char *src, int pos);
  55. BOOL  DynCat    (DSTR *pstr, const char *src);
  56. BOOL  DynCpy    (DSTR *pstr, const char *src);
  57. BOOL  DynSCpy    (DSTR *pstr, const char *src);
  58. BOOL  DynDIns    (DSTR *pstr, DSTR *src, int pos);
  59. BOOL  DynDCat    (DSTR *pstr, DSTR *src);
  60. BOOL  DynDCpy    (DSTR *pstr, DSTR *src);
  61. BOOL  DynDSCpy    (DSTR *pstr, DSTR *src);
  62. BOOL vDynAppend (DSTR *pstr, int         num,  va_list adds);
  63. BOOL vDynPrintf (DSTR *pstr, const char *tplt, va_list args);
  64. int   DynPutc    (DSTR *pstr, int chr);
  65. BOOL  DynGetFile(DSTR *pstr, const char *name);
  66.  
  67. #ifdef STREAM /* ---- Really so ? */
  68. BOOL DynGIns    (DSTR *pstr, int pos, STREAM instream, char *(read)(STREAM));
  69. #endif
  70.  
  71. #ifndef NO_DYNSTR_MACROS
  72. #define BRA_ do{
  73. #define KET_ }while(0)
  74.  
  75. #define DynInit(pstr)   *(pstr) = EmptyDyn
  76. #define DynDelete(pstr) DynClear(pstr)
  77. #define DynClear(pstr) BRA_ DSTR d;if((d=*(pstr)))free(d);*(pstr)=EmptyDyn; KET_
  78. #define DynReset(pstr) BRA_ DSTR d;if((d=*(pstr)))d->Length=strlen(d->Str); KET_
  79. #define DynErase(pstr) BRA_ DSTR d;if((d=*(pstr)))d->Length=d->Str[0]=0;    KET_
  80. #define DynValue(pstr)  ((*(pstr))? ((*(pstr))->Str): "")
  81. #define DynSize(pstr)   ((*(pstr))? ((*(pstr))->Size): 0)
  82. #define DynLen(pstr)    ((*(pstr))? ((*(pstr))->Length): 0)
  83.  
  84. #endif /* !NO_DYNSTR_MACROS */
  85. #endif /* !DYN_H */
  86.  
  87. /******************************************************************************
  88. *****  END DYN.h
  89. ******************************************************************************/
  90.