"Fossies" - the Fresh Open Source Software Archive

Member "quotactl-1.00/giraffe/include/girstring.h" (28 Aug 2005, 2497 Bytes) of package /linux/privat/old/quotactl-1.00.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "girstring.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef GIRSTRING_H_INCLUDED
    2 #define GIRSTRING_H_INCLUDED
    3 #include <features.h>  // for __BEGIN_DECLS
    4 
    5 __BEGIN_DECLS
    6 
    7 /* The file including this must declare _GNU_SOURCE */
    8 
    9 #include <string.h>
   10 #include <stdio.h>
   11 #include <stdarg.h>
   12 #include <stdlib.h>
   13 #ifndef __cplusplus
   14 #include <stdbool.h>
   15 #endif
   16 
   17 char
   18 stripeq(const char * const comparand, const char * const comparator);
   19 
   20 char
   21 stripcaseeq(const char * const comparand, const char * const comparator);
   22 
   23 void
   24 stripcpy(char * dest, const char * source);
   25 
   26 void
   27 stripcasecpy(char * dest, const char * source);
   28 
   29 char *
   30 stripdup(const char * const input);
   31 
   32 char *
   33 strcasedup(const char input[]);
   34 
   35 static inline bool
   36 streq(const char * const comparator,
   37       const char * const comparand) {
   38 
   39     return (strcmp(comparand, comparator) == 0);
   40 }
   41 
   42 static inline const char *
   43 sdup(const char * const input) {
   44     return (const char *) strdup(input);
   45 }
   46 
   47 inline static void
   48 cvasprintf(const char ** const retvalP, 
   49            const char *  const fmt,
   50            va_list             varargs) {
   51 
   52     char *retval;
   53 
   54     vasprintf(&retval, fmt, varargs);
   55 
   56     *retvalP = retval;
   57 }
   58 
   59 
   60 inline static void __attribute__ ((__format__ (__printf__, 2, 3)))
   61 casprintf(const char ** const retvalP, const char * const fmt, ...) {
   62 
   63     va_list varargs;  /* mysterious structure used by variable arg facility */
   64 
   65     va_start(varargs, fmt); /* start up the mysterious variable arg facility */
   66 
   67     cvasprintf(retvalP, fmt, varargs);
   68 
   69     va_end(varargs);
   70 }
   71 
   72 
   73 inline static void
   74 freeString(const char * const arg) {
   75     free((void *) arg);
   76 }
   77 
   78 inline static void
   79 strfree(const char * const arg) {
   80     free((void *) arg);
   81 }
   82 
   83 void
   84 format_text(char          const input[], 
   85             const char ** const outputP, 
   86             int           const ncolumns,
   87             int *         const nlinesP);
   88 
   89 /* Copy string pointed by B to array A with size checking.  */
   90 #define STRSCPY(A,B) \
   91     (strncpy((A), (B), sizeof(A)), *((A)+sizeof(A)-1) = '\0')
   92 #define STRSCMP(A,B) \
   93     (strncmp((A), (B), sizeof(A)))
   94 
   95 #define STRFCPY(A,B) STRSCPY(A,B)
   96 #define STRFCMP(A,B) STRSCMP(A,B)
   97 
   98 /* Concatenate string B onto string in array A with size checking */
   99 #define STRSCAT(A,B) \
  100     (strncat((A), (B), sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')
  101 
  102 /* Format string into A with size checking */
  103 #define SSPRINTF(TARGET, REST...) \
  104   (snprintf(TARGET, sizeof(TARGET) , ## REST)) 
  105 
  106 
  107 const char *
  108 asciihex(unsigned char const bytes[],
  109          unsigned int  const len);
  110 
  111 __END_DECLS
  112 
  113 #endif
  114