## root/clib/slogcode.c

/* [<][>][^][v][top][bottom][index][help] */

## DEFINITIONS

This source file includes following definitions.

1. sys_log_code_string

    /* 'sys_log' error message translation module.
       Rick Smereka, Copyright (C) 1998-2002.

       This program is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published by
       the Free Software Foundation; either version 2 of the License, or
       (at your option) any later version.

       This program is distributed in the hope that it will be useful,
       but WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       GNU General Public License for more details.

       You should have received a copy of the GNU General Public License
       along with this program; if not, get a copy via the Internet at
       http://gnu.org/copyleft/gpl.html or write to the Free Software
       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
       MA 02111-1307 USA

       You can contact the author via email at rsmereka@future-lab.com

       Original version for CodeWarrior V4 under Windows 32bit.
       Dec/98, Rick Smereka

       Ported to HP-UX under GNU C 2.8.1.
       Jan/99, Rick Smereka

       Ported to Red Hat Linux 5.2, Jul/99, Rick Smereka

       Modified to use common socket codes in 'flsocket.h' and
       changed messages. Added text for code 'SYS_LOG_NO_INIT'.
       Mar/2000, Rick Smereka

       Added translation of the error code 'SYS_LOG_BAD_IP'.
       Jun/2001, Rick Smereka

       Removed include of 'sys_log.h' and 'slogcode.h' as they
       are automatically included from 'enhlib.h'.
       Sep/2001, Rick Smereka

       Ported to Debian Linux. Nov/2002, Rick Smereka */

    #include "stdhead.h"
    #include "flsocket.h"

    void sys_log_code_string(int code, char *mes)
    {
       /* Interpret a sys_log code ('code') and return the
          English description in 'mes' which must be
          already allocated to sufficient size. */

       switch(code)
          {
          case SYS_LOG_OK:
             strcpy(mes, "ok");
             break;

          case SYS_LOG_TERM:
             strcpy(mes, "received shutdown request, terminating server");
             break;

          case SYS_LOG_WERR:
             strcpy(mes, "error writing to log file");
             break;

          case SYS_LOG_UNKNOWN:
             strcpy(mes, "unknown sys_log command");
             break;

          case SYS_LOG_NOMES:
             strcpy(mes, "request to log without a message");
             break;

          case SYS_LOG_ALREADY_LOCKED:
             strcpy(mes, "log file already locked");
             break;

          case SYS_LOG_ALREADY_UNLOCKED:
             strcpy(mes, "log file already unlocked");
             break;

          case SYS_LOG_ALREADY_OPEN:
             strcpy(mes, "log file already open");
             break;

          case SYS_LOG_ALREADY_CLOSED:
             strcpy(mes, "log file already closed");
             break;

          case SYS_LOG_ALLOC_FAIL:
             strcpy(mes, "memory allocation failure");
             break;

          case SYS_LOG_PARM_ERROR:
             strcpy(mes, "parameter error");
             break;

          case SYS_LOG_BAD_REPLY:
             strcpy(mes, "bad (unknown) reply from server");
             break;

          case SYS_LOG_NO_ACCESS:
             strcpy(mes, "permission denied");
             break;

          case SYS_LOG_NOT_IMPLEMENTED:
             strcpy(mes, "command not implemented");
             break;

          case SYS_LOG_VC_ERROR:
    #ifdef IPC_TCP
             strcpy(mes, "socket communication error");
    #else
             strcpy(mes, "virtual circuit error");
    #endif

             break;

          case SYS_LOG_NO_INIT:
             strcpy(mes, "sys_log interface not initialized");
             break;

          case SYS_LOG_INTERNAL_ERROR:
             strcpy(mes, "unexpected internal error");
             break;

          case SYS_LOG_SOCLOC_ERROR:
             strcpy(mes, "unexpected 'socloc' error");
             break;

          case SYS_LOG_NO_SERVER:
             strcpy(mes, "no 'sys_log' server available");
             break;

          case SYS_LOG_SOCLOC_NO_INIT:
             strcpy(mes, "'socloc' has not been initialized");
             break;

          case SYS_LOG_BAD_IP:
             strcpy(mes, "bad IP address");
             break;
          };
    }

/* [<][>][^][v][top][bottom][index][help] */