## root/include/sys_log.h

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

## INCLUDED FROM

    /* Defines for the system log process.
       Rick Smereka, Copyright (C) 1997-2004.

       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 QNX version Feb/97, Rick Smereka

       Changed define 'SYS_LOG_NID' to zero to allow for multiple system
       log servers located on any node ID. Dec/97, Rick Smereka

       Ported to 32bit Windows under CodeWarrior. Communication
       method is Berkeley Sockets using the Microsoft implementation
       called WinSock which claims to be a superset of the original
       Berkeley Socket. I have tried as much as possible to stay
       away from the Microsoft extensions for portability reasons.
       Server is TCP connection oriented iterative.
       Dec/98, Rick Smereka

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

       Added 'is_sys_log_active' function prototype.
       Feb/99, Rick Smereka

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

       Removed defines of default port, node and IPC config file.
       Added 'extern "C"' section for C++ compilers. Added
       all common socket codes from 'flsocket.h'. Changed
       send messages defines by adding the prefix 'SYS_LOG_SEND'.
       Added prototypes for the new functions (common socket codes).
       Mar/2000, Rick Smereka

       Added include of 'comcode.h' which contains common send and reply
       codes. Added prototype of function 'sys_log_get_active'.
       Apr/2000, Rick Smereka

       Added error code 'SYS_LOG_BAD_IP' to maintain compatibility with
       the 'REALbasic' version. Jun/2000, Rick Smereka

       Modified for use by both socket and QNX message passing IPC.
       Added prototype 'sys_log_nf'. Oct/2001, Rick Smereka

       Added a parameter to the 'sys_log_init' prototype. Jun/2002,
       Rick Smereka

       Ported to Debian Linux. Nov/2002, Rick Smereka

       Added send codes 'SYS_LOG_SEND_TRANS_NUM' and 'SYS_LOG_SEND_CONNECT_NUM'.
       Added prototypes 'sys_log_trans_num' and 'sys_log_connect_num'.
       May/2003, Rick Smereka

       Added function prototypes 'sys_log_console' and 'sys_log_get_console'.
       Mar/2004, Rick Smereka */

    /* define common send/reply codes */

    #include "comcode.h"

    /* send message types */

    #define SYS_LOG_SEND 1                                      // log a mess
    #define SYS_LOG_SEND_LOCK 2                                 // lock log
    #define SYS_LOG_SEND_UNLOCK 3                               // unlock log
    #define SYS_LOG_SEND_OPEN 4                                 // open log
    #define SYS_LOG_SEND_CLOSE 5                                // close log
    #define SYS_LOG_SEND_DELETE 6                               // delete log
    #define SYS_LOG_SEND_STATUS SOCKET_SEND_STATUS              // get status
    #define SYS_LOG_SEND_STOP SOCKET_SEND_TERM                  // halt server
    #define SYS_LOG_SEND_LOG_OFF SOCKET_SEND_LOG_OFF            // not impl
    #define SYS_LOG_SEND_LOG_ON SOCKET_SEND_LOG_ON              // not impl
    #define SYS_LOG_SEND_LOG_STATUS SOCKET_SEND_LOG_STATUS      // not impl
    #define SYS_LOG_SEND_SERVICE_NAME SOCKET_SEND_SERVICE_NAME  // get srv name
    #define SYS_LOG_SEND_VERSION SOCKET_SEND_VERSION            // get version
    #define SYS_LOG_SEND_TRANS_NUM SOCKET_SEND_TRANS_NUM        // get trans
    #define SYS_LOG_SEND_CONNECT_NUM SOCKET_SEND_CONNECT_NUM    // get connected

    // maximum message size

    #define SYS_LOG_MAXMES 8192

    /* reply/error codes */

    #define SYS_LOG_OK SOCKET_RC_OK             // ok
    #define SYS_LOG_TERM 20                     // terminating server
    #define SYS_LOG_WERR 21                     // error writing to log file
    #define SYS_LOG_UNKNOWN 22                  // unknown request
    #define SYS_LOG_NOMES 23                    // no message to send
    #define SYS_LOG_ALREADY_LOCKED 24           // log file is already locked
    #define SYS_LOG_ALREADY_UNLOCKED 25         // log file already unlocked
    #define SYS_LOG_ALREADY_OPEN 26             // already open
    #define SYS_LOG_ALREADY_CLOSED 27           // already closed
    #define SYS_LOG_ALLOC_FAIL 28               // internal memory alloc fail
    #define SYS_LOG_PARM_ERROR 29               // parameter error
    #define SYS_LOG_BAD_REPLY 30                // reply made no sense
    #define SYS_LOG_NO_ACCESS 31                // access not allowed
    #define SYS_LOG_NOT_IMPLEMENTED 32          // not implemented
    #define SYS_LOG_NO_INIT 33                  // sys_log not init
    #define SYS_LOG_INTERNAL_ERROR 34           // unexpected internal error
    #define SYS_LOG_SOCLOC_ERROR 35             // unexpected 'socloc' error
    #define SYS_LOG_NO_SERVER 36                // no 'sys_log' server avail
    #define SYS_LOG_SOCLOC_NO_INIT 37           // 'socloc' not init
    #define SYS_LOG_BAD_IP 38                   // bad IP address
    #define SYS_LOG_VC_ERROR SOCKET_RC_VC_ERROR // socket error

    /* TCP/IP IPC specific defines */

    #ifdef IPC_TCP

    /* sys_log service name for 'socloc' */

    #define SYS_LOG_SERVICE_NAME "sys_log"
    #else
    /* QNX message passing IPC */

    #define SYS_LOG_SERVICE_NAME "/sys_log"
    #endif

    // function prototypes from 'sys_log.c' client API

    #ifdef __cplusplus
    extern "C"
    {
    #endif

    int sys_log_init(char *);
    void sys_log_end(void);
    int sys_log(char *,...);
    int sys_log_nf(char *);
    int sys_log_status(void);
    int sys_log_stop(char *);
    int sys_log_lock(void);
    int sys_log_unlock(void);
    int sys_log_open(void);
    int sys_log_close(void);
    int sys_log_delete(char *);
    int sys_log_log_off(void);
    int sys_log_log_on(char *);
    int sys_log_log_status(int *, char *);
    int sys_log_service_name(char *);
    int sys_log_version(char *);
    int sys_log_trans_num(long *);
    int sys_log_connect_num(int *);
    int is_sys_log_active(void);
    void sys_log_console(int);
    int sys_log_get_console(void);
    #ifdef IPC_TCP
    void sys_log_get_active(char *, int *);
    #endif

    #ifdef __cplusplus
    }
    #endif

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