home *** CD-ROM | disk | FTP | other *** search
/ Micro R&D 1 / MicroRD-CD-ROM-Vol1-1994.iso / os20 / util / trumultiassigns.lha / clib.h next >
C/C++ Source or Header  |  1992-08-12  |  804b  |  49 lines

  1. #ifndef _CLIB_H
  2. #define _CLIB_H
  3.  
  4. // varargs functions better be done with macros, because they're not
  5. // inline'able
  6. #define printf(_fmt, _args...) \
  7.   ({ void *_argv[] = { _args }; VPrintf (_fmt, _argv); })
  8.  
  9. extern inline const char *
  10. index (const char *s, char ch)
  11. {
  12.   char *sp = (char *) s;
  13.  
  14.   do
  15.     if (*sp == ch)
  16.       return (const char *) sp;
  17.   while (*++sp);
  18.   return 0;
  19. }
  20.  
  21. extern inline const char *
  22. rindex (const char *s, char ch)
  23. {
  24.   char *last = 0;
  25.   do
  26.     if (*s == ch)
  27.       last = (char *) s;
  28.   while (*++s);
  29.   return (const char *) last;
  30. }
  31.  
  32. extern inline u_long
  33. strlen (const char *s)
  34. {
  35.   const char *start = s;
  36.   while (*s++) ;
  37.   return s - start;
  38. }
  39.  
  40. extern inline char *
  41. strcpy (char *d, const char *s)
  42. {
  43.   char *tgt = d;
  44.   while (*d++ = *s++) ;
  45.   return tgt;
  46. }
  47.  
  48. #endif /* _CLIB_H */
  49.