aboutsummaryrefslogtreecommitdiffstats
path: root/Str.h
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:05:14 +0000
committerTatsuya Kinoshita <tats@vega.ocn.ne.jp>2011-05-04 07:05:14 +0000
commit72f72d64a422d6628c4796f5c0bf2e508f134214 (patch)
tree0c9ea90cc53310832c977265521fb44db24a515e /Str.h
parentAdding upstream version 0.3 (diff)
downloadw3m-1ef51c20e0ea7b35c8c9cad6f9d9bc1e16664cc5.tar.gz
w3m-1ef51c20e0ea7b35c8c9cad6f9d9bc1e16664cc5.zip
Adding upstream version 0.5.1upstream/0.5.1
Diffstat (limited to 'Str.h')
-rw-r--r--Str.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/Str.h b/Str.h
new file mode 100644
index 0000000..af0b2de
--- /dev/null
+++ b/Str.h
@@ -0,0 +1,83 @@
+/* $Id: Str.h,v 1.5 2003/01/20 15:30:19 ukai Exp $ */
+/*
+ * String manipulation library for Boehm GC
+ *
+ * (C) Copyright 1998-1999 by Akinori Ito
+ *
+ * This software may be redistributed freely for this purpose, in full
+ * or in part, provided that this entire copyright notice is included
+ * on any copies of this software and applications and derivations thereof.
+ *
+ * This software is provided on an "as is" basis, without warranty of any
+ * kind, either expressed or implied, as to any matter including, but not
+ * limited to warranty of fitness of purpose, or merchantability, or
+ * results obtained from use of this software.
+ */
+#ifndef GC_STR_H
+#define GC_STR_H
+#include <stdio.h>
+#include <string.h>
+#ifdef __EMX__
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+#endif
+
+typedef struct _Str {
+ char *ptr;
+ int length;
+ int area_size;
+} *Str;
+
+Str Strnew();
+Str Strnew_size(int);
+Str Strnew_charp(char *);
+Str Strnew_charp_n(char *, int);
+Str Strnew_m_charp(char *, ...);
+Str Strdup(Str);
+void Strclear(Str);
+void Strfree(Str);
+void Strcopy(Str, Str);
+void Strcopy_charp(Str, char *);
+void Strcopy_charp_n(Str, char *, int);
+void Strcat_charp_n(Str, char *, int);
+void Strcat(Str, Str);
+void Strcat_charp(Str, char *);
+void Strcat_m_charp(Str, ...);
+Str Strsubstr(Str, int, int);
+void Strinsert_char(Str, int, char);
+void Strinsert_charp(Str, int, char *);
+void Strdelete(Str, int, int);
+void Strtruncate(Str, int);
+void Strlower(Str);
+void Strupper(Str);
+void Strchop(Str);
+void Strshrink(Str, int);
+void Strshrinkfirst(Str, int);
+void Strremovefirstspaces(Str);
+void Strremovetrailingspaces(Str);
+Str Stralign_left(Str, int);
+Str Stralign_right(Str, int);
+Str Stralign_center(Str, int);
+
+Str Sprintf(char *fmt, ...);
+
+Str Strfgets(FILE *);
+Str Strfgetall(FILE *);
+
+void Strgrow(Str s);
+
+#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)
+#define Strcmp(x,y) strcmp((x)->ptr,(y)->ptr)
+#define Strcmp_charp(x,y) strcmp((x)->ptr,(y))
+#define Strncmp(x,y,n) strncmp((x)->ptr,(y)->ptr,(n))
+#define Strncmp_charp(x,y,n) strncmp((x)->ptr,(y),(n))
+#define Strcasecmp(x,y) strcasecmp((x)->ptr,(y)->ptr)
+#define Strcasecmp_charp(x,y) strcasecmp((x)->ptr,(y))
+#define Strncasecmp(x,y,n) strncasecmp((x)->ptr,(y)->ptr,(n))
+#define Strncasecmp_charp(x,y,n) strncasecmp((x)->ptr,(y),(n))
+
+#define Strlastchar(s) ((s)->length>0?(s)->ptr[(s)->length-1]:'\0')
+#define Strinsert(s,n,p) Strinsert_charp((s),(n),(p)->ptr)
+#define Strshrinkfirst(s,n) Strdelete((s),0,(n))
+#define Strfputs(s,f) fwrite((s)->ptr,1,(s)->length,(f))
+#endif /* not GC_STR_H */