]> code.citadel.org Git - citadel.git/blobdiff - citadel/support.c
change to db-open flags
[citadel.git] / citadel / support.c
index a3ebffc19142e7bb6d52288160b0011f25df099d..af155d31df92298178ab5e9c03a742be304fa133 100644 (file)
@@ -1,29 +1,22 @@
 /*
- * $Id$
- *
  * Server-side utility functions
- *
  */
 
 #include "sysdep.h"
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <ctype.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys/stat.h>
+#include <libcitadel.h>
+
 #include "citadel.h"
-#include "server.h"
 #include "support.h"
-#include "tools.h"
 
 /*
  * strproc()  -  make a string 'nice'
  */
 void strproc(char *string)
 {
-       int a;
+       int a, b;
 
        if (string == NULL) return;
        if (IsEmptyStr(string)) return;
@@ -34,11 +27,15 @@ void strproc(char *string)
                if (string[a]>126) string[a]=32;
        }
 
+       /* a is now the length of our string. */
        /* Remove leading and trailing blanks */
-       while( (string[0]<33) && (!IsEmptyStr(string)) )
-               strcpy(string,&string[1]);
-       while( (string[strlen(string)-1]<33) && (!IsEmptyStr(string)) )
-               string[strlen(string)-1]=0;
+       while( (string[a-1]<33) && (!IsEmptyStr(string)) )
+               string[--a]=0;
+       b = 0;
+       while( (string[b]<33) && (!IsEmptyStr(&string[b])) )
+               b++;
+       if (b > 0)
+               memmove(string,&string[b], a - b + 1);
 
        /* Remove double blanks */
        for (a=0; !IsEmptyStr(&string[a]); ++a) {
@@ -84,54 +81,3 @@ int getstring(FILE *fp, char *string)
                } while(string[0]=='#');
        return(strlen(string));
 }
-
-
-/*
- * pattern2()  -  searches for patn within search string, returns pos 
- */ 
-int pattern2(char *search, char *patn)
-{
-       int a, len;
-       
-       len = strlen(patn);
-       for (a=0; !IsEmptyStr(&search[a]); ++a) {
-               if (!strncasecmp(&search[a],patn, len)) return(a);
-               }
-       return(-1);
-       }
-
-
-/*
- * mesg_locate()  -  locate a message or help file, case insensitive
- */
-void mesg_locate(char *targ, size_t n, const char *searchfor,
-                int numdirs, const char * const *dirs)
-{
-       int a;
-       char buf[SIZ];
-       struct stat test;
-
-       for (a=0; a<numdirs; ++a) {
-               snprintf(buf, sizeof buf, "%s/%s", dirs[a], searchfor);
-               if (!stat(buf, &test)) {
-                       snprintf(targ, n, "%s/%s", dirs[a], searchfor);
-                       return;
-               }
-       }
-       strcpy(targ,"");
-}
-
-
-#ifndef HAVE_STRERROR
-/*
- * replacement strerror() for systems that don't have it
- */
-char *strerror(int e)
-{
-       static char buf[32];
-
-       snprintf(buf,sizeof buf,"errno = %d",e);
-       return(buf);
-       }
-#endif
-