From: Wilfried Göesgens Date: Tue, 14 Aug 2007 14:26:05 +0000 (+0000) Subject: * next try to get a working new tokenizer. this seems to be working X-Git-Tag: v7.86~3150 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=c6d7de6a0ff0b2df71f7a7a2ebb586b36b329b84;p=citadel.git * next try to get a working new tokenizer. this seems to be working * a way to have backtraces in log in citserver. --- diff --git a/citadel/citserver.c b/citadel/citserver.c index d74c3a0ab..46f3834f0 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -26,6 +26,10 @@ # endif #endif +#if HAVE_BACKTRACE +#include +#endif + #include #include #include @@ -66,6 +70,28 @@ int ScheduledShutdown = 0; int do_defrag = 0; time_t server_startup_time; +/** + * \brief print the actual stack frame. + */ +void cit_backtrace(void) +{ +#ifdef HAVE_BACKTRACE + void *stack_frames[50]; + size_t size, i; + char **strings; + + + size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*)); + strings = backtrace_symbols(stack_frames, size); + for (i = 0; i < size; i++) { + if (strings != NULL) + lprintf(1, "%s\n", strings[i]); + else + lprintf(1, "%p\n", stack_frames[i]); + } + free(strings); +#endif +} /* * Various things that need to be initialized at startup */ diff --git a/citadel/configure.ac b/citadel/configure.ac index f735aadf6..af09ef2d9 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -294,7 +294,7 @@ dnl Checks for libraries. dnl We want to test for the following in libc before checking for their dnl respective libraries, because some systems (like Irix) have both, and the dnl non-libc versions may be broken. -AC_CHECK_FUNCS(crypt gethostbyname connect) +AC_CHECK_FUNCS(crypt gethostbyname connect backtrace) if test "$ac_cv_func_gethostbyname" = no; then AC_CHECK_LIB(nsl, gethostbyname) diff --git a/citadel/tools.c b/citadel/tools.c index 86ab798f6..7016d96b0 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -101,16 +101,18 @@ int num_tokens(const char *source, char tok) return (count); } +//extern void cit_backtrace(void); + /* * extract_token() - a string tokenizer * returns -1 if not found, or length of token. - * / + */ long extract_token(char *dest, const char *source, int parmnum, char separator, int maxlen) { - const char *s; /* source * / - int len = 0; /* running total length of extracted string * / - int current_token = 0; /* token currently being processed * / + const char *s; //* source * / + int len = 0; //* running total length of extracted string * / + int current_token = 0; //* token currently being processed * / s = source; @@ -118,6 +120,8 @@ long extract_token(char *dest, const char *source, int parmnum, char separator, return(-1); } +// cit_backtrace(); +// lprintf (CTDL_DEBUG, "test >: n: %d sep: %c source: %s \n willi \n", parmnum, separator, source); dest[0] = 0; if (s == NULL) { @@ -128,7 +132,9 @@ long extract_token(char *dest, const char *source, int parmnum, char separator, if (*s == separator) { ++current_token; } - if ( (current_token == parmnum) && (len < maxlen) ) { + if ( (current_token == parmnum) && + (*s != separator) && + (len < maxlen) ) { dest[len] = *s; ++len; } @@ -138,28 +144,36 @@ long extract_token(char *dest, const char *source, int parmnum, char separator, ++s; } - dest[len] = 0; - if (current_token < parmnum) return(-1); + dest[len] = '\0'; + if (current_token < parmnum) { +// lprintf (CTDL_DEBUG,"test : n: %d sep: %c source: %s \n willi \n", parmnum, separator, source); strcpy(dest, ""); - /* Locate desired parameter */ + //* Locate desired parameter * / s = source; while (count < parmnum) { - /* End of string, bail! */ + //* End of string, bail! * / if (!*s) { s = NULL; break; @@ -169,15 +183,19 @@ long extract_token(char *dest, const char *source, int parmnum, char separator, } s++; } - if (!s) return -1; /* Parameter not found */ - + if (!s) { + lprintf (CTDL_DEBUG,"test