diff -Nrub clearsilver-0.9.14/cgi/cgi.c clearsilver-0.10.1/cgi/cgi.c --- clearsilver-0.9.14/cgi/cgi.c 2004-12-29 09:24:40.000000000 -0800 +++ clearsilver-0.10.1/cgi/cgi.c 2005-06-30 18:14:36.000000000 -0700 @@ -263,7 +263,7 @@ return s; } -NEOERR *cgi_js_escape (unsigned char *buf, unsigned char **esc) +NEOERR *cgi_js_escape (const unsigned char *buf, unsigned char **esc) { int nl = 0; int l = 0; @@ -308,7 +308,8 @@ return STATUS_OK; } -NEOERR *cgi_url_escape_more (unsigned char *buf, unsigned char **esc, unsigned char *other) +NEOERR *cgi_url_escape_more (const unsigned char *buf, unsigned char **esc, + const unsigned char *other) { int nl = 0; int l = 0; @@ -397,7 +398,7 @@ return STATUS_OK; } -NEOERR *cgi_url_escape (unsigned char *buf, unsigned char **esc) +NEOERR *cgi_url_escape (const unsigned char *buf, unsigned char **esc) { return nerr_pass(cgi_url_escape_more(buf, esc, NULL)); } @@ -695,8 +696,8 @@ return STATUS_OK; } -NEOERR *cgi_register_parse_cb(CGI *cgi, char *method, char *ctype, void *rock, - CGI_PARSE_CB parse_cb) +NEOERR *cgi_register_parse_cb(CGI *cgi, const char *method, const char *ctype, + void *rock, CGI_PARSE_CB parse_cb) { struct _cgi_parse_cb *my_pcb; @@ -922,7 +923,7 @@ static NEOERR *render_cb (void *ctx, char *buf) { - STRING *str= (STRING *)ctx; + STRING *str = (STRING *)ctx; NEOERR *err; err = nerr_pass(string_append(str, buf)); @@ -1371,17 +1372,17 @@ return nerr_pass(err); } -NEOERR *cgi_html_escape_strfunc(unsigned char *str, unsigned char **ret) +NEOERR *cgi_html_escape_strfunc(const unsigned char *str, unsigned char **ret) { return nerr_pass(html_escape_alloc(str, strlen(str), ret)); } -NEOERR *cgi_html_strip_strfunc(unsigned char *str, unsigned char **ret) +NEOERR *cgi_html_strip_strfunc(const unsigned char *str, unsigned char **ret) { return nerr_pass(html_strip_alloc(str, strlen(str), ret)); } -NEOERR *cgi_text_html_strfunc(unsigned char *str, unsigned char **ret) +NEOERR *cgi_text_html_strfunc(const unsigned char *str, unsigned char **ret) { return nerr_pass(convert_text_html_alloc(str, strlen(str), ret)); } @@ -1421,7 +1422,7 @@ return nerr_pass(err); } -NEOERR *cgi_display (CGI *cgi, char *cs_file) +NEOERR *cgi_display (CGI *cgi, const char *cs_file) { NEOERR *err = STATUS_OK; char *debug; @@ -1480,7 +1481,7 @@ cgiwrap_writef("\n"); } -void cgi_error (CGI *cgi, char *fmt, ...) +void cgi_error (CGI *cgi, const char *fmt, ...) { va_list ap; @@ -1522,7 +1523,7 @@ } } -void cgi_vredirect (CGI *cgi, int uri, char *fmt, va_list ap) +void cgi_vredirect (CGI *cgi, int uri, const char *fmt, va_list ap) { cgiwrap_writef ("Status: 302\r\n"); cgiwrap_writef ("Content-Type: text/html\r\n"); @@ -1575,7 +1576,7 @@ } -void cgi_redirect (CGI *cgi, char *fmt, ...) +void cgi_redirect (CGI *cgi, const char *fmt, ...) { va_list ap; @@ -1585,7 +1586,7 @@ return; } -void cgi_redirect_uri (CGI *cgi, char *fmt, ...) +void cgi_redirect_uri (CGI *cgi, const char *fmt, ...) { va_list ap; @@ -1595,7 +1596,7 @@ return; } -char *cgi_cookie_authority (CGI *cgi, char *host) +char *cgi_cookie_authority (CGI *cgi, const char *host) { HDF *obj; char *domain; @@ -1635,8 +1636,9 @@ * http://www.ietf.org/rfc/rfc2109.txt */ -NEOERR *cgi_cookie_set (CGI *cgi, char *name, char *value, char *path, - char *domain, char *time_str, int persistent, int secure) +NEOERR *cgi_cookie_set (CGI *cgi, const char *name, const char *value, + const char *path, const char *domain, + const char *time_str, int persistent, int secure) { NEOERR *err; STRING str; @@ -1687,7 +1689,8 @@ /* This will actually issue up to three set cookies, attempting to clear * the damn thing. */ -NEOERR *cgi_cookie_clear (CGI *cgi, char *name, char *domain, char *path) +NEOERR *cgi_cookie_clear (CGI *cgi, const char *name, const char *domain, + const char *path) { if (path == NULL) path = "/"; if (domain) diff -Nrub clearsilver-0.9.14/cgi/cgi.h clearsilver-0.10.1/cgi/cgi.h --- clearsilver-0.9.14/cgi/cgi.h 2004-11-24 15:27:33.000000000 -0800 +++ clearsilver-0.10.1/cgi/cgi.h 2005-06-30 18:11:42.000000000 -0700 @@ -188,8 +188,8 @@ * callbacks. * */ -NEOERR *cgi_register_parse_cb(CGI *cgi, char *method, char *ctype, void *rock, - CGI_PARSE_CB parse_cb); +NEOERR *cgi_register_parse_cb(CGI *cgi, const char *method, const char *ctype, + void *rock, CGI_PARSE_CB parse_cb); /* * Function: cgi_destroy - deallocate the data associated with a CGI @@ -228,7 +228,7 @@ * Return: NERR_IO - an IO error occured during output * NERR_NOMEM - no memory was available to render the template */ -NEOERR *cgi_display (CGI *cgi, char *cs_file); +NEOERR *cgi_display (CGI *cgi, const char *cs_file); /* * Function: cgi_output - display the CGI output to the user @@ -258,7 +258,7 @@ * indicates that the form_name wasn't found, but might indicate * a problem with the HDF dataset) */ -FILE *cgi_filehandle (CGI *cgi, char *form_name); +FILE *cgi_filehandle (CGI *cgi, const char *form_name); /* * Function: cgi_neo_error - display a NEOERR call backtrace @@ -284,7 +284,7 @@ * Output: None * Return: None */ -void cgi_error (CGI *cgi, char *fmt, ...); +void cgi_error (CGI *cgi, const char *fmt, ...); /* * Function: cgi_debug_init - initialize standalone debugging @@ -311,7 +311,7 @@ * Output: esc - a newly allocated string * Return: NERR_NOMEM - no memory available to allocate the escaped string */ -NEOERR *cgi_url_escape (unsigned char *buf, unsigned char **esc); +NEOERR *cgi_url_escape (const unsigned char *buf, unsigned char **esc); /* * Function: cgi_url_escape_more - url escape a string @@ -325,7 +325,8 @@ * Output: esc - a newly allocated string * Return: NERR_NOMEM - no memory available to allocate the escaped string */ -NEOERR *cgi_url_escape_more (unsigned char *buf, unsigned char **esc, unsigned char *other); +NEOERR *cgi_url_escape_more (const unsigned char *buf, unsigned char **esc, + const unsigned char *other); /* * Function: cgi_url_unescape - unescape an url encoded string @@ -351,7 +352,7 @@ * Output: None * Return: None */ -void cgi_redirect (CGI *cgi, char *fmt, ...); +void cgi_redirect (CGI *cgi, const char *fmt, ...); /* * Function: cgi_redirect_uri - send an HTTP 302 redirect response @@ -367,7 +368,7 @@ * Output: None * Return: None */ -void cgi_redirect_uri (CGI *cgi, char *fmt, ...); +void cgi_redirect_uri (CGI *cgi, const char *fmt, ...); /* * Function: cgi_vredirect - send an HTTP 302 redirect response @@ -380,7 +381,7 @@ * Output: None * Return: None */ -void cgi_vredirect (CGI *cgi, int uri, char *fmt, va_list ap); +void cgi_vredirect (CGI *cgi, int uri, const char *fmt, va_list ap); /* @@ -401,7 +402,7 @@ * Output: None * Return: The authority domain, or NULL if none found. */ -char *cgi_cookie_authority (CGI *cgi, char *host); +char *cgi_cookie_authority (CGI *cgi, const char *host); /* * Function: cgi_cookie_set - Set a browser Cookie @@ -426,8 +427,9 @@ * Output: None * Return: NERR_IO */ -NEOERR *cgi_cookie_set (CGI *cgi, char *name, char *value, char *path, - char *domain, char *time_str, int persistent, int secure); +NEOERR *cgi_cookie_set (CGI *cgi, const char *name, const char *value, + const char *path, const char *domain, + const char *time_str, int persistent, int secure); /* * Function: cgi_cookie_clear - clear browser cookie @@ -446,13 +448,14 @@ * Output: None * Return: NERR_IO */ -NEOERR *cgi_cookie_clear (CGI *cgi, char *name, char *domain, char *path); +NEOERR *cgi_cookie_clear (CGI *cgi, const char *name, const char *domain, + const char *path); /* not documented *yet* */ -NEOERR *cgi_text_html_strfunc(unsigned char *str, unsigned char **ret); -NEOERR *cgi_html_strip_strfunc(unsigned char *str, unsigned char **ret); -NEOERR *cgi_html_escape_strfunc(unsigned char *str, unsigned char **ret); -NEOERR *cgi_js_escape (unsigned char *buf, unsigned char **esc); +NEOERR *cgi_text_html_strfunc(const unsigned char *str, unsigned char **ret); +NEOERR *cgi_html_strip_strfunc(const unsigned char *str, unsigned char **ret); +NEOERR *cgi_html_escape_strfunc(const unsigned char *str, unsigned char **ret); +NEOERR *cgi_js_escape (const unsigned char *buf, unsigned char **esc); void cgi_html_ws_strip(STRING *str, int level); NEOERR *cgi_register_strfuncs(CSPARSE *cs); diff -Nrub clearsilver-0.9.14/cgi/cgiwrap.c clearsilver-0.10.1/cgi/cgiwrap.c --- clearsilver-0.9.14/cgi/cgiwrap.c 2004-07-28 15:17:51.000000000 -0700 +++ clearsilver-0.10.1/cgi/cgiwrap.c 2005-06-30 18:20:21.000000000 -0700 @@ -81,7 +81,7 @@ GlobalWrapper.emu_init = 1; } -NEOERR *cgiwrap_getenv (char *k, char **v) +NEOERR *cgiwrap_getenv (const char *k, char **v) { if (GlobalWrapper.getenv_cb != NULL) { @@ -108,7 +108,7 @@ return STATUS_OK; } -NEOERR *cgiwrap_putenv (char *k, char *v) +NEOERR *cgiwrap_putenv (const char *k, const char *v) { if (GlobalWrapper.putenv_cb != NULL) { @@ -164,7 +164,7 @@ return STATUS_OK; } -NEOERR *cgiwrap_writef (char *fmt, ...) +NEOERR *cgiwrap_writef (const char *fmt, ...) { va_list ap; @@ -174,7 +174,7 @@ return STATUS_OK; } -NEOERR *cgiwrap_writevf (char *fmt, va_list ap) +NEOERR *cgiwrap_writevf (const char *fmt, va_list ap) { int r; @@ -192,7 +192,7 @@ return STATUS_OK; } -NEOERR *cgiwrap_write (char *buf, int buf_len) +NEOERR *cgiwrap_write (const char *buf, int buf_len) { int r; diff -Nrub clearsilver-0.9.14/cgi/cgiwrap.h clearsilver-0.10.1/cgi/cgiwrap.h --- clearsilver-0.9.14/cgi/cgiwrap.h 2004-07-28 15:17:51.000000000 -0700 +++ clearsilver-0.10.1/cgi/cgiwrap.h 2005-06-30 18:22:12.000000000 -0700 @@ -28,10 +28,10 @@ __BEGIN_DECLS typedef int (*READ_FUNC)(void *, char *, int); -typedef int (*WRITEF_FUNC)(void *, char *, va_list); -typedef int (*WRITE_FUNC)(void *, char *, int); -typedef char *(*GETENV_FUNC)(void *, char *); -typedef int (*PUTENV_FUNC)(void *, char *, char *); +typedef int (*WRITEF_FUNC)(void *, const char *, va_list); +typedef int (*WRITE_FUNC)(void *, const char *, int); +typedef char *(*GETENV_FUNC)(void *, const char *); +typedef int (*PUTENV_FUNC)(void *, const char *, const char *); typedef int (*ITERENV_FUNC)(void *, int, char **, char **); /* @@ -85,7 +85,7 @@ * NULL if not found. * Returns: NERR_NOMEM if there isn't memory available to allocate the result */ -NEOERR *cgiwrap_getenv (char *k, char **v); +NEOERR *cgiwrap_getenv (const char *k, char **v); /* * Function: cgiwrap_putenv - wrap the putenv call @@ -101,7 +101,7 @@ * Output: None * Returns: NERR_NOMEM */ -NEOERR *cgiwrap_putenv (char *k, char *v); +NEOERR *cgiwrap_putenv (const char *k, const char *v); /* * Function: cgiwrap_iterenv - iterater for env vars @@ -124,7 +124,7 @@ * Output: None * Returns: NERR_SYSTEM */ -NEOERR *cgiwrap_writef (char *fmt, ...); +NEOERR *cgiwrap_writef (const char *fmt, ...); /* * Function: cgiwrap_writevf - a wrapper for vprintf @@ -137,7 +137,7 @@ * Output: None * Returns: NERR_SYSTEM */ -NEOERR *cgiwrap_writevf (char *fmt, va_list ap); +NEOERR *cgiwrap_writevf (const char *fmt, va_list ap); /* * Function: cgiwrap_write - wrapper for the fwrite(stdout) @@ -148,7 +148,7 @@ * Output: None * Returns: NERR_IO */ -NEOERR *cgiwrap_write (char *buf, int buf_len); +NEOERR *cgiwrap_write (const char *buf, int buf_len); /* * Function: cgiwrap_read - cgiwrap input function diff -Nrub clearsilver-0.9.14/cgi/date.c clearsilver-0.10.1/cgi/date.c --- clearsilver-0.9.14/cgi/date.c 2004-07-28 15:17:51.000000000 -0700 +++ clearsilver-0.10.1/cgi/date.c 2005-07-27 14:07:16.000000000 -0700 @@ -38,14 +38,15 @@ * */ -NEOERR *export_date_tm (HDF *data, char *prefix, struct tm *ttm) +NEOERR *export_date_tm (HDF *data, const char *prefix, struct tm *ttm) { NEOERR *err; HDF *obj; int hour, am = 1; char buf[256]; + int tzoffset_seconds = 0; int tzoffset = 0; - char tzsign = '-'; + char tzsign = '+'; obj = hdf_get_obj (data, prefix); if (obj == NULL) @@ -93,11 +94,13 @@ if (err) return nerr_pass(err); err = hdf_set_int_value (obj, "wday", ttm->tm_wday); if (err) return nerr_pass(err); - tzoffset = neo_tz_offset(ttm); + // neo_tz_offset() returns offset from GMT in seconds + tzoffset_seconds = neo_tz_offset(ttm); + tzoffset = tzoffset_seconds / 60; if (tzoffset < 0) { tzoffset *= -1; - tzsign = '+'; + tzsign = '-'; } snprintf(buf, sizeof(buf), "%c%02d%02d", tzsign, tzoffset / 60, tzoffset % 60); err = hdf_set_value (obj, "tzoffset", buf); @@ -106,7 +109,8 @@ return STATUS_OK; } -NEOERR *export_date_time_t (HDF *data, char *prefix, char *timezone, time_t tt) +NEOERR *export_date_time_t (HDF *data, const char *prefix, const char *timezone, + time_t tt) { struct tm ttm; diff -Nrub clearsilver-0.9.14/cgi/date.h clearsilver-0.10.1/cgi/date.h --- clearsilver-0.9.14/cgi/date.h 2004-07-28 15:17:51.000000000 -0700 +++ clearsilver-0.10.1/cgi/date.h 2005-06-30 18:21:30.000000000 -0700 @@ -16,8 +16,9 @@ __BEGIN_DECLS -NEOERR *export_date_tm (HDF *obj, char *prefix, struct tm *ttm); -NEOERR *export_date_time_t (HDF *obj, char *prefix, char *timezone, time_t tt); +NEOERR *export_date_tm (HDF *obj, const char *prefix, struct tm *ttm); +NEOERR *export_date_time_t (HDF *obj, const char *prefix, const char *timezone, + time_t tt); __END_DECLS diff -Nrub clearsilver-0.9.14/cgi/html.c clearsilver-0.10.1/cgi/html.c --- clearsilver-0.9.14/cgi/html.c 2004-07-28 15:17:51.000000000 -0700 +++ clearsilver-0.10.1/cgi/html.c 2005-06-30 18:18:13.000000000 -0700 @@ -22,7 +22,7 @@ #include "html.h" #include "cgi.h" -static int has_space_formatting(unsigned char *src, int slen) +static int has_space_formatting(const unsigned char *src, int slen) { int spaces = 0; int returns = 0; @@ -100,7 +100,8 @@ static char *EmailRe = "[^][@:;<>\\\"()[:space:][:cntrl:]]+@[-+a-zA-Z0-9]+\\.[-+a-zA-Z0-9\\.]+[-+a-zA-Z0-9]"; static char *URLRe = "((http|https|ftp|mailto):(//)?[^[:space:]>\"\t]*|www\\.[-a-z0-9\\.]+)[^[:space:];\t\">]*"; -static NEOERR *split_and_convert (unsigned char *src, int slen, STRING *out, HTML_CONVERT_OPTS *opts) +static NEOERR *split_and_convert (const unsigned char *src, int slen, + STRING *out, HTML_CONVERT_OPTS *opts) { NEOERR *err = STATUS_OK; static int compiled = 0; @@ -523,12 +524,15 @@ } } -NEOERR *convert_text_html_alloc (unsigned char *src, int slen, unsigned char **out) +NEOERR *convert_text_html_alloc (const unsigned char *src, int slen, + unsigned char **out) { return nerr_pass(convert_text_html_alloc_options(src, slen, out, NULL)); } -NEOERR *convert_text_html_alloc_options (unsigned char *src, int slen, unsigned char **out, HTML_CONVERT_OPTS *opts) +NEOERR *convert_text_html_alloc_options (const unsigned char *src, int slen, + unsigned char **out, + HTML_CONVERT_OPTS *opts) { NEOERR *err; STRING out_s; @@ -594,7 +598,8 @@ return STATUS_OK; } -NEOERR *html_escape_alloc (unsigned char *src, int slen, unsigned char **out) +NEOERR *html_escape_alloc (const unsigned char *src, int slen, + unsigned char **out) { NEOERR *err = STATUS_OK; STRING out_s; @@ -643,10 +648,8 @@ return STATUS_OK; } -static char *StripTags[] = {"script", "style", "head"}; - /* Replace ampersand with iso-8859-1 character code */ -static unsigned char _expand_amp_8859_1_char (unsigned char *s) +static unsigned char _expand_amp_8859_1_char (const unsigned char *s) { if (s[0] == '\0') return 0; @@ -721,7 +724,8 @@ return 0; } -unsigned char *html_expand_amp_8859_1(unsigned char *amp, unsigned char *buf) +unsigned char *html_expand_amp_8859_1(const unsigned char *amp, + unsigned char *buf) { unsigned char ch; @@ -738,7 +742,8 @@ } } -NEOERR *html_strip_alloc(unsigned char *src, int slen, unsigned char **out) +NEOERR *html_strip_alloc(const unsigned char *src, int slen, + unsigned char **out) { NEOERR *err = STATUS_OK; STRING out_s; diff -Nrub clearsilver-0.9.14/cgi/html.h clearsilver-0.10.1/cgi/html.h --- clearsilver-0.9.14/cgi/html.h 2004-07-28 15:17:51.000000000 -0700 +++ clearsilver-0.10.1/cgi/html.h 2005-06-30 18:16:42.000000000 -0700 @@ -31,10 +31,15 @@ char *link_name; } HTML_CONVERT_OPTS; -NEOERR *convert_text_html_alloc (unsigned char *src, int slen, unsigned char **out); -NEOERR *convert_text_html_alloc_options (unsigned char *src, int slen, unsigned char **out, HTML_CONVERT_OPTS *opts); -NEOERR *html_escape_alloc (unsigned char *src, int slen, unsigned char **out); -NEOERR *html_strip_alloc(unsigned char *src, int slen, unsigned char **out); +NEOERR *convert_text_html_alloc (const unsigned char *src, int slen, + unsigned char **out); +NEOERR *convert_text_html_alloc_options (const unsigned char *src, int slen, + unsigned char **out, + HTML_CONVERT_OPTS *opts); +NEOERR *html_escape_alloc (const unsigned char *src, int slen, + unsigned char **out); +NEOERR *html_strip_alloc(const unsigned char *src, int slen, + unsigned char **out); __END_DECLS diff -Nrub clearsilver-0.9.14/cgi/rfc2388.c clearsilver-0.10.1/cgi/rfc2388.c --- clearsilver-0.9.14/cgi/rfc2388.c 2004-07-28 15:17:51.000000000 -0700 +++ clearsilver-0.10.1/cgi/rfc2388.c 2005-06-30 18:21:06.000000000 -0700 @@ -568,7 +568,7 @@ } /* this is here because it gets populated in this file */ -FILE *cgi_filehandle (CGI *cgi, char *form_name) +FILE *cgi_filehandle (CGI *cgi, const char *form_name) { NEOERR *err; FILE *fp; diff -Nrub clearsilver-0.9.14/configure.in clearsilver-0.10.1/configure.in --- clearsilver-0.9.14/configure.in 2004-04-20 10:10:27.000000000 -0700 +++ clearsilver-0.10.1/configure.in 2005-06-30 18:49:06.000000000 -0700 @@ -50,11 +50,16 @@ EXTRA_UTL_OBJS= EXTRA_UTL_SRC= cs_cv_wdb=no -AC_SEARCH_LIBS(db_open, db db2, [cs_cv_wdb=yes]) -if test $cs_cv_wdb = yes; then +AC_ARG_ENABLE(apache, [ --disable-wdb Disables building of wdb], + [if test $enableval = no; then + AC_MSG_RESULT(Disabling wdb code) + else + AC_SEARCH_LIBS(db_open, db db2, [cs_cv_wdb=yes]) + if test $cs_cv_wdb = yes; then AC_DEFINE(HAVE_DB2) EXTRA_UTL_SRC="$EXTRA_UTL_SRC wdb.c" -fi + fi + fi]) dnl Check for locks AC_CHECK_FUNC(lockf, [ diff -Nrub clearsilver-0.9.14/cs/cs.h clearsilver-0.10.1/cs/cs.h --- clearsilver-0.9.14/cs/cs.h 2004-09-29 17:46:33.000000000 -0700 +++ clearsilver-0.10.1/cs/cs.h 2005-06-30 18:14:21.000000000 -0700 @@ -131,6 +131,8 @@ struct _tree *next; } CSTREE; +/* Technically, the char * for this func should be const char *, but that + * would break existing code */ typedef NEOERR* (*CSOUTFUNC)(void *, char *); typedef struct _local_map @@ -158,7 +160,7 @@ } CS_MACRO; typedef NEOERR* (*CSFUNCTION)(CSPARSE *parse, CS_FUNCTION *csf, CSARG *args, CSARG *result); -typedef NEOERR* (*CSSTRFUNC)(unsigned char *str, unsigned char **ret); +typedef NEOERR* (*CSSTRFUNC)(const unsigned char *str, unsigned char **ret); struct _funct { @@ -174,7 +176,7 @@ struct _parse { - char *context; /* A string identifying where the parser is parsing */ + const char *context; /* A string identifying where the parser is parsing */ int in_file; /* Indicates if current context is a file */ int offset; char *context_string; @@ -235,7 +237,7 @@ * NERR_NOMEM - unable to allocate memory to load file into memory * NERR_PARSE - error in CS template */ -NEOERR *cs_parse_file (CSPARSE *parse, char *path); +NEOERR *cs_parse_file (CSPARSE *parse, const char *path); /* * Function: cs_parse_string - parse a CS template string diff -Nrub clearsilver-0.9.14/cs/csparse.c clearsilver-0.10.1/cs/csparse.c --- clearsilver-0.9.14/cs/csparse.c 2004-09-29 17:46:33.000000000 -0700 +++ clearsilver-0.10.1/cs/csparse.c 2005-06-30 18:04:34.000000000 -0700 @@ -276,11 +276,11 @@ return -1; } -NEOERR *cs_parse_file (CSPARSE *parse, char *path) +NEOERR *cs_parse_file (CSPARSE *parse, const char *path) { NEOERR *err; char *ibuf; - char *save_context; + const char *save_context; int save_infile; char fpath[_POSIX_PATH_MAX]; @@ -1447,7 +1447,7 @@ NEOERR *err; CSTREE *node; char *a, *s; - char *save_context; + const char *save_context; int save_infile; char tmp[256]; diff -Nrub clearsilver-0.9.14/cs_config.h.in clearsilver-0.10.1/cs_config.h.in --- clearsilver-0.9.14/cs_config.h.in 2005-03-08 11:47:49.000000000 -0800 +++ clearsilver-0.10.1/cs_config.h.in 2005-06-30 18:49:22.000000000 -0700 @@ -1,4 +1,4 @@ -/* cs_config.h.in. Generated automatically from configure.in by autoheader. */ +/* cs_config.h.in. Generated from configure.in by autoheader. */ /* * Copyright 2001-2004 Brandon Long * All Rights Reserved. @@ -18,61 +18,15 @@ #define __CS_CONFIG_H_ 1 -/* Define to empty if the keyword does not work. */ -#undef const - -/* Define if you don't have vprintf but do have _doprnt. */ -#undef HAVE_DOPRNT - -/* Define if you have the strftime function. */ -#undef HAVE_STRFTIME - -/* Define if you have that is POSIX.1 compatible. */ -#undef HAVE_SYS_WAIT_H - -/* Define if your struct tm has tm_zone. */ -#undef HAVE_TM_ZONE - -/* Define if you don't have tm_zone but do have the external array - tzname. */ -#undef HAVE_TZNAME - -/* Define if you have the vprintf function. */ -#undef HAVE_VPRINTF - -/* Define if you have the wait3 system call. */ -#undef HAVE_WAIT3 - -/* Define to `int' if doesn't define. */ -#undef mode_t - -/* Define to `long' if doesn't define. */ -#undef off_t - -/* Define to `int' if doesn't define. */ -#undef pid_t - -/* Define as the return type of signal handlers (int or void). */ -#undef RETSIGTYPE - -/* Define to `unsigned' if doesn't define. */ -#undef size_t - -/* Define if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Define if your declares struct tm. */ -#undef TM_IN_SYS_TIME - /* Enable support for HTML Compression (still must be enabled at run time) */ #undef HTML_COMPRESSION /* Enable support for X Remote CGI Debugging */ #undef ENABLE_REMOTE_DEBUG +/********* SYSTEM CONFIG ***************************************************/ +/* autoconf/configure should figure all of these out for you */ + /* Does your system have the snprintf() call? */ #undef HAVE_SNPRINTF @@ -106,82 +60,176 @@ /* Enable support for gettext message translation */ #undef ENABLE_GETTEXT -/* Define if you have the drand48 function. */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the `drand48' function. */ #undef HAVE_DRAND48 -/* Define if you have the gettimeofday function. */ +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY -/* Define if you have the gmtime_r function. */ +/* Define to 1 if you have the `gmtime_r' function. */ #undef HAVE_GMTIME_R -/* Define if you have the localtime_r function. */ +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you have the `localtime_r' function. */ #undef HAVE_LOCALTIME_R -/* Define if you have the mktime function. */ +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mktime' function. */ #undef HAVE_MKTIME -/* Define if you have the putenv function. */ +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV -/* Define if you have the rand function. */ +/* Define to 1 if you have the `rand' function. */ #undef HAVE_RAND -/* Define if you have the random function. */ +/* Define to 1 if you have the `random' function. */ #undef HAVE_RANDOM -/* Define if you have the strerror function. */ +/* Define to 1 if you have the header file. */ +#undef HAVE_STDARG_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR -/* Define if you have the strspn function. */ +/* Define to 1 if you have the `strftime' function. */ +#undef HAVE_STRFTIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strspn' function. */ #undef HAVE_STRSPN -/* Define if you have the strtod function. */ +/* Define to 1 if you have the `strtod' function. */ #undef HAVE_STRTOD -/* Define if you have the strtok_r function. */ +/* Define to 1 if you have the `strtok_r' function. */ #undef HAVE_STRTOK_R -/* Define if you have the strtol function. */ +/* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL -/* Define if you have the strtoul function. */ +/* Define to 1 if you have the `strtoul' function. */ #undef HAVE_STRTOUL -/* Define if you have the header file. */ -#undef HAVE_DIRENT_H +/* Define to 1 if `tm_zone' is member of `struct tm'. */ +#undef HAVE_STRUCT_TM_TM_ZONE -/* Define if you have the header file. */ -#undef HAVE_FCNTL_H +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H -/* Define if you have the header file. */ -#undef HAVE_LIMITS_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H -/* Define if you have the header file. */ -#undef HAVE_NDIR_H +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H -/* Define if you have the header file. */ -#undef HAVE_STDARG_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H -/* Define if you have the header file. */ -#undef HAVE_STRINGS_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H -/* Define if you have the header file. */ -#undef HAVE_SYS_DIR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H -/* Define if you have the header file. */ -#undef HAVE_SYS_IOCTL_H +/* Define to 1 if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H -/* Define if you have the header file. */ -#undef HAVE_SYS_NDIR_H +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#undef HAVE_TM_ZONE -/* Define if you have the header file. */ -#undef HAVE_SYS_TIME_H +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +#undef HAVE_TZNAME -/* Define if you have the header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define if you have the header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_VARARGS_H +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if you have the `wait3' system call. Deprecated, you should no + longer depend upon `wait3'. */ +#undef HAVE_WAIT3 + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `int' if does not define. */ +#undef mode_t + +/* Define to `long' if does not define. */ +#undef off_t + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to `unsigned' if does not define. */ +#undef size_t + #endif /* __CS_CONFIG_H_ */ diff -Nrub clearsilver-0.9.14/java-jni/CSTest.java clearsilver-0.10.1/java-jni/CSTest.java --- clearsilver-0.9.14/java-jni/CSTest.java 2004-09-29 17:23:16.000000000 -0700 +++ clearsilver-0.10.1/java-jni/CSTest.java 2005-06-30 11:51:54.000000000 -0700 @@ -2,23 +2,42 @@ import java.io.*; import java.util.*; +import org.clearsilver.CS; +import org.clearsilver.HDF; + class CSTest { public static void main( String [] args ) throws IOException { - org.clearsilver.HDF hdf = new org.clearsilver.HDF(); + org.clearsilver.HDF hdf = new HDF(); System.out.println("Testing HDF set and dump\n"); hdf.setValue("Foo.Bar","10"); hdf.setValue("Foo.Baz","20"); System.out.println( hdf.dump() ); - String foo = hdf.getValue("Foo.Bar", ""); System.out.println("Testing HDF get\n"); + String foo = hdf.getValue("Foo.Bar", "30"); + System.out.println( foo ); + foo = hdf.getValue("Foo.Baz", "30"); System.out.println( foo ); System.out.println( "----" ); - org.clearsilver.CS cs = new org.clearsilver.CS(hdf); + System.out.println("Testing HDF get where default value is null\n"); + foo = hdf.getValue("Foo.Bar", null); + System.out.println("foo = " + foo); + foo = hdf.getValue("Foo.Nonexistent", null); + System.out.println("foo = " + foo); + + System.out.println( "----" ); + + int fooInt = hdf.getIntValue("Foo.Bar", 30); + System.out.println("Testing HDF get int\n"); + System.out.println( fooInt ); + + System.out.println( "----" ); + + org.clearsilver.CS cs = new CS(hdf); System.out.println("Testing HDF parse/render\n"); String tmplstr = "Foo.Bar:\nFoo.Baz:\n"; @@ -37,7 +56,7 @@ cs.parseStr(tmplstr); System.out.println(cs.render()); - cs = new org.clearsilver.CS(hdf); + cs = new CS(hdf); System.out.println("Testing white space stripping\n"); // test white space stripping @@ -55,5 +74,48 @@ System.out.println("Final HDF dump\n"); System.out.println( hdf.dump() ); + + // Now, test reading an HDF file from disk + System.out.println("Testing HDF.readFile()\n"); + HDF file_hdf = new HDF(); + file_hdf.readFile("testdata/test1.hdf"); + System.out.println(file_hdf.dump()); + + System.out.println("Testing HDF.readFile() for a file that doesn't exist"); + try { + file_hdf.readFile("testdata/doesnt_exist.hdf"); + } catch (Exception e) { + // The error message contains line numbers for functions in + // neo_hdf.c, and I don't want this test to fail if the line numbers + // change, so I'm not going to print out the exception message here. + // The important thing to test here is that an exception is thrown + // System.out.println(e + "\n"); + System.out.println("Caught exception of type " + e.getClass().getName() + "\n"); + } + + System.out.println("Testing HDF.getObj()"); + HDF foo_hdf = file_hdf.getObj("Foo"); + System.out.println(foo_hdf.dump()); + + System.out.println("Testing HDF.objName()"); + System.out.println("Should be \"Foo\": " + foo_hdf.objName()); + System.out.println("Should be \"Bar\": " + + foo_hdf.getObj("Bar").objName()); + System.out.println("Should be null: " + file_hdf.objName() + "\n"); + + System.out.println("Testing HDF.objValue()"); + System.out.println("Value of Foo.Bar: " + + foo_hdf.getObj("Bar").objValue()); + System.out.println("Value of root node: " + file_hdf.objValue() + "\n"); + + System.out.println("Testing HDF.objChild()"); + HDF child_hdf = foo_hdf.objChild(); + System.out.println("First child name: " + child_hdf.objName() + "\n"); + + System.out.println("Testing HDF.objNext()"); + HDF next_hdf = child_hdf.objNext(); + System.out.println("Next child name: " + next_hdf.objName()); + next_hdf = next_hdf.objNext(); + System.out.println("Next child (should be null): " + next_hdf + "\n"); } }; diff -Nrub clearsilver-0.9.14/java-jni/HDF.java clearsilver-0.10.1/java-jni/HDF.java --- clearsilver-0.9.14/java-jni/HDF.java 2002-09-20 15:13:08.000000000 -0700 +++ clearsilver-0.10.1/java-jni/HDF.java 2005-06-30 11:51:54.000000000 -0700 @@ -1,11 +1,17 @@ package org.clearsilver; -import java.io.*; -import java.util.*; +import java.io.FileNotFoundException; +import java.io.IOException; +/** This class is a wrapper around the HDF C API. Many features of the C API + * are not yet exposed through this wrapper. + */ public class HDF { - public int hdfptr; - + int hdfptr; // stores the C HDF* pointer + HDF root; // If this is a child HDF node, points at the root node of + // the tree. For root nodes this is null. A child node needs + // to hold a reference on the root to prevent the root from + // being GC-ed. static { try { System.loadLibrary("clearsilver-jni"); @@ -15,32 +21,121 @@ } } + /** Constructs an empty HDF dataset */ public HDF() { hdfptr = _init(); + root = null; + } + + /** Constructs an HDF child node. Used by other methods in this class when + * a child node needs to be constructed. + */ + private HDF(int hdfptr, HDF parent) { + this.hdfptr = hdfptr; + this.root = (parent.root != null) ? parent.root : parent; } + public void finalize() { + // Only root nodes have ownership of the C HDF pointer, so only a root + // node needs to dealloc hdfptr. + if ( root == null ) { _dealloc(hdfptr); } + } + + /** Loads the contents of the specified HDF file from disk into the current + * HDF object. The loaded contents are merged with the existing contents. + */ + public boolean readFile(String filename) throws IOException, + FileNotFoundException { + return _readFile(hdfptr, filename); + } + /** Retrieves the integer value at the specified path in this HDF node's + * subtree. If the value does not exist, or cannot be converted to an + * integer, default_value will be returned. */ public int getIntValue(String hdfname, int default_value) { return _getIntValue(hdfptr,hdfname,default_value); } + /** Retrieves the value at the specified path in this HDF node's subtree. + */ public String getValue(String hdfname, String default_value) { return _getValue(hdfptr,hdfname,default_value); } + /** Sets the value at the specified path in this HDF node's subtree. */ public void setValue(String hdfname, String value) { _setValue(hdfptr,hdfname,value); } + + /** Retrieves the HDF object that is the root of the subtree at hdfpath, or + * null if no object exists at that path. */ + public HDF getObj(String hdfpath) { + int obj_ptr = _getObj(hdfptr, hdfpath); + if ( obj_ptr == 0 ) { + return null; + } + return new HDF(obj_ptr, this); + } + + /** Returns the name of this HDF node. The root node has no name, so + * calling this on the root node will return null. */ + public String objName() { + return _objName(hdfptr); + } + + /** Returns the value of this HDF node, or null if this node has no value. + * Every node in the tree can have a value, a child, and a next peer. */ + public String objValue() { + return _objValue(hdfptr); + } + + /** Returns the child of this HDF node, or null if there is no child. + * Use this in conjunction with objNext to walk the HDF tree. Every node + * in the tree can have a value, a child, and a next peer. */ + public HDF objChild() { + int child_ptr = _objChild(hdfptr); + if ( child_ptr == 0 ) { + return null; + } + return new HDF(child_ptr, this); + } + + /** Returns the next sibling of this HDF node, or null if there is no next + * sibling. Use this in conjunction with objChild to walk the HDF tree. + * Every node in the tree can have a value, a child, and a next peer. */ + public HDF objNext() { + int next_ptr = _objNext(hdfptr); + if ( next_ptr == 0 ) { + return null; + } + return new HDF(next_ptr, this); + } + + /** + * Generates a string representing the content of the HDF tree rooted at + * this node. + */ public String dump() { return _dump(hdfptr); } - private native int _init(); - private native void _dealloc(int ptr); - private native int _getIntValue(int ptr, String hdfname,int default_value); - private native String _getValue(int ptr, String hdfname, String default_value); - private native void _setValue(int ptr, String hdfname, String hdf_value); - private native String _dump(int ptr); -}; + private static native int _init(); + private static native void _dealloc(int ptr); + private static native boolean _readFile(int ptr, String filename); + private static native int _getIntValue(int ptr, String hdfname, + int default_value); + private static native String _getValue(int ptr, String hdfname, + String default_value); + private static native void _setValue(int ptr, String hdfname, + String hdf_value); + private static native int _getObj(int ptr, String hdfpath); + private static native int _objChild(int ptr); + private static native int _objNext(int ptr); + private static native String _objName(int ptr); + private static native String _objValue(int ptr); + + private static native String _dump(int ptr); +} + diff -Nrub clearsilver-0.9.14/java-jni/javatest.gold clearsilver-0.10.1/java-jni/javatest.gold --- clearsilver-0.9.14/java-jni/javatest.gold 2004-09-29 17:23:16.000000000 -0700 +++ clearsilver-0.10.1/java-jni/javatest.gold 2005-06-30 11:51:54.000000000 -0700 @@ -6,6 +6,16 @@ Testing HDF get 10 +20 +---- +Testing HDF get where default value is null + +foo = 10 +foo = null +---- +Testing HDF get int + +10 ---- Testing HDF parse/render @@ -41,3 +51,31 @@ ClearSilver.WhiteSpaceStrip = 1 ClearSilver.DisplayDebug = 1 +Testing HDF.readFile() + +Foo.Bar = 10 +Foo.Baz = 20 + +Testing HDF.readFile() for a file that doesn't exist +Caught exception of type java.io.FileNotFoundException + +Testing HDF.getObj() +Bar = 10 +Baz = 20 + +Testing HDF.objName() +Should be "Foo": Foo +Should be "Bar": Bar +Should be null: null + +Testing HDF.objValue() +Value of Foo.Bar: 10 +Value of root node: null + +Testing HDF.objChild() +First child name: Bar + +Testing HDF.objNext() +Next child name: Baz +Next child (should be null): null + diff -Nrub clearsilver-0.9.14/java-jni/j_neo_util.c clearsilver-0.10.1/java-jni/j_neo_util.c --- clearsilver-0.9.14/java-jni/j_neo_util.c 2004-11-24 15:22:12.000000000 -0800 +++ clearsilver-0.10.1/java-jni/j_neo_util.c 2005-06-30 11:51:54.000000000 -0700 @@ -11,118 +11,163 @@ #include "cgi/date.h" #include "cgi/html.h" +void throwException(JNIEnv *env, const char* class_name, const char *message) { + jclass ex_class = (*env)->FindClass(env, class_name); + if (ex_class == NULL) { + // Unable to find proper class! + return; + } + (*env)->ThrowNew(env, ex_class, message); +} + +void throwNullPointerException(JNIEnv *env, const char *message) { + throwException(env, "java/lang/NullPointerException", message); +} + +void throwRuntimeException(JNIEnv *env, const char *message) { + throwException(env, "java/lang/RuntimeException", message); +} + +void throwIOException(JNIEnv *env, const char *message) { + throwException(env, "java/io/IOException", message); +} + +void throwFileNotFoundException(JNIEnv *env, const char *message) { + throwException(env, "java/io/FileNotFoundException", message); +} -jfieldID _hdfobjFldID = NULL; +void throwOutOfMemoryError(JNIEnv *env, const char *message) { + throwException(env, "java/lang/OutOfMemoryError", message); +} -int jNeoErr (JNIEnv *env, NEOERR *err) { +// Throws a runtime exception back to the Java VM appropriate for the type of +// error and frees the NEOERR that is passed in. +// TODO: throw more specific exceptions for errors like NERR_IO and NERR_NOMEM +int jNeoErr(JNIEnv *env, NEOERR *err) { STRING str; - jclass newExcCls = (*env)->FindClass(env, "java/lang/RuntimeException"); - if (newExcCls == 0) { - // unable to find proper class! - return 0; + string_init(&str); + if (nerr_match(err, NERR_PARSE)) { + nerr_error_string(err, &str); + throwRuntimeException(env, str.buf); + } else if (nerr_match(err, NERR_IO)) { + nerr_error_string(err, &str); + throwIOException(env, str.buf); + } else if (nerr_match(err, NERR_NOMEM)) { + nerr_error_string(err, &str); + throwOutOfMemoryError(env, str.buf); + } else { + nerr_error_traceback(err, &str); + throwRuntimeException(env, str.buf); } - string_init (&str); - if (nerr_match(err, NERR_PARSE)) - { - nerr_error_string (err, &str); - (*env)->ThrowNew(env, newExcCls, str.buf); - } - else - { - nerr_error_traceback (err, &str); - (*env)->ThrowNew(env, newExcCls, str.buf); - } - string_clear (&str); + nerr_ignore(&err); // free err, otherwise it would leak + string_clear(&str); return 0; } -JNIEXPORT jint JNICALL Java_org_clearsilver_HDF__1init - (JNIEnv *env, jobject obj) { +JNIEXPORT jint JNICALL Java_org_clearsilver_HDF__1init( + JNIEnv *env, jclass objClass) { HDF *hdf = NULL; NEOERR *err; - // if (!_hdfobjFldID) { - // jclass objClass = (*env)->GetObjectClass(env,obj); - // _hdfobjFldID = (*env)->GetFieldID(env,objClass,"hdfptr","i"); - // } - err = hdf_init(&hdf); - if (err) return jNeoErr(env,err); + if (err != STATUS_OK) { + return jNeoErr(env, err); + } return (jint) hdf; } -JNIEXPORT void JNICALL Java_org_clearsilver_HDF__1dealloc -(JNIEnv *env, jclass objClass, jint hdf_obj_ptr) { +JNIEXPORT void JNICALL Java_org_clearsilver_HDF__1dealloc( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr) { HDF *hdf = (HDF *)hdf_obj_ptr; hdf_destroy(&hdf); } -JNIEXPORT jint JNICALL Java_org_clearsilver_HDF__1getIntValue - (JNIEnv *env, jclass objClass, - jint hdf_obj_ptr, jstring j_hdfname, jint default_value) { - +JNIEXPORT jint JNICALL Java_org_clearsilver_HDF__1getIntValue( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr, jstring j_hdfname, + jint default_value) { HDF *hdf = (HDF *)hdf_obj_ptr; int r; const char *hdfname; - if (!j_hdfname) { return 0; } // throw + if (!j_hdfname) { + throwNullPointerException(env, "hdfname argument was null"); + return 0; + } - hdfname = (*env)->GetStringUTFChars(env,j_hdfname,0); + hdfname = (*env)->GetStringUTFChars(env,j_hdfname, 0); r = hdf_get_int_value(hdf,(char *) hdfname,default_value); (*env)->ReleaseStringUTFChars(env,j_hdfname,hdfname); return r; - } -JNIEXPORT jstring JNICALL Java_org_clearsilver_HDF__1getValue - (JNIEnv *env, jclass objClass, - jint hdf_obj_ptr, jstring j_hdfname, jstring j_default_value) { - +JNIEXPORT jstring JNICALL Java_org_clearsilver_HDF__1getValue( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr, jstring j_hdfname, + jstring j_default_value) { HDF *hdf = (HDF *)hdf_obj_ptr; const char *r; const char *hdfname; const char *default_value; + jstring retval; - if (!j_hdfname || !j_default_value) { return 0; } // throw - + if (!j_hdfname) { + throwNullPointerException(env, "hdfname argument was null"); + return 0; + } hdfname = (*env)->GetStringUTFChars(env,j_hdfname,0); - default_value = (*env)->GetStringUTFChars(env,j_default_value,0); + if (!j_default_value) { + default_value = NULL; + } else { + default_value = (*env)->GetStringUTFChars(env, j_default_value, 0); + } - r = hdf_get_value(hdf,(char *)hdfname,(char *)default_value); + r = hdf_get_value(hdf, (char *)hdfname, (char *)default_value); - (*env)->ReleaseStringUTFChars(env,j_hdfname,hdfname); - return (r ? (*env)->NewStringUTF(env,r) : 0); + (*env)->ReleaseStringUTFChars(env, j_hdfname, hdfname); + retval = (r ? (*env)->NewStringUTF(env, r) : 0); + if (default_value) { + (*env)->ReleaseStringUTFChars(env, j_default_value, default_value); + } + return retval; } - - -JNIEXPORT void JNICALL Java_org_clearsilver_HDF__1setValue - (JNIEnv *env, jclass objClass, +JNIEXPORT void JNICALL Java_org_clearsilver_HDF__1setValue( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr, jstring j_hdfname, jstring j_value) { HDF *hdf = (HDF *)hdf_obj_ptr; NEOERR *err; const char *hdfname; const char *value; - if (!j_hdfname || !j_value) { return; } - - hdfname = (*env)->GetStringUTFChars(env,j_hdfname,0); - value = (*env)->GetStringUTFChars(env,j_value,0); - - err = hdf_set_value(hdf, (char *)hdfname,(char *)value); + if (!j_hdfname) { + throwNullPointerException(env, "hdfname argument was null"); + return; + } + hdfname = (*env)->GetStringUTFChars(env, j_hdfname, 0); + if (j_value) { + value = (*env)->GetStringUTFChars(env, j_value, 0); + } else { + value = NULL; + } + err = hdf_set_value(hdf, (char *)hdfname, (char *)value); (*env)->ReleaseStringUTFChars(env, j_hdfname, hdfname); + if (value) { (*env)->ReleaseStringUTFChars(env, j_value, value); + } + if (err != STATUS_OK) { + // Throw an exception + jNeoErr(env, err); + } } -JNIEXPORT jstring JNICALL Java_org_clearsilver_HDF__1dump - (JNIEnv *env, jclass objClass, +JNIEXPORT jstring JNICALL Java_org_clearsilver_HDF__1dump( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr) { HDF *hdf = (HDF *)hdf_obj_ptr; NEOERR *err; @@ -131,9 +176,100 @@ string_init(&str); err = hdf_dump_str(hdf, NULL, 0, &str); - if (err) {} // throw exception + if (err != STATUS_OK) { + // Throw an exception + jNeoErr(env, err); + retval = NULL; + } else { retval = (*env)->NewStringUTF(env,str.buf); + } string_clear(&str); return retval; } + +JNIEXPORT jboolean JNICALL Java_org_clearsilver_HDF__1readFile( + JNIEnv *env, jobject objClass, jint hdf_obj_ptr, jstring j_filename) { + HDF *hdf = (HDF *)hdf_obj_ptr; + NEOERR *err; + const char *filename; + jboolean retval; + + filename = (*env)->GetStringUTFChars(env, j_filename, 0); + err = hdf_read_file(hdf, (char*)filename); + (*env)->ReleaseStringUTFChars(env, j_filename, filename); + if (err != STATUS_OK) { + // Throw an exception. jNeoErr handles all types of errors other than + // NOT_FOUND, since that can mean different things in different contexts. + // In this context, it means "file not found". + if (nerr_match(err, NERR_NOT_FOUND)) { + STRING str; + string_init(&str); + nerr_error_string(err, &str); + throwFileNotFoundException(env, str.buf); + string_clear(&str); + } else { + jNeoErr(env, err); + } + } + retval = (err == STATUS_OK); + return retval; +} + + +JNIEXPORT jint JNICALL Java_org_clearsilver_HDF__1getObj( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr, jstring j_hdf_path) { + HDF *hdf = (HDF *)hdf_obj_ptr; + HDF *obj_hdf = NULL; + const char *hdf_path; + + hdf_path = (*env)->GetStringUTFChars(env, j_hdf_path, 0); + obj_hdf = hdf_get_obj(hdf, (char*)hdf_path); + (*env)->ReleaseStringUTFChars(env, j_hdf_path, hdf_path); + return (jint)obj_hdf; +} + +JNIEXPORT jint JNICALL Java_org_clearsilver_HDF__1objChild( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr) { + HDF *hdf = (HDF *)hdf_obj_ptr; + HDF *child_hdf = NULL; + + child_hdf = hdf_obj_child(hdf); + return (jint)child_hdf; +} + +JNIEXPORT jint JNICALL Java_org_clearsilver_HDF__1objNext( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr) { + HDF *hdf = (HDF *)hdf_obj_ptr; + HDF *next_hdf = NULL; + + next_hdf = hdf_obj_next(hdf); + return (jint)next_hdf; +} + +JNIEXPORT jstring JNICALL Java_org_clearsilver_HDF__1objName( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr) { + HDF *hdf = (HDF *)hdf_obj_ptr; + char *name; + jstring retval = NULL; + + name = hdf_obj_name(hdf); + if (name != NULL) { + retval = (*env)->NewStringUTF(env, name); + } + return retval; +} + +JNIEXPORT jstring JNICALL Java_org_clearsilver_HDF__1objValue( + JNIEnv *env, jclass objClass, jint hdf_obj_ptr) { + HDF *hdf = (HDF *)hdf_obj_ptr; + char *name; + jstring retval = NULL; + + name = hdf_obj_value(hdf); + if (name != NULL) { + retval = (*env)->NewStringUTF(env, name); + } + return retval; +} + Binary files clearsilver-0.9.14/java-jni/libclearsilver-jni.so and clearsilver-0.10.1/java-jni/libclearsilver-jni.so differ diff -Nrub clearsilver-0.9.14/java-jni/testdata/test1.hdf clearsilver-0.10.1/java-jni/testdata/test1.hdf --- clearsilver-0.9.14/java-jni/testdata/test1.hdf 1969-12-31 16:00:00.000000000 -0800 +++ clearsilver-0.10.1/java-jni/testdata/test1.hdf 2005-06-30 11:51:54.000000000 -0700 @@ -0,0 +1,3 @@ +# Simple HDF file to test that HDF.readFile() works +Foo.Bar = 10 +Foo.Baz = 20 diff -Nrub clearsilver-0.9.14/Makefile clearsilver-0.10.1/Makefile --- clearsilver-0.9.14/Makefile 2005-03-08 09:58:35.000000000 -0800 +++ clearsilver-0.10.1/Makefile 2005-07-27 19:34:41.000000000 -0700 @@ -86,7 +86,8 @@ done changelog: - rcs2log -v | cat - ChangeLog | sed -e "s/\/b2\/src\/cvsroot\/neotonic\///g" > ChangeLog.$$$$ && mv ChangeLog.$$$$ ChangeLog + p4 changes -l ./... + clean: @for mdir in $(SUBDIRS); do \ @@ -107,23 +108,21 @@ mkdir -p $$mdir; \ done -CS_DISTDIR = clearsilver-0.9.14 -CS_LABEL = CLEARSILVER-0_9_14 -CS_FILES = README README.python INSTALL LICENSE CS_LICENSE rules.mk.in Makefile util cs cgi python scripts mod_ecs imd java-jni perl ruby dso csharp acconfig.h autogen.sh config.guess config.sub configure.in cs_config.h.in mkinstalldirs install-sh ClearSilver.h ports contrib +CS_DISTDIR = clearsilver-0.10.1 +CS_LABEL = CLEARSILVER-0_10_1 +CS_FILES = README README.python INSTALL LICENSE CS_LICENSE rules.mk.in Makefile acconfig.h autogen.sh config.guess config.sub configure.in cs_config.h.in mkinstalldirs install-sh ClearSilver.h +CS_DIRS = util cs cgi python scripts mod_ecs imd java-jni perl ruby dso csharp ports contrib + cs_dist: - @if cvs log Makefile | grep "${CS_LABEL}"; then \ + @if p4 labels Makefile | grep "${CS_LABEL}"; then \ echo "release ${CS_LABEL} already exists"; \ - echo " to rebuild, type: cvs tag -d -F ${CS_LABEL} Makefile "; \ + echo " to rebuild, type: p4 label -d ${CS_LABEL}"; \ exit 1; \ fi; rm -rf $(CS_DISTDIR) - cvs -q tag -F $(CS_LABEL) $(CS_FILES) + p4 label $(CS_LABEL) + p4 labelsync -l$(CS_LABEL) $(CS_FILES) $(addsuffix /..., $(CS_DIRS)) mkdir -p $(CS_DISTDIR) - cvs -z3 -q export -r $(CS_LABEL) -d $(CS_DISTDIR) neotonic - -rm -rf $(CS_DISTDIR)/CVS + tar -cf - `p4 files $(CS_FILES) $(addsuffix /..., $(CS_DIRS)) | cut -d'#' -f 1 | sed -e "s|//depot/google3/third_party/clearsilver/core/||"` | (cd $(CS_DISTDIR); tar -xf -) $(MAKE) -C $(CS_DISTDIR) man distclean tar chozf $(CS_DISTDIR).tar.gz $(CS_DISTDIR) - -trakken: cs - $(MAKE) -C retrieve - $(MAKE) VERSION=$(VERSION) RELEASE=$(RELEASE) -C trakken diff -Nrub clearsilver-0.9.14/mod_ecs/mod_ecs.c clearsilver-0.10.1/mod_ecs/mod_ecs.c --- clearsilver-0.9.14/mod_ecs/mod_ecs.c 2002-01-11 17:05:31.000000000 -0800 +++ clearsilver-0.10.1/mod_ecs/mod_ecs.c 2005-07-02 17:17:45.000000000 -0700 @@ -189,7 +189,7 @@ * to be very careful not to leak. We could probably at least use the * ap_register_cleanup() function to make sure we clean up our mess... */ -static int wrap_write (void *data, char *buf, size_t len) +static int wrap_write (void *data, const char *buf, size_t len) { WRAPPER_DATA *wrap = (WRAPPER_DATA *)data; int wl; @@ -263,7 +263,7 @@ return ret; } -int wrap_vprintf (void *data, char *fmt, va_list ap) +int wrap_vprintf (void *data, const char *fmt, va_list ap) { char buf[4096]; int len; @@ -272,7 +272,7 @@ return wrap_write (data, buf, len); } -static int wrap_read (void *data, void *buf, size_t len) +static int wrap_read (void *data, char *buf, size_t len) { WRAPPER_DATA *wrap = (WRAPPER_DATA *)data; int ret; @@ -294,7 +294,7 @@ return x; } -static char *wrap_getenv (void *data, char *s) +static char *wrap_getenv (void *data, const char *s) { WRAPPER_DATA *wrap = (WRAPPER_DATA *)data; char *v; @@ -304,7 +304,7 @@ return NULL; } -static int wrap_putenv (void *data, char *k, char *v) +static int wrap_putenv (void *data, const char *k, const char *v) { WRAPPER_DATA *wrap = (WRAPPER_DATA *)data; diff -Nrub clearsilver-0.9.14/python/neo_cgi.c clearsilver-0.10.1/python/neo_cgi.c --- clearsilver-0.9.14/python/neo_cgi.c 2004-07-28 15:17:41.000000000 -0700 +++ clearsilver-0.10.1/python/neo_cgi.c 2005-06-30 18:30:18.000000000 -0700 @@ -503,7 +503,7 @@ return Py_None; } -static int p_writef (void *data, char *fmt, va_list ap) +static int p_writef (void *data, const char *fmt, va_list ap) { WRAPPER_DATA *wrap = (WRAPPER_DATA *)data; PyObject *str; @@ -533,7 +533,7 @@ return err; } -static int p_write (void *data, char *buf, int len) +static int p_write (void *data, const char *buf, int len) { WRAPPER_DATA *wrap = (WRAPPER_DATA *)data; PyObject *s; @@ -625,7 +625,7 @@ * place that python actually checks for errors independent of an error * return. Not the best way to do things, but its what we've got. Some * of these we can check for in cgiWrap() */ -static char *p_getenv (void *data, char *s) +static char *p_getenv (void *data, const char *s) { WRAPPER_DATA *wrap = (WRAPPER_DATA *)data; PyObject *get; @@ -749,7 +749,7 @@ return 0; } -static int p_putenv (void *data, char *k, char *v) +static int p_putenv (void *data, const char *k, const char *v) { WRAPPER_DATA *wrap = (WRAPPER_DATA *)data; PyObject *set; diff -Nrub clearsilver-0.9.14/ruby/ext/hdf/neo_util.c clearsilver-0.10.1/ruby/ext/hdf/neo_util.c --- clearsilver-0.9.14/ruby/ext/hdf/neo_util.c 2004-07-28 15:17:45.000000000 -0700 +++ clearsilver-0.10.1/ruby/ext/hdf/neo_util.c 2005-06-30 11:51:57.000000000 -0700 @@ -444,7 +444,7 @@ char *s; char *escape; char *esc_char; - int buflen; + long buflen; char *ret = NULL; NEOERR *err; @@ -467,7 +467,7 @@ char *s; char *copy; char *esc_char; - int buflen; + long buflen; s = rb_str2cstr(oString,&buflen); esc_char = STR2CSTR(oEsc_char); diff -Nrub clearsilver-0.9.14/ruby/hdftest.out clearsilver-0.10.1/ruby/hdftest.out --- clearsilver-0.9.14/ruby/hdftest.out 1969-12-31 16:00:00.000000000 -0800 +++ clearsilver-0.10.1/ruby/hdftest.out 2005-07-27 19:44:07.000000000 -0700 @@ -0,0 +1,27 @@ +1 = farming +2 = sewing +3 = bowling +party.1 [Drool="True"] = baloons +party.2 [Pink] = noise makers +party.3 << EOM +telling long +stories +EOM +arf.1 = farming +arf.2 = sewing +arf.3 = bowling +arf.party.1 [Drool="True"] = baloons +arf.party.2 [Pink] = noise makers +arf.party.3 << EOM +telling long +stories +EOM +party.2 attr (Pink=1) +This is a funny test. farming. + +baloons + +noise makers + +telling long +stories diff -Nrub clearsilver-0.9.14/rules.mk.in clearsilver-0.10.1/rules.mk.in --- clearsilver-0.9.14/rules.mk.in 2004-11-16 15:05:10.000000000 -0800 +++ clearsilver-0.10.1/rules.mk.in 2005-07-02 17:13:51.000000000 -0700 @@ -74,12 +74,12 @@ RUBY = @RUBY@ CFLAGS = @CFLAGS@ -Wall -I$(NEOTONIC_ROOT) @CPPFLAGS@ -CPPFLAGS = -I$(NEOTONIC_ROOT) @CPPFLAGS@ +CPPFLAGS = -I$(NEOTONIC_ROOT) -fPIC @CPPFLAGS@ OUTPUT_OPTION = -o $@ LD = $(CC) -o LDFLAGS = -L$(LIB_DIR) @LDFLAGS@ -LDSHARED = $(CC) -shared -fPic -CPPLDSHARED = $(CPP) -shared -fPic +LDSHARED = $(CC) -shared -fPIC +CPPLDSHARED = $(CPP) -shared -fPIC AR = @AR@ cr RANLIB = @RANLIB@ DEP_LIBS = $(DLIBS:-l%=$(LIB_DIR)lib%.a) @@ -141,7 +141,7 @@ @echo "** OSNAME: $(OSTYPE)" @rm -f Makefile.depends @touch Makefile.depends - @for II in `$(LS) -1 *.c`; do \ + @for II in `find . -maxdepth 1 -name "*.c" -print`; do \ gcc -M -MG ${CFLAGS} $$II >> Makefile.depends; \ done; @echo "** (done) " diff -Nrub clearsilver-0.9.14/scripts/document.py clearsilver-0.10.1/scripts/document.py --- clearsilver-0.9.14/scripts/document.py 2003-04-03 17:34:32.000000000 -0800 +++ clearsilver-0.10.1/scripts/document.py 2005-07-27 17:53:10.000000000 -0700 @@ -1,4 +1,4 @@ -#!/usr/local/bin/python +#!/bin/env python """ document.py -- Simple script to generate manpages from C header files. Looks for the following formatted C comments in the C header files: diff -Nrub clearsilver-0.9.14/util/dict.c clearsilver-0.10.1/util/dict.c --- clearsilver-0.9.14/util/dict.c 2003-04-14 16:02:26.000000000 -0700 +++ clearsilver-0.10.1/util/dict.c 2005-06-30 17:48:26.000000000 -0700 @@ -83,7 +83,7 @@ /* entry is locked, so item may be added */ static NEOERR *dictNewItem(dictCtx dict, dictEntryPtr entry, - char *id, dictValuePtr newval, dictItemPtr *item) + const char *id, dictValuePtr newval, dictItemPtr *item) { dictItemPtr my_item; @@ -139,8 +139,8 @@ } /* list locked, so safe to walk entry */ -static dictItemPtr dictFindItem(dictCtx dict, dictEntryPtr entry, char *id, - BOOL unlink) { +static dictItemPtr dictFindItem(dictCtx dict, dictEntryPtr entry, + const char *id, BOOL unlink) { dictItemPtr *prev, item; @@ -162,7 +162,7 @@ return NULL; } -static NEOERR *dictUpdate(dictCtx dict, dictEntryPtr entry, char *id, +static NEOERR *dictUpdate(dictCtx dict, dictEntryPtr entry, const char *id, dictValuePtr newval, void *lock) { NEOERR *err = STATUS_OK; @@ -216,7 +216,8 @@ return nerr_pass(err); } -static NEOERR *dictInsert(dictCtx dict, UINT32 hash, char *id, dictValuePtr newval) { +static NEOERR *dictInsert(dictCtx dict, UINT32 hash, const char *id, + dictValuePtr newval) { dictEntryPtr entry; void *lock; @@ -253,7 +254,7 @@ return nerr_pass(dictUpdate(dict, entry, id, newval, lock)); } -static UINT32 dictHash(dictCtx dict, char *id) { +static UINT32 dictHash(dictCtx dict, const char *id) { UINT32 hash; @@ -266,7 +267,7 @@ return hash; } -static NEOERR *dictModify(dictCtx dict, char *id, dictValuePtr newval) +static NEOERR *dictModify(dictCtx dict, const char *id, dictValuePtr newval) { NEOERR *err; UINT32 hash; @@ -292,7 +293,7 @@ return nerr_pass(err); } -NEOERR *dictSetValue(dictCtx dict, char *id, void *value) { +NEOERR *dictSetValue(dictCtx dict, const char *id, void *value) { struct dictValue newval; @@ -303,7 +304,7 @@ return dictModify(dict, id, &newval); } -NEOERR *dictModifyValue(dictCtx dict, char *id, dictNewValueCB new, +NEOERR *dictModifyValue(dictCtx dict, const char *id, dictNewValueCB new, dictUpdateValueCB update, void *rock) { struct dictValue newval; @@ -373,7 +374,7 @@ return; } -void *dictSearch(dictCtx dict, char *id, void **plock) { +void *dictSearch(dictCtx dict, const char *id, void **plock) { dictEntryPtr entry; dictItemPtr item; @@ -502,7 +503,7 @@ return NULL; } -BOOL dictRemove(dictCtx dict, char *id) { +BOOL dictRemove(dictCtx dict, const char *id) { dictEntryPtr entry; dictItemPtr item; diff -Nrub clearsilver-0.9.14/util/dict.h clearsilver-0.10.1/util/dict.h --- clearsilver-0.9.14/util/dict.h 2003-04-14 16:02:26.000000000 -0700 +++ clearsilver-0.10.1/util/dict.h 2005-06-30 17:47:10.000000000 -0700 @@ -51,7 +51,7 @@ * MT-Level: Safe for unique . */ -BOOL dictRemove(dictCtx dict, char *id); +BOOL dictRemove(dictCtx dict, const char *id); /* * Function: dictRemove - remove item from dictionary. * Description: Removes item identified by from . @@ -62,7 +62,7 @@ * MT-Level: Safe if thread-safe. */ -void *dictSearch(dictCtx dict, char *id, void **plock); +void *dictSearch(dictCtx dict, const char *id, void **plock); /* * Function: dictSearch - search for value in dictionary. * Description: Searches for in , and returns value if @@ -113,7 +113,7 @@ * MT-Level: Safe if thread-safe. */ -NEOERR *dictSetValue(dictCtx dict, char *id, void *value); +NEOERR *dictSetValue(dictCtx dict, const char *id, void *value); /* * Function: dictSetValue - set/reset an items value. * Description: Updates the / pair into . @@ -126,10 +126,10 @@ * MT-Level: Safe if thread-safe. */ -typedef NEOERR *(*dictNewValueCB)(char *id, void *rock, void **new_val); -typedef NEOERR *(*dictUpdateValueCB)(char *id, void *value, void *rock); +typedef NEOERR *(*dictNewValueCB)(const char *id, void *rock, void **new_val); +typedef NEOERR *(*dictUpdateValueCB)(const char *id, void *value, void *rock); -NEOERR *dictModifyValue(dictCtx dict, char *id, dictNewValueCB new_cb, +NEOERR *dictModifyValue(dictCtx dict, const char *id, dictNewValueCB new_cb, dictUpdateValueCB update, void *rock); /* * Function: dictModifyValue - create/modify an item. diff -Nrub clearsilver-0.9.14/util/filter.c clearsilver-0.10.1/util/filter.c --- clearsilver-0.9.14/util/filter.c 2003-04-02 15:07:36.000000000 -0800 +++ clearsilver-0.10.1/util/filter.c 2005-06-30 11:57:56.000000000 -0700 @@ -34,7 +34,8 @@ return STATUS_OK; } if (r == 0) return STATUS_OK; - else return nerr_raise(NERR_SYSTEM, "Child %d returned status %d:", rpid, r); + else return nerr_raise(NERR_SYSTEM, "Child %d returned status %d:", rpid, + r); } if (WIFSIGNALED(r)) { @@ -47,10 +48,12 @@ return nerr_raise(NERR_SYSTEM, "Child %d stopped on signal %d:", rpid, r); } - return nerr_raise(NERR_ASSERT, "ERROR: waitpid(%d, %d) returned (%d, %d)", pid, options, rpid, r); + return nerr_raise(NERR_ASSERT, "ERROR: waitpid(%d, %d) returned (%d, %d)", + pid, options, rpid, r); } -NEOERR *filter_create_fd (char *cmd, int *fdin, int *fdout, int *fderr, pid_t *pid) +NEOERR *filter_create_fd (const char *cmd, int *fdin, int *fdout, int *fderr, + pid_t *pid) { int pi[2]={-1,-1}, po[2]={-1,-1}, pe[2]={-1,-1}; int rpid; @@ -61,7 +64,8 @@ { *fdin = 0; if (pipe (pi) == -1) - return nerr_raise_errno(NERR_SYSTEM, "Unable to open in pipe for command: %s", cmd); + return nerr_raise_errno(NERR_SYSTEM, + "Unable to open in pipe for command: %s", cmd); } if (fdout) @@ -74,7 +78,8 @@ close (pi[0]); close (pi[1]); } - return nerr_raise_errno(NERR_SYSTEM, "Unable to open out pipe for command: %s", cmd); + return nerr_raise_errno(NERR_SYSTEM, + "Unable to open out pipe for command: %s", cmd); } } @@ -168,7 +173,8 @@ return STATUS_OK; } -NEOERR *filter_create_fp(char *cmd, FILE **in, FILE **out, FILE **err, pid_t *pid) +NEOERR *filter_create_fp(const char *cmd, FILE **in, FILE **out, FILE **err, + pid_t *pid) { NEOERR *nerr; int fdin = 0, fdout = 0, fderr = 0; diff -Nrub clearsilver-0.9.14/util/filter.h clearsilver-0.10.1/util/filter.h --- clearsilver-0.9.14/util/filter.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/filter.h 2005-06-30 11:58:05.000000000 -0700 @@ -62,7 +62,8 @@ * pid -> the pid of the sub process * Returns: NERR_SYSTEM */ -NEOERR *filter_create_fd(char *cmd, int *fdin, int *fdout, int *fderr, pid_t *pid); +NEOERR *filter_create_fd(const char *cmd, int *fdin, int *fdout, int *fderr, + pid_t *pid); /* * Function: filter_create_fp - similar to filter_create_fd except with @@ -83,7 +84,8 @@ * pid -> the pid of the sub process * Returns: NERR_SYSTEM, NERR_IO */ -NEOERR *filter_create_fp(char *cmd, FILE **in, FILE **out, FILE **err, pid_t *pid); +NEOERR *filter_create_fp(const char *cmd, FILE **in, FILE **out, FILE **err, + pid_t *pid); __END_DECLS diff -Nrub clearsilver-0.9.14/util/neo_date.c clearsilver-0.10.1/util/neo_date.c --- clearsilver-0.9.14/util/neo_date.c 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_date.c 2005-06-30 11:58:40.000000000 -0700 @@ -31,7 +31,7 @@ * than this */ static char TzBuf[_POSIX_PATH_MAX + 4]; -static int time_set_tz (char *timezone) +static int time_set_tz (const char *timezone) { snprintf (TzBuf, sizeof(TzBuf), "TZ=%s", timezone); putenv(TzBuf); @@ -39,13 +39,13 @@ return 0; } -void neo_time_expand (const time_t tt, char *timezone, struct tm *ttm) +void neo_time_expand (const time_t tt, const char *timezone, struct tm *ttm) { time_set_tz (timezone); localtime_r (&tt, ttm); } -time_t neo_time_compact (struct tm *ttm, char *timezone) +time_t neo_time_compact (struct tm *ttm, const char *timezone) { time_t r; int save_isdst = ttm->tm_isdst; diff -Nrub clearsilver-0.9.14/util/neo_date.h clearsilver-0.10.1/util/neo_date.h --- clearsilver-0.9.14/util/neo_date.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_date.h 2005-06-30 11:58:48.000000000 -0700 @@ -17,10 +17,10 @@ __BEGIN_DECLS /* UTC time_t -> struct tm in local timezone */ -void neo_time_expand (const time_t tt, char *timezone, struct tm *ttm); +void neo_time_expand (const time_t tt, const char *timezone, struct tm *ttm); /* local timezone struct tm -> time_t UTC */ -time_t neo_time_compact (struct tm *ttm, char *timezone); +time_t neo_time_compact (struct tm *ttm, const char *timezone); /* To be portable... in seconds */ long neo_tz_offset(struct tm *ttm); diff -Nrub clearsilver-0.9.14/util/neo_err.h clearsilver-0.10.1/util/neo_err.h --- clearsilver-0.9.14/util/neo_err.h 2004-11-10 16:45:46.000000000 -0800 +++ clearsilver-0.10.1/util/neo_err.h 2005-06-30 11:59:37.000000000 -0700 @@ -69,14 +69,14 @@ #define nerr_raise(e,f,a...) \ nerr_raisef(__PRETTY_FUNCTION__,__FILE__,__LINE__,e,f,##a) -NEOERR *nerr_raisef (const char *func, const char *file, int lineno, NERR_TYPE error, - const char *fmt, ...); +NEOERR *nerr_raisef (const char *func, const char *file, int lineno, + NERR_TYPE error, const char *fmt, ...); #define nerr_raise_errno(e,f,a...) \ nerr_raise_errnof(__PRETTY_FUNCTION__,__FILE__,__LINE__,e,f,##a) -NEOERR *nerr_raise_errnof (const char *func, const char *file, int lineno, int error, - const char *fmt, ...); +NEOERR *nerr_raise_errnof (const char *func, const char *file, int lineno, + int error, const char *fmt, ...); /* function: nerr_pass * description: this function is used to pass an error up a level in the * call chain (ie, if the error isn't handled at the @@ -88,7 +88,8 @@ */ #define nerr_pass(e) \ nerr_passf(__PRETTY_FUNCTION__,__FILE__,__LINE__,e) -NEOERR *nerr_passf (const char *func, const char *file, int lineno, NEOERR *err); +NEOERR *nerr_passf (const char *func, const char *file, int lineno, + NEOERR *err); /* function: nerr_pass_ctx * description: this function is used to pass an error up a level in the diff -Nrub clearsilver-0.9.14/util/neo_files.c clearsilver-0.10.1/util/neo_files.c --- clearsilver-0.9.14/util/neo_files.c 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_files.c 2005-06-30 17:41:29.000000000 -0700 @@ -27,7 +27,7 @@ #include "neo_files.h" #include "wildmat.h" -NEOERR *ne_mkdirs (char *path, mode_t mode) +NEOERR *ne_mkdirs (const char *path, mode_t mode) { char mypath[_POSIX_PATH_MAX]; int x; @@ -63,7 +63,7 @@ return STATUS_OK; } -NEOERR *ne_load_file_len (char *path, char **str, int *out_len) +NEOERR *ne_load_file_len (const char *path, char **str, int *out_len) { struct stat s; int fd; @@ -108,11 +108,11 @@ return STATUS_OK; } -NEOERR *ne_load_file (char *path, char **str) { +NEOERR *ne_load_file (const char *path, char **str) { return ne_load_file_len (path, str, NULL); } -NEOERR *ne_save_file (char *path, char *str) +NEOERR *ne_save_file (const char *path, char *str) { NEOERR *err; int fd; @@ -136,7 +136,7 @@ return STATUS_OK; } -NEOERR *ne_remove_dir (char *path) +NEOERR *ne_remove_dir (const char *path) { NEOERR *err; DIR *dp; @@ -192,22 +192,23 @@ return STATUS_OK; } -NEOERR *ne_listdir(char *path, ULIST **files) +NEOERR *ne_listdir(const char *path, ULIST **files) { return nerr_pass(ne_listdir_fmatch(path, files, NULL, NULL)); } -static int _glob_match(void *rock, char *filename) +static int _glob_match(void *rock, const char *filename) { return wildmat(filename, rock); } -NEOERR *ne_listdir_match(char *path, ULIST **files, char *match) +NEOERR *ne_listdir_match(const char *path, ULIST **files, const char *match) { - return nerr_pass(ne_listdir_fmatch(path, files, _glob_match, match)); + return nerr_pass(ne_listdir_fmatch(path, files, _glob_match, (void *)match)); } -NEOERR *ne_listdir_fmatch(char *path, ULIST **files, MATCH_FUNC fmatch, void *rock) +NEOERR *ne_listdir_fmatch(const char *path, ULIST **files, MATCH_FUNC fmatch, + void *rock) { DIR *dp; struct dirent *de; diff -Nrub clearsilver-0.9.14/util/neo_files.h clearsilver-0.10.1/util/neo_files.h --- clearsilver-0.9.14/util/neo_files.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_files.h 2005-06-30 12:02:23.000000000 -0700 @@ -20,16 +20,17 @@ -typedef int (* MATCH_FUNC)(void *rock, char *filename); +typedef int (* MATCH_FUNC)(void *rock, const char *filename); -NEOERR *ne_mkdirs (char *path, mode_t mode); -NEOERR *ne_load_file (char *path, char **str); -NEOERR *ne_load_file_len (char *path, char **str, int *len); -NEOERR *ne_save_file (char *path, char *str); -NEOERR *ne_remove_dir (char *path); -NEOERR *ne_listdir(char *path, ULIST **files); -NEOERR *ne_listdir_match(char *path, ULIST **files, char *match); -NEOERR *ne_listdir_fmatch(char *path, ULIST **files, MATCH_FUNC fmatch, void *rock); +NEOERR *ne_mkdirs (const char *path, mode_t mode); +NEOERR *ne_load_file (const char *path, char **str); +NEOERR *ne_load_file_len (const char *path, char **str, int *len); +NEOERR *ne_save_file (const char *path, char *str); +NEOERR *ne_remove_dir (const char *path); +NEOERR *ne_listdir(const char *path, ULIST **files); +NEOERR *ne_listdir_match(const char *path, ULIST **files, const char *match); +NEOERR *ne_listdir_fmatch(const char *path, ULIST **files, MATCH_FUNC fmatch, + void *rock); __END_DECLS diff -Nrub clearsilver-0.9.14/util/neo_hdf.c clearsilver-0.10.1/util/neo_hdf.c --- clearsilver-0.9.14/util/neo_hdf.c 2004-11-05 02:00:21.000000000 -0800 +++ clearsilver-0.10.1/util/neo_hdf.c 2005-06-30 17:40:04.000000000 -0700 @@ -52,8 +52,8 @@ return ne_crc(ha->name, ha->name_len); } -static NEOERR *_alloc_hdf (HDF **hdf, char *name, size_t nlen, char *value, - int dup, int wf, HDF *top) +static NEOERR *_alloc_hdf (HDF **hdf, const char *name, size_t nlen, + const char *value, int dup, int wf, HDF *top) { *hdf = calloc (1, sizeof (HDF)); if (*hdf == NULL) @@ -95,7 +95,10 @@ else { (*hdf)->alloc_value = wf; - (*hdf)->value = value; + /* We're overriding the const of value here for the set_buf case + * where we overrode the char * to const char * earlier, since + * alloc_value actually keeps track of the const-ness for us */ + (*hdf)->value = (char *)value; } } return STATUS_OK; @@ -189,13 +192,13 @@ } } -static int _walk_hdf (HDF *hdf, char *name, HDF **node) +static int _walk_hdf (HDF *hdf, const char *name, HDF **node) { HDF *parent = NULL; HDF *hp = hdf; HDF hash_key; int x = 0; - char *s, *n; + const char *s, *n; int r; *node = NULL; @@ -235,7 +238,7 @@ { if (parent && parent->hash) { - hash_key.name = n; + hash_key.name = (char *)n; hash_key.name_len = x; hp = ne_hash_lookup(parent->hash, &hash_key); } @@ -286,7 +289,7 @@ return 0; } -int hdf_get_int_value (HDF *hdf, char *name, int defval) +int hdf_get_int_value (HDF *hdf, const char *name, int defval) { HDF *node; int v; @@ -301,7 +304,9 @@ return defval; } -char* hdf_get_value (HDF *hdf, char *name, char *defval) +/* This should return a const char *, but changing this would have big + * repurcussions for any C code using this function, so no change for now */ +char* hdf_get_value (HDF *hdf, const char *name, const char *defval) { HDF *node; @@ -309,10 +314,10 @@ { return node->value; } - return defval; + return (char *)defval; } -char* hdf_get_valuevf (HDF *hdf, char *namefmt, va_list ap) +char* hdf_get_valuevf (HDF *hdf, const char *namefmt, va_list ap) { HDF *node; char *name; @@ -328,7 +333,7 @@ return NULL; } -char* hdf_get_valuef (HDF *hdf, char *namefmt, ...) +char* hdf_get_valuef (HDF *hdf, const char *namefmt, ...) { char *val; va_list ap; @@ -339,7 +344,8 @@ return val; } -NEOERR* hdf_get_copy (HDF *hdf, char *name, char **value, char *defval) +NEOERR* hdf_get_copy (HDF *hdf, const char *name, char **value, + const char *defval) { HDF *node; @@ -367,7 +373,7 @@ return STATUS_OK; } -HDF* hdf_get_obj (HDF *hdf, char *name) +HDF* hdf_get_obj (HDF *hdf, const char *name) { HDF *obj; @@ -375,7 +381,7 @@ return obj; } -HDF* hdf_get_child (HDF *hdf, char *name) +HDF* hdf_get_child (HDF *hdf, const char *name) { HDF *obj; _walk_hdf(hdf, name, &obj); @@ -383,7 +389,7 @@ return obj; } -HDF_ATTR* hdf_get_attr (HDF *hdf, char *name) +HDF_ATTR* hdf_get_attr (HDF *hdf, const char *name) { HDF *obj; _walk_hdf(hdf, name, &obj); @@ -391,7 +397,8 @@ return NULL; } -NEOERR* hdf_set_attr (HDF *hdf, char *name, char *key, char *value) +NEOERR* hdf_set_attr (HDF *hdf, const char *name, const char *key, + const char *value) { HDF *obj; HDF_ATTR *attr, *last; @@ -561,14 +568,16 @@ return STATUS_OK; } -static NEOERR* _set_value (HDF *hdf, char *name, char *value, int dup, int wf, int link, HDF_ATTR *attr, HDF **set_node) +static NEOERR* _set_value (HDF *hdf, const char *name, const char *value, + int dup, int wf, int link, HDF_ATTR *attr, + HDF **set_node) { NEOERR *err; HDF *hn, *hp, *hs; HDF hash_key; int x = 0; - char *s = name; - char *n = name; + const char *s = name; + const char *n = name; int count = 0; if (set_node != NULL) *set_node = NULL; @@ -616,7 +625,7 @@ else { hdf->alloc_value = wf; - hdf->value = value; + hdf->value = (char *)value; } if (set_node != NULL) *set_node = hdf; return STATUS_OK; @@ -653,7 +662,7 @@ /* Look for a matching node at this level */ if (hn->hash != NULL) { - hash_key.name = n; + hash_key.name = (char *)n; hash_key.name_len = x; hp = ne_hash_lookup(hn->hash, &hash_key); hs = hn->last_child; @@ -754,7 +763,7 @@ else { hp->alloc_value = wf; - hp->value = value; + hp->value = (char *)value; } } if (link) hp->link = 1; @@ -778,22 +787,23 @@ return STATUS_OK; } -NEOERR* hdf_set_value (HDF *hdf, char *name, char *value) +NEOERR* hdf_set_value (HDF *hdf, const char *name, const char *value) { return nerr_pass(_set_value (hdf, name, value, 1, 1, 0, NULL, NULL)); } -NEOERR* hdf_set_value_attr (HDF *hdf, char *name, char *value, HDF_ATTR *attr) +NEOERR* hdf_set_value_attr (HDF *hdf, const char *name, const char *value, + HDF_ATTR *attr) { return nerr_pass(_set_value (hdf, name, value, 1, 1, 0, attr, NULL)); } -NEOERR* hdf_set_symlink (HDF *hdf, char *src, char *dest) +NEOERR* hdf_set_symlink (HDF *hdf, const char *src, const char *dest) { return nerr_pass(_set_value (hdf, src, dest, 1, 1, 1, NULL, NULL)); } -NEOERR* hdf_set_int_value (HDF *hdf, char *name, int value) +NEOERR* hdf_set_int_value (HDF *hdf, const char *name, int value) { char buf[256]; @@ -801,12 +811,12 @@ return nerr_pass(_set_value (hdf, name, buf, 1, 1, 0, NULL, NULL)); } -NEOERR* hdf_set_buf (HDF *hdf, char *name, char *value) +NEOERR* hdf_set_buf (HDF *hdf, const char *name, char *value) { return nerr_pass(_set_value (hdf, name, value, 0, 1, 0, NULL, NULL)); } -NEOERR* hdf_set_copy (HDF *hdf, char *dest, char *src) +NEOERR* hdf_set_copy (HDF *hdf, const char *dest, const char *src) { HDF *node; if ((_walk_hdf(hdf, src, &node) == 0) && (node->value != NULL)) @@ -816,7 +826,7 @@ return nerr_raise (NERR_NOT_FOUND, "Unable to find %s", src); } -NEOERR* hdf_set_valuevf (HDF *hdf, char *fmt, va_list ap) +NEOERR* hdf_set_valuevf (HDF *hdf, const char *fmt, va_list ap) { NEOERR *err; char *k; @@ -840,7 +850,7 @@ return nerr_pass(err); } -NEOERR* hdf_set_valuef (HDF *hdf, char *fmt, ...) +NEOERR* hdf_set_valuef (HDF *hdf, const char *fmt, ...) { NEOERR *err; va_list ap; @@ -851,7 +861,7 @@ return nerr_pass(err); } -NEOERR* hdf_get_node (HDF *hdf, char *name, HDF **ret) +NEOERR* hdf_get_node (HDF *hdf, const char *name, HDF **ret) { _walk_hdf(hdf, name, ret); if (*ret == NULL) @@ -899,13 +909,13 @@ return nerr_pass(err); } -NEOERR* hdf_remove_tree (HDF *hdf, char *name) +NEOERR* hdf_remove_tree (HDF *hdf, const char *name) { HDF *hp = hdf; HDF *lp = NULL, *ln = NULL; /* last parent, last node */ int x = 0; - char *s = name; - char *n = name; + const char *s = name; + const char *n = name; if (hdf == NULL) return STATUS_OK; @@ -993,7 +1003,7 @@ return STATUS_OK; } -NEOERR* hdf_copy (HDF *dest, char *name, HDF *src) +NEOERR* hdf_copy (HDF *dest, const char *name, HDF *src) { NEOERR *err; HDF *node; @@ -1029,9 +1039,9 @@ ml[x] = '\0'; } -typedef NEOERR *(*DUMPF_CB)(void *rock, char *fmt, ...); +typedef NEOERR *(*DUMPF_CB)(void *rock, const char *fmt, ...); -static NEOERR *_fp_dump_cb (void *rock, char *fmt, ...) +static NEOERR *_fp_dump_cb (void *rock, const char *fmt, ...) { FILE *fp = (FILE *)rock; va_list ap; @@ -1042,7 +1052,7 @@ return STATUS_OK; } -static NEOERR *_string_dump_cb (void *rock, char *fmt, ...) +static NEOERR *_string_dump_cb (void *rock, const char *fmt, ...) { NEOERR *err; STRING *str = (STRING *)rock; @@ -1058,7 +1068,8 @@ #define DUMP_TYPE_COMPACT 1 #define DUMP_TYPE_PRETTY 2 -static NEOERR* hdf_dump_cb(HDF *hdf, char *prefix, int dtype, int lvl, void *rock, DUMPF_CB dump_cbf) +static NEOERR* hdf_dump_cb(HDF *hdf, const char *prefix, int dtype, int lvl, + void *rock, DUMPF_CB dump_cbf) { NEOERR *err; char *p, op; @@ -1173,12 +1184,12 @@ return STATUS_OK; } -NEOERR* hdf_dump_str (HDF *hdf, char *prefix, int dtype, STRING *str) +NEOERR* hdf_dump_str (HDF *hdf, const char *prefix, int dtype, STRING *str) { return nerr_pass(hdf_dump_cb(hdf, prefix, dtype, 0, str, _string_dump_cb)); } -NEOERR* hdf_dump(HDF *hdf, char *prefix) +NEOERR* hdf_dump(HDF *hdf, const char *prefix) { return nerr_pass(hdf_dump_cb(hdf, prefix, DUMP_TYPE_DOTTED, 0, stdout, _fp_dump_cb)); } @@ -1188,7 +1199,7 @@ return nerr_pass(hdf_dump_cb(hdf, "", DUMP_TYPE_PRETTY, 0, fp, _fp_dump_cb)); } -NEOERR *hdf_write_file (HDF *hdf, char *path) +NEOERR *hdf_write_file (HDF *hdf, const char *path) { NEOERR *err; FILE *fp; @@ -1207,7 +1218,7 @@ return nerr_pass(err); } -NEOERR *hdf_write_file_atomic (HDF *hdf, char *path) +NEOERR *hdf_write_file_atomic (HDF *hdf, const char *path) { NEOERR *err; FILE *fp; @@ -1271,10 +1282,10 @@ /* HDF file looks like the following: */ #define SKIPWS(s) while (*s && isspace(*s)) s++; -static int _copy_line (char **s, char *buf, size_t buf_len) +static int _copy_line (const char **s, char *buf, size_t buf_len) { int x = 0; - char *st = *s; + const char *st = *s; while (*st && x < buf_len-1) { @@ -1287,13 +1298,13 @@ return x; } -static int _copy_line_alloc (char **s, char **buf) +static int _copy_line_alloc (const char **s, char **buf) { NEOERR *err; int x = 0; - char *st = *s; + const char *st = *s; STRING str; - char *nl; + const char *nl; string_init(&str); @@ -1450,7 +1461,8 @@ return STATUS_OK; } -static NEOERR* _hdf_read_string (HDF *hdf, char **str, int *line, int ignore) +static NEOERR* _hdf_read_string (HDF *hdf, const char **str, int *line, + int ignore) { NEOERR *err; HDF *lower; @@ -1612,22 +1624,22 @@ return STATUS_OK; } -NEOERR * hdf_read_string (HDF *hdf, char *str) +NEOERR * hdf_read_string (HDF *hdf, const char *str) { int line = 0; return nerr_pass (_hdf_read_string (hdf, &str, &line, 0)); } -NEOERR * hdf_read_string_ignore (HDF *hdf, char *str, int ignore) +NEOERR * hdf_read_string_ignore (HDF *hdf, const char *str, int ignore) { int line = 0; return nerr_pass (_hdf_read_string (hdf, &str, &line, ignore)); } -static int count_newlines (char *s) +static int count_newlines (const char *s) { int i = 0; - char *n = s; + const char *n = s; n = strchr(s, '\n'); while (n != NULL) @@ -1638,7 +1650,8 @@ return i; } -static NEOERR* hdf_read_file_fp (HDF *hdf, FILE *fp, char *path, int *line) +static NEOERR* hdf_read_file_fp (HDF *hdf, FILE *fp, const char *path, + int *line) { NEOERR *err; STRING str; @@ -1863,7 +1876,7 @@ } /* The search path is part of the HDF by convention */ -NEOERR* hdf_search_path (HDF *hdf, char *path, char *full) +NEOERR* hdf_search_path (HDF *hdf, const char *path, char *full) { HDF *paths; struct stat s; @@ -1896,7 +1909,7 @@ return nerr_raise (NERR_NOT_FOUND, "Path %s not found", path); } -NEOERR* hdf_read_file (HDF *hdf, char *path) +NEOERR* hdf_read_file (HDF *hdf, const char *path) { NEOERR *err; FILE *fp; diff -Nrub clearsilver-0.9.14/util/neo_hdf.h clearsilver-0.10.1/util/neo_hdf.h --- clearsilver-0.9.14/util/neo_hdf.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_hdf.h 2005-06-30 17:34:16.000000000 -0700 @@ -88,7 +88,7 @@ * Output: None * Returns: The integer value of the node, or the defval */ -int hdf_get_int_value (HDF *hdf, char *name, int defval); +int hdf_get_int_value (HDF *hdf, const char *name, int defval); /* * Function: hdf_get_value - Return the value of a node in the data set @@ -105,7 +105,7 @@ * a copy you either have to call strdup yourself, or use * hdf_get_copy */ -char *hdf_get_value (HDF *hdf, char *name, char *defval); +char *hdf_get_value (HDF *hdf, const char *name, const char *defval); /* * Function: hdf_get_valuevf - Return the value of a node in the data set @@ -122,7 +122,7 @@ * The data set maintains ownership of the string, if you want * a copy you either have to call strdup yourself. */ -char* hdf_get_valuevf (HDF *hdf, char *namefmt, va_list ap); +char* hdf_get_valuevf (HDF *hdf, const char *namefmt, va_list ap); /* * Function: hdf_get_valuef - Return the value of a node in the data set @@ -139,7 +139,7 @@ * The data set maintains ownership of the string, if you want * a copy you either have to call strdup yourself. */ -char* hdf_get_valuef (HDF *hdf, char *namefmt, ...); +char* hdf_get_valuef (HDF *hdf, const char *namefmt, ...); /* * Function: hdf_get_copy - Returns a copy of a string in the HDF data set @@ -153,7 +153,8 @@ * will be NULL if defval is used) * Returns: NERR_NOMEM if unable to allocate the new copy */ -NEOERR* hdf_get_copy (HDF *hdf, char *name, char **value, char *defval); +NEOERR* hdf_get_copy (HDF *hdf, const char *name, char **value, + const char *defval); /* * Function: hdf_get_obj - return the HDF data set node at a named location @@ -164,7 +165,7 @@ * Output: None * Returns: the pointer to the named node, or NULL if it doesn't exist */ -HDF* hdf_get_obj (HDF *hdf, char *name); +HDF* hdf_get_obj (HDF *hdf, const char *name); /* * Function: hdf_get_node - Similar to hdf_get_obj except all the nodes @@ -178,7 +179,7 @@ * Output: ret -> the dataset node you asked for * Returns: NERR_NOMEM - unable to allocate new nodes */ -NEOERR * hdf_get_node (HDF *hdf, char *name, HDF **ret); +NEOERR * hdf_get_node (HDF *hdf, const char *name, HDF **ret); /* * Function: hdf_get_child - return the first child of the named node @@ -190,7 +191,7 @@ * Returns: The first child of the named dataset node or NULL if the * node is not found (or it has no children) */ -HDF* hdf_get_child (HDF *hdf, char *name); +HDF* hdf_get_child (HDF *hdf, const char *name); /* * Function: hdf_get_attr - @@ -199,7 +200,7 @@ * Output: * Returns: */ -HDF_ATTR* hdf_get_attr (HDF *hdf, char *name); +HDF_ATTR* hdf_get_attr (HDF *hdf, const char *name); /* * Function: hdf_set_attr - @@ -208,7 +209,8 @@ * Output: * Returns: */ -NEOERR* hdf_set_attr (HDF *hdf, char *name, char *key, char *value); +NEOERR* hdf_set_attr (HDF *hdf, const char *name, const char *key, + const char *value); /* * Function: hdf_obj_child - Return the first child of a dataset node @@ -296,7 +298,7 @@ * Output: None * Returns: NERR_NOMEM */ -NEOERR* hdf_set_value (HDF *hdf, char *name, char *value); +NEOERR* hdf_set_value (HDF *hdf, const char *name, const char *value); /* * Function: hdf_set_valuef - Set the value of a named node @@ -320,8 +322,8 @@ * Output: None * Returns: NERR_NOMEM */ -NEOERR* hdf_set_valuef (HDF *hdf, char *fmt, ...); -NEOERR* hdf_set_valuevf (HDF *hdf, char *fmt, va_list ap); +NEOERR* hdf_set_valuef (HDF *hdf, const char *fmt, ...); +NEOERR* hdf_set_valuevf (HDF *hdf, const char *fmt, va_list ap); /* * Function: hdf_set_int_value - Set the value of a named node to a number @@ -334,7 +336,7 @@ * Output: None * Returns: NERR_NOMEM */ -NEOERR* hdf_set_int_value (HDF *hdf, char *name, int value); +NEOERR* hdf_set_int_value (HDF *hdf, const char *name, int value); /* * Function: hdf_set_copy -> Copy a value from one location in the @@ -348,7 +350,7 @@ * Output: None * Returns: NERR_NOMEM, NERR_NOT_FOUND */ -NEOERR* hdf_set_copy (HDF *hdf, char *dest, char *src); +NEOERR* hdf_set_copy (HDF *hdf, const char *dest, const char *src); /* * Function: hdf_set_buf - Set the value of a node without duplicating @@ -365,7 +367,7 @@ * Returns: NERR_NOMEM - unable to allocate a node */ -NEOERR* hdf_set_buf (HDF *hdf, char *name, char *value); +NEOERR* hdf_set_buf (HDF *hdf, const char *name, char *value); /* * Function: hdf_set_symlink - Set part of the tree to link to another @@ -387,7 +389,7 @@ * Output: None * Returns: NERR_NOMEM */ -NEOERR *hdf_set_symlink (HDF *hdf, char *src, char *dest); +NEOERR *hdf_set_symlink (HDF *hdf, const char *src, const char *dest); /* * Function: hdf_sort_obj - sort the children of an HDF node @@ -424,7 +426,7 @@ * Output: * Returns: NERR_IO, NERR_NOMEM, NERR_PARSE */ -NEOERR* hdf_read_file (HDF *hdf, char *path); +NEOERR* hdf_read_file (HDF *hdf, const char *path); /* * Function: hdf_write_file - write an HDF data file @@ -433,7 +435,7 @@ * Output: * Returns: NERR_IO */ -NEOERR* hdf_write_file (HDF *hdf, char *path); +NEOERR* hdf_write_file (HDF *hdf, const char *path); /* * Function: hdf_write_file_atomic - write an HDF data file atomically @@ -445,7 +447,7 @@ * Output: * Returns: NERR_IO */ -NEOERR* hdf_write_file_atomic (HDF *hdf, char *path); +NEOERR* hdf_write_file_atomic (HDF *hdf, const char *path); /* * Function: hdf_read_string - read an HDF string @@ -454,7 +456,7 @@ * Output: * Returns: NERR_NOMEM, NERR_PARSE */ -NEOERR* hdf_read_string (HDF *hdf, char *s); +NEOERR* hdf_read_string (HDF *hdf, const char *s); /* * Function: hdf_read_string_ignore - Read an HDF string and ignore errors @@ -463,7 +465,7 @@ * Output: * Returns: NERR_NOMEM */ -NEOERR* hdf_read_string_ignore (HDF *hdf, char *s, int ignore); +NEOERR* hdf_read_string_ignore (HDF *hdf, const char *s, int ignore); /* * Function: hdf_write_string - serialize an HDF dataset to a string @@ -481,7 +483,7 @@ * Output: * Returns: */ -NEOERR* hdf_dump (HDF *hdf, char *prefix); +NEOERR* hdf_dump (HDF *hdf, const char *prefix); /* * Function: hdf_dump_format - dump an HDF dataset to FILE *fp @@ -499,7 +501,7 @@ * Output: * Returns: */ -NEOERR* hdf_dump_str(HDF *hdf, char *prefix, int compact, STRING *str); +NEOERR* hdf_dump_str(HDF *hdf, const char *prefix, int compact, STRING *str); /* * Function: hdf_remove_tree - delete a subtree of an HDF dataset @@ -508,7 +510,7 @@ * Output: * Returns: */ -NEOERR* hdf_remove_tree (HDF *hdf, char *name); +NEOERR* hdf_remove_tree (HDF *hdf, const char *name); /* * Function: hdf_copy - copy part of an HDF dataset to another @@ -521,7 +523,7 @@ * Output: None * Returns: NERR_NOMEM, NERR_NOT_FOUND */ -NEOERR* hdf_copy (HDF *dest_hdf, char *name, HDF *src); +NEOERR* hdf_copy (HDF *dest_hdf, const char *name, HDF *src); /* * Function: hdf_search_path - Find a file given a search path in HDF @@ -535,7 +537,7 @@ * Output: full -> the full path of the file * Returns: NERR_NOT_FOUND if the file wasn't found in the search path */ -NEOERR* hdf_search_path (HDF *hdf, char *path, char *full); +NEOERR* hdf_search_path (HDF *hdf, const char *path, char *full); __END_DECLS diff -Nrub clearsilver-0.9.14/util/neo_misc.c clearsilver-0.10.1/util/neo_misc.c --- clearsilver-0.9.14/util/neo_misc.c 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_misc.c 2005-06-30 17:40:45.000000000 -0700 @@ -22,7 +22,7 @@ #include "neo_misc.h" #include "neo_err.h" -void ne_vwarn (char *fmt, va_list ap) +void ne_vwarn (const char *fmt, va_list ap) { char tbuf[20]; char buf[1024]; @@ -42,7 +42,7 @@ fprintf (stderr, "[%s] %s\n", tbuf, buf); } -void ne_warn (char *fmt, ...) +void ne_warn (const char *fmt, ...) { va_list ap; va_start (ap, fmt); @@ -57,7 +57,7 @@ LogLevel = level; } -void ne_log (int level, char *fmt, ...) +void ne_log (int level, const char *fmt, ...) { va_list ap; @@ -130,7 +130,7 @@ return src+sl+1; } -UINT8 *ne_stream_str (UINT8 *dest, char *s, int l) +UINT8 *ne_stream_str (UINT8 *dest, const char *s, int l) { if (l > 255) { diff -Nrub clearsilver-0.9.14/util/neo_misc.h clearsilver-0.10.1/util/neo_misc.h --- clearsilver-0.9.14/util/neo_misc.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_misc.h 2005-07-26 15:41:36.000000000 -0700 @@ -14,6 +14,7 @@ #include #include +#include /* In case they didn't start from ClearSilver.h... */ #ifndef __CS_CONFIG_H_ @@ -102,16 +103,16 @@ #define FALSE 0 #endif -void ne_vwarn (char *fmt, va_list ap); -void ne_warn (char *fmt, ...); +void ne_vwarn (const char *fmt, va_list ap); +void ne_warn (const char *fmt, ...); void ne_set_log (int level); -void ne_log (int level, char *fmt, ...); +void ne_log (int level, const char *fmt, ...); UINT32 python_string_hash (const char *s); UINT8 *ne_stream4 (UINT8 *dest, UINT32 num); UINT8 *ne_unstream4 (UINT32 *pnum, UINT8 *src); UINT8 *ne_stream2 (UINT8 *dest, UINT16 num); UINT8 *ne_unstream2 (UINT16 *pnum, UINT8 *src); -UINT8 *ne_stream_str (UINT8 *dest, char *s, int l); +UINT8 *ne_stream_str (UINT8 *dest, const char *s, int l); UINT8 *ne_unstream_str (char *s, int l, UINT8 *src); double ne_timef (void); UINT32 ne_crc (UINT8 *data, UINT32 bytes); diff -Nrub clearsilver-0.9.14/util/neo_net.c clearsilver-0.10.1/util/neo_net.c --- clearsilver-0.9.14/util/neo_net.c 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_net.c 2005-06-30 17:44:25.000000000 -0700 @@ -146,8 +146,8 @@ } /* Client side */ -NEOERR *ne_net_connect(NSOCK **sock, char *host, int port, int conn_timeout, - int data_timeout) +NEOERR *ne_net_connect(NSOCK **sock, const char *host, int port, + int conn_timeout, int data_timeout) { struct sockaddr_in serv_addr; struct hostent hp; @@ -589,7 +589,7 @@ return nerr_pass(_ne_net_read_int(sock, i, ',')); } -NEOERR *ne_net_write(NSOCK *sock, UINT8 *b, int blen) +NEOERR *ne_net_write(NSOCK *sock, const UINT8 *b, int blen) { NEOERR *err; int x = 0; @@ -622,7 +622,7 @@ return STATUS_OK; } -NEOERR *ne_net_write_line(NSOCK *sock, char *s) +NEOERR *ne_net_write_line(NSOCK *sock, const char *s) { NEOERR *err; @@ -633,7 +633,7 @@ return STATUS_OK; } -NEOERR *ne_net_write_binary(NSOCK *sock, UINT8 *b, int blen) +NEOERR *ne_net_write_binary(NSOCK *sock, const UINT8 *b, int blen) { NEOERR *err; char buf[32]; @@ -655,7 +655,7 @@ return STATUS_OK; } -NEOERR *ne_net_write_str(NSOCK *sock, char *s) +NEOERR *ne_net_write_str(NSOCK *sock, const char *s) { NEOERR *err; diff -Nrub clearsilver-0.9.14/util/neo_net.h clearsilver-0.10.1/util/neo_net.h --- clearsilver-0.9.14/util/neo_net.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_net.h 2005-06-30 17:44:44.000000000 -0700 @@ -36,17 +36,18 @@ NEOERR *ne_net_listen(int port, int *fd); NEOERR *ne_net_accept(NSOCK **sock, int fd, int data_timeout); -NEOERR *ne_net_connect(NSOCK **sock, char *host, int port, int conn_timeout, int data_timeout); +NEOERR *ne_net_connect(NSOCK **sock, const char *host, int port, + int conn_timeout, int data_timeout); NEOERR *ne_net_close(NSOCK **sock); NEOERR *ne_net_read(NSOCK *sock, UINT8 *buf, int buflen); NEOERR *ne_net_read_line(NSOCK *sock, char **buf); NEOERR *ne_net_read_binary(NSOCK *sock, UINT8 **b, int *blen); NEOERR *ne_net_read_str_alloc(NSOCK *sock, char **s, int *len); NEOERR *ne_net_read_int(NSOCK *sock, int *i); -NEOERR *ne_net_write(NSOCK *sock, UINT8 *b, int blen); -NEOERR *ne_net_write_line(NSOCK *sock, char *s); -NEOERR *ne_net_write_binary(NSOCK *sock, UINT8 *b, int blen); -NEOERR *ne_net_write_str(NSOCK *sock, char *s); +NEOERR *ne_net_write(NSOCK *sock, const UINT8 *b, int blen); +NEOERR *ne_net_write_line(NSOCK *sock, const char *s); +NEOERR *ne_net_write_binary(NSOCK *sock, const UINT8 *b, int blen); +NEOERR *ne_net_write_str(NSOCK *sock, const char *s); NEOERR *ne_net_write_int(NSOCK *sock, int i); NEOERR *ne_net_flush(NSOCK *sock); void ne_net_shutdown(void); diff -Nrub clearsilver-0.9.14/util/neo_str.c clearsilver-0.10.1/util/neo_str.c --- clearsilver-0.9.14/util/neo_str.c 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_str.c 2005-06-30 17:42:50.000000000 -0700 @@ -108,13 +108,13 @@ return STATUS_OK; } -NEOERR *string_set (STRING *str, char *buf) +NEOERR *string_set (STRING *str, const char *buf) { str->len = 0; return nerr_pass (string_append (str, buf)); } -NEOERR *string_append (STRING *str, char *buf) +NEOERR *string_append (STRING *str, const char *buf) { NEOERR *err; int l; @@ -128,7 +128,7 @@ return STATUS_OK; } -NEOERR *string_appendn (STRING *str, char *buf, int l) +NEOERR *string_appendn (STRING *str, const char *buf, int l) { NEOERR *err; @@ -142,7 +142,7 @@ } /* this is much more efficient with C99 snprintfs... */ -NEOERR *string_appendvf (STRING *str, char *fmt, va_list ap) +NEOERR *string_appendvf (STRING *str, const char *fmt, va_list ap) { NEOERR *err; char buf[4096]; @@ -181,7 +181,7 @@ return STATUS_OK; } -NEOERR *string_appendf (STRING *str, char *fmt, ...) +NEOERR *string_appendf (STRING *str, const char *fmt, ...) { NEOERR *err; va_list ap; @@ -211,7 +211,8 @@ arr->max = 0; } -NEOERR *string_array_split (ULIST **list, char *s, char *sep, int max) +NEOERR *string_array_split (ULIST **list, char *s, const char *sep, + int max) { NEOERR *err; char *p, *n, *f; @@ -270,7 +271,7 @@ /* Mostly used by vprintf_alloc for non-C99 compliant snprintfs, * this is like vsprintf_alloc except it takes a "suggested" size */ -int vnisprintf_alloc (char **buf, int start_size, char *fmt, va_list ap) +int vnisprintf_alloc (char **buf, int start_size, const char *fmt, va_list ap) { int bl, size; va_list tmp; @@ -295,7 +296,7 @@ } } -char *vnsprintf_alloc (int start_size, char *fmt, va_list ap) +char *vnsprintf_alloc (int start_size, const char *fmt, va_list ap) { char *r; vnisprintf_alloc(&r, start_size, fmt, ap); @@ -304,7 +305,7 @@ /* This works better with a C99 compliant vsnprintf, but should work ok * with versions that return a -1 if it overflows the buffer */ -int visprintf_alloc (char **buf, char *fmt, va_list ap) +int visprintf_alloc (char **buf, const char *fmt, va_list ap) { char ibuf[4096]; int bl, size; @@ -332,7 +333,7 @@ return vnisprintf_alloc(buf, size, fmt, ap); } -char *vsprintf_alloc (char *fmt, va_list ap) +char *vsprintf_alloc (const char *fmt, va_list ap) { char *r; visprintf_alloc(&r, fmt, ap); @@ -341,7 +342,7 @@ /* technically, sprintf's can have null values, so we need to be able to * return a length also like real sprintf */ -int isprintf_alloc (char **buf, char *fmt, ...) +int isprintf_alloc (char **buf, const char *fmt, ...) { va_list ap; int r; @@ -352,7 +353,7 @@ return r; } -char *sprintf_alloc (char *fmt, ...) +char *sprintf_alloc (const char *fmt, ...) { va_list ap; char *r; @@ -369,7 +370,7 @@ * C99 snprintf and it doesn't fit in start_size. * BTW: If you are really worried about the efficiency of these * functions, maybe you shouldn't be using them in the first place... */ -char *nsprintf_alloc (int start_size, char *fmt, ...) +char *nsprintf_alloc (int start_size, const char *fmt, ...) { va_list ap; char *r; @@ -380,13 +381,13 @@ return r; } -BOOL reg_search (char *re, char *str) +BOOL reg_search (const char *re, const char *str) { regex_t search_re; int errcode; char buf[256]; - if ((errcode = regcomp (&search_re, re, REG_ICASE | REG_EXTENDED | REG_NOSUB))) + if ((errcode = regcomp(&search_re, re, REG_ICASE | REG_EXTENDED | REG_NOSUB))) { regerror (errcode, &search_re, buf, sizeof(buf)); ne_warn ("Unable to compile regex %s: %s", re, buf); @@ -417,7 +418,8 @@ return STATUS_OK; } -NEOERR* neos_escape(UINT8 *buf, int buflen, char esc_char, char *escape, char **esc) +NEOERR* neos_escape(UINT8 *buf, int buflen, char esc_char, const char *escape, + char **esc) { int nl = 0; int l = 0; @@ -517,7 +519,7 @@ return s; } -char *repr_string_alloc (char *s) +char *repr_string_alloc (const char *s) { int l,x,i; int nl = 0; diff -Nrub clearsilver-0.9.14/util/neo_str.h clearsilver-0.10.1/util/neo_str.h --- clearsilver-0.9.14/util/neo_str.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/neo_str.h 2005-06-30 17:43:29.000000000 -0700 @@ -26,16 +26,16 @@ void neos_lower (char *s); -char *sprintf_alloc (char *fmt, ...); -char *nsprintf_alloc (int start_size, char *fmt, ...); -char *vsprintf_alloc (char *fmt, va_list ap); -char *vnsprintf_alloc (int start_size, char *fmt, va_list ap); +char *sprintf_alloc (const char *fmt, ...); +char *nsprintf_alloc (int start_size, const char *fmt, ...); +char *vsprintf_alloc (const char *fmt, va_list ap); +char *vnsprintf_alloc (int start_size, const char *fmt, va_list ap); /* Versions of the above which actually return a length, necessary if * you expect embedded NULLs */ -int vnisprintf_alloc (char **buf, int start_size, char *fmt, va_list ap); -int visprintf_alloc (char **buf, char *fmt, va_list ap); -int isprintf_alloc (char **buf, char *fmt, ...); +int vnisprintf_alloc (char **buf, int start_size, const char *fmt, va_list ap); +int visprintf_alloc (char **buf, const char *fmt, va_list ap); +int isprintf_alloc (char **buf, const char *fmt, ...); typedef struct _string { @@ -56,26 +56,30 @@ * can't get DoS'd by someone sending us a line without an end point, * etc. */ void string_init (STRING *str); -NEOERR *string_set (STRING *str, char *buf); -NEOERR *string_append (STRING *str, char *buf); -NEOERR *string_appendn (STRING *str, char *buf, int l); +NEOERR *string_set (STRING *str, const char *buf); +NEOERR *string_append (STRING *str, const char *buf); +NEOERR *string_appendn (STRING *str, const char *buf, int l); NEOERR *string_append_char (STRING *str, char c); -NEOERR *string_appendf (STRING *str, char *fmt, ...); -NEOERR *string_appendvf (STRING *str, char *fmt, va_list ap); +NEOERR *string_appendf (STRING *str, const char *fmt, ...); +NEOERR *string_appendvf (STRING *str, const char *fmt, va_list ap); NEOERR *string_readline (STRING *str, FILE *fp); void string_clear (STRING *str); /* typedef struct _ulist ULIST; */ #include "util/ulist.h" -NEOERR *string_array_split (ULIST **list, char *s, char *sep, int max); +/* s is not const because we actually temporarily modify the string + * during split */ +NEOERR *string_array_split (ULIST **list, char *s, const char *sep, + int max); -BOOL reg_search (char *re, char *str); +BOOL reg_search (const char *re, const char *str); -NEOERR* neos_escape(UINT8 *buf, int buflen, char esc_char, char *escape, char **esc); +NEOERR* neos_escape(UINT8 *buf, int buflen, char esc_char, const char *escape, + char **esc); UINT8 *neos_unescape (UINT8 *s, int buflen, char esc_char); -char *repr_string_alloc (char *s); +char *repr_string_alloc (const char *s); __END_DECLS diff -Nrub clearsilver-0.9.14/util/rcfs.c clearsilver-0.10.1/util/rcfs.c --- clearsilver-0.9.14/util/rcfs.c 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/rcfs.c 2005-06-30 12:16:49.000000000 -0700 @@ -32,7 +32,7 @@ #include "util/ulocks.h" #include "rcfs.h" -NEOERR * rcfs_meta_load (char *path, HDF **meta) +NEOERR * rcfs_meta_load (const char *path, HDF **meta) { NEOERR *err; char fpath[_POSIX_PATH_MAX]; @@ -52,7 +52,7 @@ return STATUS_OK; } -static NEOERR * _meta_save (char *path, HDF *meta) +static NEOERR * _meta_save (const char *path, HDF *meta) { NEOERR *err; char ftmp[_POSIX_PATH_MAX]; @@ -72,7 +72,7 @@ return STATUS_OK; } -NEOERR * rcfs_meta_save (char *path, HDF *meta) +NEOERR * rcfs_meta_save (const char *path, HDF *meta) { NEOERR *err; int lock; @@ -94,7 +94,7 @@ } /* load a specified version of the file, version -1 is latest */ -NEOERR * rcfs_load (char *path, int version, char **data) +NEOERR * rcfs_load (const char *path, int version, char **data) { NEOERR *err; char fpath[_POSIX_PATH_MAX]; @@ -120,7 +120,8 @@ return nerr_pass (err); } -NEOERR * rcfs_save (char *path, char *data, char *user, char *log) +NEOERR * rcfs_save (const char *path, const char *data, const char *user, + const char *log) { NEOERR *err; HDF *meta = NULL, *vers; @@ -185,7 +186,7 @@ return nerr_pass (err); } -NEOERR * rcfs_lock (char *path, int *lock) +NEOERR * rcfs_lock (const char *path, int *lock) { NEOERR *err; char fpath[_POSIX_PATH_MAX]; @@ -208,7 +209,7 @@ fDestroy (lock); } -NEOERR * rcfs_listdir (char *path, ULIST **list) +NEOERR * rcfs_listdir (const char *path, ULIST **list) { NEOERR *err; DIR *dp; diff -Nrub clearsilver-0.9.14/util/rcfs.h clearsilver-0.10.1/util/rcfs.h --- clearsilver-0.9.14/util/rcfs.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/rcfs.h 2005-06-30 12:17:19.000000000 -0700 @@ -20,14 +20,15 @@ NEOERR * rcfs_init (RCFS **rcfs); NEOERR * rcfs_destroy (RCFS **rcfs); -NEOERR * rcfs_load (char *path, int version, char **data); -NEOERR * rcfs_save (char *path, char *data, char *user, char *log); -NEOERR * rcfs_lock (char *path, int *lock); +NEOERR * rcfs_load (const char *path, int version, char **data); +NEOERR * rcfs_save (const char *path, const char *data, const char *user, + const char *log); +NEOERR * rcfs_lock (const char *path, int *lock); void rcfs_unlock (int lock); -NEOERR * rcfs_meta_load (char *path, HDF **meta); -NEOERR * rcfs_meta_save (char *path, HDF *meta); -NEOERR * rcfs_listdir (char *path, ULIST **list); -NEOERR * rcfs_link (char *src_path, char *dest_path); -NEOERR * rcfs_unlink (char *path); +NEOERR * rcfs_meta_load (const char *path, HDF **meta); +NEOERR * rcfs_meta_save (const char *path, HDF *meta); +NEOERR * rcfs_listdir (const char *path, ULIST **list); +NEOERR * rcfs_link (const char *src_path, const char *dest_path); +NEOERR * rcfs_unlink (const char *path); #endif /* __RCFS_H_ */ diff -Nrub clearsilver-0.9.14/util/test/hdftest.c clearsilver-0.10.1/util/test/hdftest.c --- clearsilver-0.9.14/util/test/hdftest.c 2003-10-08 16:46:26.000000000 -0700 +++ clearsilver-0.10.1/util/test/hdftest.c 2005-06-30 18:00:18.000000000 -0700 @@ -9,17 +9,24 @@ int rand_name (char *s, int slen) { char buf[256]; - int x, m, l; + int x, m, l, rl; m = neo_rand(10); + while (1) { neo_rand_word(s, slen); + if (!strchr(s, '.')) break; + } for (x = 1; x < m; x++) { l = strlen(s); neo_rand_word(buf, sizeof(buf)); + rl = strlen(buf); + /* fprintf(stderr, "%s\n", buf); */ + if (rl && slen - l - rl > 1 && !strchr(buf, '.')) { snprintf(s + l, slen - l, ".%s", buf); } + } return 0; } diff -Nrub clearsilver-0.9.14/util/ulocks.c clearsilver-0.10.1/util/ulocks.c --- clearsilver-0.9.14/util/ulocks.c 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/ulocks.c 2005-06-30 12:17:27.000000000 -0700 @@ -23,7 +23,7 @@ #include "neo_files.h" #include "ulocks.h" -NEOERR *fCreate(int *plock, char *file) +NEOERR *fCreate(int *plock, const char *file) { NEOERR *err; int lock; @@ -72,7 +72,7 @@ return; } -NEOERR *fFind(int *plock, char *file) +NEOERR *fFind(int *plock, const char *file) { int lock; diff -Nrub clearsilver-0.9.14/util/ulocks.h clearsilver-0.10.1/util/ulocks.h --- clearsilver-0.9.14/util/ulocks.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/ulocks.h 2005-06-30 12:17:32.000000000 -0700 @@ -18,7 +18,7 @@ #define __ULOCKS_H_ -NEOERR *fCreate(int *plock, char *file); +NEOERR *fCreate(int *plock, const char *file); /* * Function: fCreate - create a file lock. * Description: Creates a file lock on named file . The lock is @@ -31,7 +31,7 @@ * MT-Level: Safe. */ -NEOERR *fFind(int *plock, char *file); +NEOERR *fFind(int *plock, const char *file); /* * Function: fFind - find a file lock. * Description: Find a file identified by the path , and returns a diff -Nrub clearsilver-0.9.14/util/wdb.c clearsilver-0.10.1/util/wdb.c --- clearsilver-0.9.14/util/wdb.c 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/wdb.c 2005-06-30 17:49:33.000000000 -0700 @@ -77,7 +77,7 @@ #define hexval(c) Index_hex[(unsigned int)(c)] /* Encoding means any non-printable characters and : and % */ -static NEOERR *wdb_encode_str_alloc (char *s, char **o) +static NEOERR *wdb_encode_str_alloc (const char *s, char **o) { int x = 0; int c = 0; @@ -122,7 +122,7 @@ return STATUS_OK; } -static NEOERR *wdb_decode_str_alloc (char *s, char **o) +static NEOERR *wdb_decode_str_alloc (const char *s, char **o) { int x = 0; int c = 0; @@ -402,7 +402,7 @@ return nerr_raise (r, "Unable to save defn"); } -static NEOERR *wdb_load_defn (WDB *wdb, char *name) +static NEOERR *wdb_load_defn (WDB *wdb, const char *name) { char path[_POSIX_PATH_MAX]; char line[1024]; @@ -443,7 +443,7 @@ return STATUS_OK; } -static NEOERR *wdb_save_defn (WDB *wdb, char *name) +static NEOERR *wdb_save_defn (WDB *wdb, const char *name) { char path[_POSIX_PATH_MAX]; char path2[_POSIX_PATH_MAX]; @@ -479,7 +479,7 @@ return STATUS_OK; } -NEOERR *wdb_open (WDB **wdb, char *name, int flags) +NEOERR *wdb_open (WDB **wdb, const char *name, int flags) { WDB *my_wdb; char path[_POSIX_PATH_MAX]; @@ -790,7 +790,7 @@ return nerr_raise(NERR_PARSE, "Unable to unpack row %s", row->key_value); } -NEOERR *wdb_column_insert (WDB *wdb, int loc, char *key, char type) +NEOERR *wdb_column_insert (WDB *wdb, int loc, const char *key, char type) { NEOERR *err; WDBColumn *col, *ocol; @@ -872,7 +872,7 @@ return STATUS_OK; } -NEOERR *wdb_column_update (WDB *wdb, char *oldkey, char *newkey) +NEOERR *wdb_column_update (WDB *wdb, const char *oldkey, const char *newkey) { WDBColumn *ocol, *col; WDBColumn *vcol; @@ -933,7 +933,7 @@ return STATUS_OK; } -NEOERR *wdb_column_delete (WDB *wdb, char *name) +NEOERR *wdb_column_delete (WDB *wdb, const char *name) { WDBColumn *col; NEOERR *err = STATUS_OK; @@ -964,14 +964,14 @@ return STATUS_OK; } -NEOERR *wdb_column_exchange (WDB *wdb, char *key1, char *key2) +NEOERR *wdb_column_exchange (WDB *wdb, const char *key1, const char *key2) { return nerr_raise (NERR_ASSERT, "wdb_column_exchange: Not Implemented"); } /* Not that there's that much point in changing the key name ... */ -NEOERR *wdb_update (WDB *wdb, char *name, char *key) +NEOERR *wdb_update (WDB *wdb, const char *name, const char *key) { if (name != NULL && strcmp(wdb->name, name)) { @@ -1001,8 +1001,8 @@ return STATUS_OK; } -NEOERR *wdb_create (WDB **wdb, char *path, char *name, char *key, ULIST *col_def, - int flags) +NEOERR *wdb_create (WDB **wdb, const char *path, const char *name, + const char *key, ULIST *col_def, int flags) { WDB *my_wdb; char d_path[_POSIX_PATH_MAX]; @@ -1072,7 +1072,7 @@ return STATUS_OK; } -NEOERR *wdb_attr_get (WDB *wdb, char *key, char **value) +NEOERR *wdb_attr_get (WDB *wdb, const char *key, char **value) { void *v; @@ -1086,7 +1086,7 @@ return STATUS_OK; } -NEOERR *wdb_attr_set (WDB *wdb, char *key, char *value) +NEOERR *wdb_attr_set (WDB *wdb, const char *key, const char *value) { NEOERR *err = STATUS_OK; char *v; @@ -1104,7 +1104,7 @@ return STATUS_OK; } -NEOERR *wdbr_get (WDB *wdb, WDBRow *row, char *key, void **value) +NEOERR *wdbr_get (WDB *wdb, WDBRow *row, const char *key, void **value) { WDBColumn *col; void *v; @@ -1124,7 +1124,7 @@ return STATUS_OK; } -NEOERR *wdbr_set (WDB *wdb, WDBRow *row, char *key, void *value) +NEOERR *wdbr_set (WDB *wdb, WDBRow *row, const char *key, void *value) { WDBColumn *col; @@ -1215,7 +1215,7 @@ return nerr_pass(err); } -NEOERR *wdbr_lookup (WDB *wdb, char *key, WDBRow **row) +NEOERR *wdbr_lookup (WDB *wdb, const char *key, WDBRow **row) { DBT dkey, data; NEOERR *err = STATUS_OK; @@ -1230,7 +1230,7 @@ dkey.flags = DB_DBT_USERMEM; data.flags = DB_DBT_MALLOC; - dkey.data = key; + dkey.data = (void *)key; dkey.size = strlen(key); r = wdb->db->get (wdb->db, NULL, &dkey, &data, 0); @@ -1269,7 +1269,7 @@ return STATUS_OK; } -NEOERR *wdbr_create (WDB *wdb, char *key, WDBRow **row) +NEOERR *wdbr_create (WDB *wdb, const char *key, WDBRow **row) { WDBRow *my_row; NEOERR *err = STATUS_OK; @@ -1324,7 +1324,7 @@ return STATUS_OK; } -NEOERR *wdbr_delete (WDB *wdb, char *key) +NEOERR *wdbr_delete (WDB *wdb, const char *key) { DBT dkey; int r; @@ -1333,7 +1333,7 @@ dkey.flags = DB_DBT_USERMEM; - dkey.data = key; + dkey.data = (void *)key; dkey.size = strlen(key); r = wdb->db->del (wdb->db, NULL, &dkey, 0); @@ -1473,7 +1473,7 @@ return STATUS_OK; } -NEOERR *wdbr_find (WDB *wdb, WDBCursor *cursor, char *key, WDBRow **row) +NEOERR *wdbr_find (WDB *wdb, WDBCursor *cursor, const char *key, WDBRow **row) { DBT dkey, data; WDBRow *my_row; @@ -1492,7 +1492,7 @@ dkey.flags = DB_DBT_USERMEM; data.flags = DB_DBT_MALLOC; - dkey.data = key; + dkey.data = (void *)key; dkey.size = strlen(key); r = cursor->db_cursor->c_get (cursor->db_cursor, &dkey, &data, DB_SET_RANGE); diff -Nrub clearsilver-0.9.14/util/wdb.h clearsilver-0.10.1/util/wdb.h --- clearsilver-0.9.14/util/wdb.h 2004-07-28 15:17:42.000000000 -0700 +++ clearsilver-0.10.1/util/wdb.h 2005-06-30 12:19:53.000000000 -0700 @@ -72,16 +72,16 @@ #define WDBR_INSERT (1<<0) -NEOERR * wdb_open (WDB **wdb, char *name, int flags); +NEOERR * wdb_open (WDB **wdb, const char *name, int flags); NEOERR * wdb_save (WDB *wdb); -NEOERR * wdb_update (WDB *wdb, char *name, char *key); -NEOERR * wdb_create (WDB **wdb, char *path, char *name, char *key, - ULIST *col_def, int flags); +NEOERR * wdb_update (WDB *wdb, const char *name, const char *key); +NEOERR * wdb_create (WDB **wdb, const char *path, const char *name, + const char *key, ULIST *col_def, int flags); void wdb_destroy (WDB **wdb); -NEOERR * wdb_column_insert (WDB *wdb, int loc, char *key, char type); -NEOERR * wdb_column_delete (WDB *wdb, char *name); -NEOERR * wdb_column_update (WDB *wdb, char *oldkey, char *newkey); -NEOERR * wdb_column_exchange (WDB *wdb, char *key1, char *key2); +NEOERR * wdb_column_insert (WDB *wdb, int loc, const char *key, char type); +NEOERR * wdb_column_delete (WDB *wdb, const char *name); +NEOERR * wdb_column_update (WDB *wdb, const char *oldkey, const char *newkey); +NEOERR * wdb_column_exchange (WDB *wdb, const char *key1, const char *key2); /* * function: wdb_keys @@ -96,19 +96,19 @@ */ NEOERR * wdb_keys (WDB *wdb, char **primary_key, ULIST **data); -NEOERR * wdb_attr_get (WDB *wdb, char *key, char **value); -NEOERR * wdb_attr_set (WDB *wdb, char *key, char *value); +NEOERR * wdb_attr_get (WDB *wdb, const char *key, char **value); +NEOERR * wdb_attr_set (WDB *wdb, const char *key, const char *value); NEOERR * wdb_attr_next (WDB *wdb, char **key, char **value); -NEOERR * wdbr_lookup (WDB *wdb, char *key, WDBRow **row); -NEOERR * wdbr_create (WDB *wdb, char *key, WDBRow **row); +NEOERR * wdbr_lookup (WDB *wdb, const char *key, WDBRow **row); +NEOERR * wdbr_create (WDB *wdb, const char *key, WDBRow **row); NEOERR * wdbr_save (WDB *wdb, WDBRow *row, int flags); -NEOERR * wdbr_delete (WDB *wdb, char *key); +NEOERR * wdbr_delete (WDB *wdb, const char *key); NEOERR * wdbr_destroy (WDB *wdb, WDBRow **row); -NEOERR * wdbr_get (WDB *wdb, WDBRow *row, char *key, void **value); -NEOERR * wdbr_set (WDB *wdb, WDBRow *row, char *key, void *value); +NEOERR * wdbr_get (WDB *wdb, WDBRow *row, const char *key, void **value); +NEOERR * wdbr_set (WDB *wdb, WDBRow *row, const char *key, void *value); NEOERR * wdbr_dump (WDB *wdb, WDBRow *row); NEOERR * wdbr_next (WDB *wdb, WDBCursor *cursor, WDBRow **row, int flags); -NEOERR * wdbr_find (WDB *wdb, WDBCursor *cursor, char *key, WDBRow **row); +NEOERR * wdbr_find (WDB *wdb, WDBCursor *cursor, const char *key, WDBRow **row); NEOERR * wdbc_create (WDB *wdb, WDBCursor **cursor); NEOERR * wdbc_destroy (WDB *wdb, WDBCursor **cursor); diff -Nrub clearsilver-0.9.14/util/wildmat.c clearsilver-0.10.1/util/wildmat.c --- clearsilver-0.9.14/util/wildmat.c 2003-04-02 15:07:36.000000000 -0800 +++ clearsilver-0.10.1/util/wildmat.c 2005-06-30 12:20:55.000000000 -0700 @@ -56,7 +56,7 @@ ** Match text and p, return TRUE, FALSE, or ABORT. */ static int -DoMatch(register char *text, register char *p) +DoMatch(register const char *text, register const char *p) { register int last; register int matched; @@ -120,7 +120,7 @@ ** Match text and p, return TRUE, FALSE, or ABORT. */ static int -DoMatchCaseInsensitive(register char *text, register char *p) +DoMatchCaseInsensitive(register const char *text, register const char *p) { register int last; register int matched; @@ -184,7 +184,7 @@ ** User-level routine. Returns TRUE or FALSE. */ int -wildmat(char *text, char *p) +wildmat(const char *text, const char *p) { #ifdef OPTIMIZE_JUST_STAR if (p[0] == '*' && p[1] == '\0') @@ -197,7 +197,7 @@ ** User-level routine. Returns TRUE or FALSE. */ int -wildmatcase(char *text, char *p) +wildmatcase(const char *text, const char *p) { #ifdef OPTIMIZE_JUST_STAR if (p[0] == '*' && p[1] == '\0') diff -Nrub clearsilver-0.9.14/util/wildmat.h clearsilver-0.10.1/util/wildmat.h --- clearsilver-0.9.14/util/wildmat.h 2002-02-28 16:53:41.000000000 -0800 +++ clearsilver-0.10.1/util/wildmat.h 2005-06-30 12:21:02.000000000 -0700 @@ -8,8 +8,8 @@ __BEGIN_DECLS -int wildmat(char *text, char *p); -int wildmatcase(char *text, char *p); +int wildmat(const char *text, const char *p); +int wildmatcase(const char *text, const char *p); __END_DECLS