calisto-20000323/
calisto-20000323/lib/
calisto-20000323/lib/etc/
calisto-20000323/lib/players/
calisto-20000323/lib/text/
calisto-20000323/log/
/*
 Calisto (c) 1998-1999 Peter Howkins, Matthew Howkins, Simon Howkins

 $Id: strplus.h,v 1.3 2000/01/14 19:53:16 peter Exp $

 $Log: strplus.h,v $
 Revision 1.3  2000/01/14 19:53:16  peter
 Added strchomp() function, reminiscent of Perl's chomp

 Revision 1.2  2000/01/10 22:15:13  peter
 Added STRNCOPY and STRNAPPEND macros to simplify buffer size checks

 Revision 1.1  1999/12/21 20:37:49  peter
 Initial revision


 */
#ifndef strplus_h
#define strplus_h

#include <string.h>

#ifndef BOOL
#define BOOL
typedef int bool;
#define FALSE  ((bool) 0)
#define TRUE   ((bool) 1)
#endif /* BOOL */

#define STREQ(s1, s2) (strcmp(s1, s2) == 0)
#define STRNEQ(s1, s2, n) (strncmp(s1, s2, n) == 0)
#define STRIEQ(s1, s2) (stricmp(s1, s2) == 0)
#define STRINEQ(s1, s2, n) (strnicmp(s1, s2, n) == 0) 

/* Copy ct to s. n is sizeof buffer at s. */
#define STRNCOPY(s, ct, n) ((void) ((n > 0) && \
                                    (strncpy(s, ct, n), (s)[(n) - 1] = '\0')))

/* Append ct to s. n is sizeof buffer at s. */
#define STRNAPPEND(s, ct, n) do { \
                               int len = strlen(s); \
                               if (len < n - 1) \
                                 strncat(s + len, ct, n - len - 1); \
                             } while (0)

void strlower(char *s);
void strupper(char *s);

void strmunch(char *source, char **first, char **rest);

/* If the last character of the string is a \n, remove it, by replacing
   with \0. Do nothing if no \n found.
   Returns number of \n's chomped. (Can only be 0 or 1) */
int strchomp(char *s);

int stricmp(const char *s1, const char *s2);
int strnicmp(const char *s1, const char *s2, size_t n);

bool  strisalnum(const char *s);
bool  strisalpha(const char *s);
bool  striscntrl(const char *s);
bool  strisdigit(const char *s);
bool  strisgraph(const char *s);
bool  strislower(const char *s);
bool  strisprint(const char *s);
bool  strispunct(const char *s);
bool  strisspace(const char *s);
bool  strisupper(const char *s);
bool strisxdigit(const char *s);

char *strip_leading_white_space(const char *s);
void strip_trailing_white_space(char *s);

#endif /* strplus_h */