w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

Str.h (2738B)


      1 /* $Id$ */
      2 /* 
      3  * String manipulation library for Boehm GC
      4  *
      5  * (C) Copyright 1998-1999 by Akinori Ito
      6  *
      7  * This software may be redistributed freely for this purpose, in full 
      8  * or in part, provided that this entire copyright notice is included 
      9  * on any copies of this software and applications and derivations thereof.
     10  *
     11  * This software is provided on an "as is" basis, without warranty of any
     12  * kind, either expressed or implied, as to any matter including, but not
     13  * limited to warranty of fitness of purpose, or merchantability, or
     14  * results obtained from use of this software.
     15  */
     16 #ifndef GC_STR_H
     17 #define GC_STR_H
     18 #include <stdio.h>
     19 #include <string.h>
     20 #ifdef __EMX__
     21 #define strcasecmp	stricmp
     22 #define strncasecmp	strnicmp
     23 #endif
     24 
     25 typedef struct _Str {
     26     char *ptr;
     27     int length;
     28     int area_size;
     29 } *Str;
     30 
     31 Str Strnew(void);
     32 Str Strnew_size(int);
     33 Str Strnew_charp(char *);
     34 Str Strnew_charp_n(char *, int);
     35 Str Strnew_m_charp(char *, ...);
     36 Str Strdup(Str);
     37 void Strclear(Str);
     38 void Strfree(Str);
     39 void Strcopy(Str, Str);
     40 void Strcopy_charp(Str, char *);
     41 void Strcopy_charp_n(Str, char *, int);
     42 void Strcat_charp_n(Str, char *, int);
     43 void Strcat(Str, Str);
     44 void Strcat_charp(Str, char *);
     45 void Strcat_m_charp(Str, ...);
     46 Str Strsubstr(Str, int, int);
     47 void Strinsert_char(Str, int, char);
     48 void Strinsert_charp(Str, int, char *);
     49 void Strdelete(Str, int, int);
     50 void Strtruncate(Str, int);
     51 void Strlower(Str);
     52 void Strupper(Str);
     53 void Strchop(Str);
     54 void Strshrink(Str, int);
     55 void Strshrinkfirst(Str, int);
     56 void Strremovefirstspaces(Str);
     57 void Strremovetrailingspaces(Str);
     58 Str Stralign_left(Str, int);
     59 Str Stralign_right(Str, int);
     60 Str Stralign_center(Str, int);
     61 
     62 Str Sprintf(char *fmt, ...);
     63 
     64 Str Strfgets(FILE *);
     65 Str Strfgetall(FILE *);
     66 
     67 void Strgrow(Str s);
     68 
     69 #define Strcat_char(x,y) (((x)->length+1>=(x)->area_size)?Strgrow(x),0:0,(x)->ptr[(x)->length++]=(y),(x)->ptr[(x)->length]=0)
     70 #define Strcmp(x,y)                  strcmp((x)->ptr,(y)->ptr)
     71 #define Strcmp_charp(x,y)            strcmp((x)->ptr,(y))
     72 #define Strncmp(x,y,n)               strncmp((x)->ptr,(y)->ptr,(n))
     73 #define Strncmp_charp(x,y,n)         strncmp((x)->ptr,(y),(n))
     74 #define Strcasecmp(x,y)              strcasecmp((x)->ptr,(y)->ptr)
     75 #define Strcasecmp_charp(x,y)        strcasecmp((x)->ptr,(y))
     76 #define Strncasecmp(x,y,n)           strncasecmp((x)->ptr,(y)->ptr,(n))
     77 #define Strncasecmp_charp(x,y,n)     strncasecmp((x)->ptr,(y),(n))
     78 
     79 #define Strlastchar(s)               ((s)->length>0?(s)->ptr[(s)->length-1]:'\0')
     80 #define Strinsert(s,n,p)             Strinsert_charp((s),(n),(p)->ptr)
     81 #define Strshrinkfirst(s,n)          Strdelete((s),0,(n))
     82 #define Strfputs(s,f)                fwrite((s)->ptr,1,(s)->length,(f))
     83 #endif				/* not GC_STR_H */