"Fossies" - the Fresh Open Source Software Archive

Member "sitecopy-0.16.6/src/common.c" (24 Jan 2005, 2742 Bytes) of archive /linux/www/sitecopy-0.16.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "common.c" see the Fossies "Dox" file reference documentation.

    1 /* 
    2    sitecopy, manage remote web sites.
    3    Copyright (C) 1998-2004, Joe Orton <joe@manyfish.co.uk>.
    4                                                                      
    5    This program is free software; you can redistribute it and/or modify
    6    it under the terms of the GNU General Public License as published by
    7    the Free Software Foundation; either version 2 of the License, or
    8    (at your option) any later version.
    9   
   10    This program is distributed in the hope that it will be useful,
   11    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13    GNU General Public License for more details.
   14   
   15    You should have received a copy of the GNU General Public License
   16    along with this program; if not, write to the Free Software
   17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   18 
   19 */
   20 
   21 #include "config.h"
   22 
   23 #include <stdio.h>
   24 #ifdef HAVE_STRING_H
   25 #include <string.h>
   26 #endif
   27 #ifdef HAVE_STRINGS_H
   28 #include <strings.h>
   29 #endif 
   30 #include <stdarg.h>
   31 #ifdef HAVE_STDLIB_H
   32 #include <stdlib.h>
   33 #endif /* HAVE_STDLIB_H */
   34 
   35 #ifdef HAVE_LANGINFO_H
   36 #include <langinfo.h>
   37 #endif
   38 
   39 #include <ctype.h>
   40 
   41 #include <ne_string.h>
   42 #include <ne_utils.h>
   43 
   44 #include "i18n.h"
   45 #include "common.h"
   46 
   47 #ifdef NE_DEBUGGING
   48 
   49 static const struct {
   50     const char *name;
   51     int val;
   52 } debug_map[] = {
   53     { "socket", NE_DBG_SOCKET },
   54     { "files", DEBUG_FILES },
   55     { "rcfile", DEBUG_RCFILE },
   56     { "ftp", DEBUG_FTP },
   57     { "xml", NE_DBG_XML },
   58     { "xmlparse", NE_DBG_XMLPARSE },
   59     { "http", NE_DBG_HTTP },
   60     { "httpauth", NE_DBG_HTTPAUTH },
   61     { "httpbody", NE_DBG_HTTPBODY },
   62     { "cleartext", NE_DBG_HTTPPLAIN },
   63     { "ssl", NE_DBG_SSL },
   64     { "rsh", DEBUG_RSH },
   65     { "sftp", DEBUG_SFTP },
   66     { NULL, 0 }
   67 };
   68 
   69 int map_debug_options(const char *opts, int *mask, char *errbuf)
   70 {
   71     char *token, *ptr, *orig;
   72     int n, ret = 0, mapped;
   73 
   74     ptr = orig = ne_strdup(opts);
   75 
   76     do {
   77         token = ne_token(&ptr, ',');
   78         token = ne_shave(token, " ");
   79 
   80     mapped = 0;
   81         
   82     for (n = 0; debug_map[n].name != NULL; n++) {
   83         if (strcasecmp(token, debug_map[n].name) == 0) {
   84         ret |= debug_map[n].val;
   85         mapped = 1;
   86         break;
   87         }
   88     }
   89     if (!mapped) {
   90         memset(errbuf, 0, 20);
   91         strncpy(errbuf, token, 19);
   92             ne_free(orig);
   93         return -1;
   94     }
   95     } while (ptr);
   96     
   97     *mask = ret;
   98     ne_free(orig);
   99     return 0;
  100 }
  101 #endif /* DEBUGGING */
  102 
  103 /* Snagged from fetchmail */
  104 # if !HAVE_STRERROR && !defined(strerror)
  105 char *strerror (errnum)
  106      int errnum;
  107 {
  108   extern char *sys_errlist[];
  109   extern int sys_nerr;
  110 
  111   if (errnum > 0 && errnum <= sys_nerr)
  112     return sys_errlist[errnum];
  113   return _("Unknown system error");
  114 }
  115 # endif /* HAVE_STRERROR */