summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael Jennings <mej@kainx.org>2004-07-20 22:32:08 +0000
committerMichael Jennings <mej@kainx.org>2004-07-20 22:32:08 +0000
commitbad139c9111100c83b169bd8ce1ae2cad8560567 (patch)
treed762eb1bb3e0a630a1a4751d636665a684c61263 /include
parent08ac6c9566b474b1cbe7affbd4e13a2fffa73ccb (diff)
downloadlibast-bad139c9111100c83b169bd8ce1ae2cad8560567.tar.gz
Tue Jul 20 18:30:54 2004 Michael Jennings (mej)
Tasty treats! ---------------------------------------------------------------------- SVN revision: 10948
Diffstat (limited to 'include')
-rw-r--r--include/libast.h68
-rw-r--r--include/libast_internal.h25
2 files changed, 50 insertions, 43 deletions
diff --git a/include/libast.h b/include/libast.h
index f15f389..9b1f767 100644
--- a/include/libast.h
+++ b/include/libast.h
@@ -274,7 +274,11 @@ extern int re_exec();
* @param a The first variable.
* @param b The second variable.
*/
-#define BINSWAP(a, b) (((long) (a)) ^= ((long) (b)) ^= ((long) (a)) ^= ((long) (b)))
+#if STRICT_ISO_C99
+# define BINSWAP(a, b) SWAP(a, b)
+#else
+# define BINSWAP(a, b) (((long) (a)) ^= ((long) (b)) ^= ((long) (a)) ^= ((long) (b)))
+#endif
/**
* Make sure a char pointer is non-NULL before printing it.
@@ -1095,7 +1099,7 @@ extern int re_exec();
# define CALLOC(type,n) spifmem_calloc(__FILE__, __LINE__, (n), (sizeof(type)))
# define REALLOC(mem,sz) spifmem_realloc(#mem, __FILE__, __LINE__, (mem), (sz))
# define FREE(ptr) do { spifmem_free(#ptr, __FILE__, __LINE__, (ptr)); (ptr) = NULL; } while (0)
-# define STRDUP(s) spifmem_strdup(#s, __FILE__, __LINE__, (s))
+# define STRDUP(s) spifmem_strdup(#s, __FILE__, __LINE__, (char *) (s))
# define MALLOC_DUMP() spifmem_dump_mem_tables()
# define X_CREATE_PIXMAP(d, win, w, h, depth) spifmem_x_create_pixmap(__FILE__, __LINE__, (d), (win), (w), (h), (depth))
# define X_FREE_PIXMAP(d, p) spifmem_x_free_pixmap(#p, __FILE__, __LINE__, (d), (p))
@@ -1119,7 +1123,7 @@ extern int re_exec();
# define CALLOC(type,n) calloc((n),(sizeof(type)))
# define REALLOC(mem,sz) ((sz) ? ((mem) ? (realloc((mem), (sz))) : (malloc(sz))) : ((mem) ? (free(mem), NULL) : (NULL)))
# define FREE(ptr) do { free(ptr); (ptr) = NULL; } while (0)
-# define STRDUP(s) strdup(s)
+# define STRDUP(s) strdup((char *) s)
# define MALLOC_DUMP() NOP
# define X_CREATE_PIXMAP(d, win, w, h, depth) XCreatePixmap((d), (win), (w), (h), (depth))
# define X_FREE_PIXMAP(d, p) XFreePixmap((d), (p))
@@ -1137,7 +1141,7 @@ extern int re_exec();
#endif
/* Fast memset() macro contributed by vendu */
-#if (SIZEOF_LONG == 8)
+#if !defined(SIZEOF_LONG) || (SIZEOF_LONG == 8)
/** UNDOCUMENTED */
# define MEMSET_LONG() (l |= l<<32)
#else
@@ -1242,7 +1246,7 @@ extern int re_exec();
* @see @link DOXGRP_STRINGS String Utility Routines @endlink
* @ingroup DOXGRP_STRINGS
*/
-#define BEG_STRCASECMP(s, constr) (strncasecmp(s, constr, CONST_STRLEN(constr)))
+#define BEG_STRCASECMP(s, constr) (strncasecmp(SPIF_CAST_C(char *) (s), constr, CONST_STRLEN(constr)))
@@ -1579,27 +1583,27 @@ typedef struct file_state_struct {
*
* Contains the path to the file.
*/
- char *path;
+ spif_charptr_t path;
/**
* Preprocessing output file.
*
* Contains the path to the file used for preprocessing
* output.
*/
- char *outfile;
+ spif_charptr_t outfile;
/**
* Line number.
*
* Contains the current line number for the file.
*/
- unsigned long line;
+ spif_uint32_t line;
/**
* File state flags.
*
* Contains the skip-to-end (FILE_SKIP_TO_END) and preprocessing
* (FILE_PREPROC) flags for the file.
*/
- unsigned char flags;
+ spif_uint8_t flags;
} fstate_t;
/**
@@ -1616,7 +1620,7 @@ typedef struct file_state_struct {
* @see @link DOXGRP_CONF_CTX Context Handling @endlink
* @ingroup DOXGRP_CONF_CTX
*/
-typedef void * (*ctx_handler_t)(char *, void *);
+typedef spif_ptr_t (*ctx_handler_t)(spif_charptr_t, spif_ptr_t);
/**
* Typedef for pointers to built-in functions.
*
@@ -1631,7 +1635,7 @@ typedef void * (*ctx_handler_t)(char *, void *);
* @see @link DOXGRP_CONF Configuration File Parser @endlink
* @ingroup DOXGRP_CONF
*/
-typedef char * (*spifconf_func_ptr_t) (char *);
+typedef spif_charptr_t (*spifconf_func_ptr_t) (spif_charptr_t);
extern fstate_t *fstate;
extern unsigned char fstate_idx;
@@ -2688,7 +2692,7 @@ extern void spifmem_dump_gc_tables(void);
extern void spiftool_free_array(void *, size_t);
/* file.c */
-extern int spiftool_temp_file(char *, size_t);
+extern int spiftool_temp_file(spif_charptr_t, size_t);
/* strings.c */
extern spif_bool_t spiftool_safe_strncpy(spif_charptr_t dest, const spif_charptr_t src, spif_int32_t size);
@@ -2696,22 +2700,22 @@ extern spif_bool_t spiftool_safe_strncat(spif_charptr_t dest, const spif_charptr
extern spif_charptr_t spiftool_substr(const spif_charptr_t, spif_int32_t, spif_int32_t);
#if LIBAST_REGEXP_SUPPORT_POSIX && HAVE_REGEX_H
extern spif_bool_t spiftool_regexp_match(const spif_charptr_t, const spif_charptr_t);
-extern spif_bool_t spiftool_regexp_match_r(const char *str, const char *pattern, regex_t **rexp);
+extern spif_bool_t spiftool_regexp_match_r(const spif_charptr_t str, const spif_charptr_t pattern, regex_t **rexp);
#endif
-extern char **spiftool_split(const char *, const char *);
-extern char **spiftool_split_regexp(const char *, const char *);
-extern char *spiftool_join(const char *, char **);
-extern char *spiftool_get_word(unsigned long, const char *);
-extern char *spiftool_get_pword(unsigned long, const char *);
-extern unsigned long spiftool_num_words(const char *);
-extern char *spiftool_chomp(char *);
-extern char *spiftool_strip_whitespace(char *);
-extern char *spiftool_downcase_str(char *);
-extern char *spiftool_upcase_str(char *);
-extern char *spiftool_safe_str(char *, unsigned short);
-extern char *spiftool_condense_whitespace(char *);
+extern spif_charptr_t *spiftool_split(const spif_charptr_t, const spif_charptr_t);
+extern spif_charptr_t *spiftool_split_regexp(const spif_charptr_t, const spif_charptr_t);
+extern spif_charptr_t spiftool_join(const spif_charptr_t, spif_charptr_t *);
+extern spif_charptr_t spiftool_get_word(unsigned long, const spif_charptr_t);
+extern spif_charptr_t spiftool_get_pword(unsigned long, const spif_charptr_t);
+extern unsigned long spiftool_num_words(const spif_charptr_t);
+extern spif_charptr_t spiftool_chomp(spif_charptr_t);
+extern spif_charptr_t spiftool_strip_whitespace(spif_charptr_t);
+extern spif_charptr_t spiftool_downcase_str(spif_charptr_t);
+extern spif_charptr_t spiftool_upcase_str(spif_charptr_t);
+extern spif_charptr_t spiftool_safe_str(spif_charptr_t, unsigned short);
+extern spif_charptr_t spiftool_condense_whitespace(spif_charptr_t);
extern void spiftool_hex_dump(void *, size_t);
-extern spif_cmp_t spiftool_version_compare(const char *, const char *);
+extern spif_cmp_t spiftool_version_compare(const spif_charptr_t, const spif_charptr_t);
#if !(HAVE_MEMMEM)
extern void *memmem(const void *, size_t, const void *, size_t);
#endif
@@ -2755,16 +2759,16 @@ extern spif_uint32_t spifhash_fnv(spif_uint8_t *key, spif_uint32_t len, spif_uin
/* conf.c */
extern void spifconf_init_subsystem(void);
-extern unsigned char spifconf_register_context(char *name, ctx_handler_t handler);
-extern unsigned char spifconf_register_fstate(FILE *fp, char *path, char *outfile, unsigned long line, unsigned char flags);
+extern unsigned char spifconf_register_context(spif_charptr_t name, ctx_handler_t handler);
+extern unsigned char spifconf_register_fstate(FILE *fp, spif_charptr_t path, spif_charptr_t outfile, unsigned long line, unsigned char flags);
extern unsigned char spifconf_register_builtin(char *name, spifconf_func_ptr_t ptr);
extern unsigned char spifconf_register_context_state(unsigned char ctx_id);
extern void spifconf_free_subsystem(void);
extern spif_charptr_t spifconf_shell_expand(spif_charptr_t);
-extern char *spifconf_find_file(const char *file, const char *dir, const char *pathlist);
-extern FILE *spifconf_open_file(char *name);
-extern void spifconf_parse_line(FILE *fp, char *buff);
-extern char *spifconf_parse(char *conf_name, const char *dir, const char *path);
+extern spif_charptr_t spifconf_find_file(const spif_charptr_t file, const spif_charptr_t dir, const spif_charptr_t pathlist);
+extern FILE *spifconf_open_file(spif_charptr_t name);
+extern void spifconf_parse_line(FILE *fp, spif_charptr_t buff);
+extern spif_charptr_t spifconf_parse(spif_charptr_t conf_name, const spif_charptr_t dir, const spif_charptr_t path);
/* options.c */
extern void spifopt_parse(int, char **);
diff --git a/include/libast_internal.h b/include/libast_internal.h
index bab521c..71b9aa8 100644
--- a/include/libast_internal.h
+++ b/include/libast_internal.h
@@ -57,7 +57,7 @@
#endif
/******************************** MSGS GOOP ***********************************/
-extern char *libast_program_name, *libast_program_version;
+extern spif_charptr_t libast_program_name, libast_program_version;
@@ -135,14 +135,15 @@ typedef struct memrec_t_struct {
*/
#define ctx_name_to_id(the_id, n, i) do { \
for ((i)=0; (i) <= ctx_idx; (i)++) { \
- if (!strcasecmp((n), context[(i)].name)) { \
+ if (!strcasecmp(SPIF_CAST_C(char *) (n), \
+ SPIF_CAST_C(char *) context[(i)].name)) { \
(the_id) = (i); \
break; \
} \
} \
if ((i) > ctx_idx) { \
libast_print_error("Parsing file %s, line %lu: No such context \"%s\"\n", \
- file_peek_path(), file_peek_line(), (n)); \
+ file_peek_path(), file_peek_line(), (n)); \
(the_id) = 0; \
} \
} while (0)
@@ -258,11 +259,12 @@ typedef struct memrec_t_struct {
* @param idx The word number of the context name.
*/
#define ctx_begin(idx) do { \
- char *name; \
+ spif_charptr_t name; \
name = spiftool_get_word(idx, buff); \
ctx_name_to_id(id, name, i); \
ctx_push(id); \
- state = (*ctx_id_to_func(id))(SPIFCONF_BEGIN_STRING, ctx_peek_last_state()); \
+ state = (*ctx_id_to_func(id))(SPIF_CAST(charptr) SPIFCONF_BEGIN_STRING, \
+ ctx_peek_last_state()); \
ctx_poke_state(state); \
FREE(name); \
} while (0)
@@ -277,7 +279,8 @@ typedef struct memrec_t_struct {
*/
#define ctx_end() do { \
if (ctx_get_depth()) { \
- state = (*ctx_id_to_func(id))(SPIFCONF_END_STRING, ctx_peek_state()); \
+ state = (*ctx_id_to_func(id))(SPIF_CAST(charptr) SPIFCONF_END_STRING, \
+ ctx_peek_state()); \
ctx_poke_state(NULL); \
ctx_pop(); \
id = ctx_peek_id(); \
@@ -306,12 +309,12 @@ typedef struct ctx_t_struct {
* value to find the handler for the requested context. This
* comparison is case-insensitive.
*/
- char *name;
+ spif_charptr_t name;
/**
* Context handler.
*
* Pointer to the function which will handle this context.
- * Context handlers must accept two parameters, a char *
+ * Context handlers must accept two parameters, a spif_charptr_t
* containing either the config file line or a begin/end magic
* string, and a void * containing state information; they must
* return a void * which will be passed to the next invocation of
@@ -363,7 +366,7 @@ typedef struct spifconf_func_t_struct {
* The string representation of the built-in function name, not
* including the leading percent sign ('%').
*/
- char *name;
+ spif_charptr_t name;
/**
* Function handler pointer.
*
@@ -390,14 +393,14 @@ typedef struct spifconf_var_t_struct {
* The string representation of the variable name. Variable names
* ARE case-sensitive!
*/
- char *var;
+ spif_charptr_t var;
/**
* Variable value.
*
* The value of the user-defined variable. The value must be a
* text string (obviously, since the config files are text-based.
*/
- char *value;
+ spif_charptr_t value;
/**
* Linked list pointer.
*