home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lr.zip / U.INC < prev    next >
Text File  |  1993-05-15  |  2KB  |  54 lines

  1. /*
  2. ______________________________________________________________________________
  3. Utilities
  4. Philip R Brenan, Transcendental Automation, 1992, 800-FOR-PHIL
  5. ______________________________________________________________________________
  6. */
  7. #ifndef U_INC
  8. #define U_INC
  9. #include <ctype.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. /*
  14. ______________________________________________________________________________
  15. Constants
  16. ______________________________________________________________________________
  17. */
  18. #define u_comment_char '*' // Comment marker if column 1
  19. /*
  20. ______________________________________________________________________________
  21. Utility routines
  22. ______________________________________________________________________________
  23. */
  24. void  u_edit_ds       (char *ds);
  25. char *u_load_ds       (char *ds);
  26. void u_free_ds        (char *ds);
  27. char *u_strip_comments(char *ds);
  28.  
  29. void  u_test(void);
  30. /*
  31. ______________________________________________________________________________
  32. Zero a structure
  33. ______________________________________________________________________________
  34. */
  35. #define u_zero(p) (memset(&p, 0, sizeof(p)))
  36. /*
  37. ______________________________________________________________________________
  38. Add to non null pointer
  39. ______________________________________________________________________________
  40. */
  41. #define u_ptr_add(p, i) (p ? (p = (void *)((char *)p + (i))) : 0)
  42. /*
  43. ______________________________________________________________________________
  44. Create string of specified width, padded with blanks or truncated
  45. ______________________________________________________________________________
  46. */
  47. #define u_str_fix(t, s)  \
  48.  (memset (t, ' ', sizeof t), \
  49.   strncpy(t, s, strlen(s) < sizeof t ? strlen(s) : sizeof(t)), \
  50.   t[sizeof t - 1] = 0, \
  51.   t \
  52.  )
  53.  
  54. #endif