/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- db_io_code_string
- db_io_code_log
- dbeng_io_code_string
- dbeng_io_code_log
/* DBENG (Bbuuzzb) io code error message module.
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 Dec/97, Rick Smereka
Ported to 32bit Windows under CodeWarrior V4. Changed
explaination of 'DBENG_VC_ERROR' from 'virtual circuit'
error to 'socket error'. Dec/98, Rick Smereka
Ported to HP-UX under GNU C 2.8.1.
Jan/99, Rick Smereka
Added configuration messages. Mar/99, Rick Smereka
Ported to Red Hat Linux 5.2, Jul/99, Rick Smereka
Added include of 'flsocket.h'. Mar/2000, Rick Smereka
Added messages for codes 'DBENG_SOCLOC_NO_INIT',
'DBENG_NO_SERVER' and 'DBENG_FAILOVER'. Apr/2000,
Rick Smereka
Added translation of error code 'DBENG_BAD_IP'.
Jun/2001, Rick Smereka
Added translation of error code 'DBENG_NO_CATALOG_ENTRY'
and 'DBENG_CATALOG_ENTRY_EXISTS'. Nov/2001, Rick Smereka
Changed error code 'DBENG_NO_SUCH_VALUE' to 'DBENG_NO_SUCH_SUBFIELD',
'DBENG_NO_SUCH_SUBVALUE' to 'DBENG_NO_SUCH_SUBSUBFIELD'
'DBENG_FIELD_PUT_ERROR' to 'DBENG_PUT_ERROR' and
adjusted error message text. Dec/2001, Rick Smereka
Added translation of new error codes 'DBENG_RECORD_POSITION_CHANGED',
'DBENG_REPLICATION_NOT_ACTIVE' and 'DBENG_NO_REPLICATION_ENTRY'.
Jan/2002, Rick Smereka
Added translation of error code 'DBENG_TABLE_IN_USE'.
May/2002, Rick Smereka
Ported to Debian Linux. Nov/2002, Rick Smereka
Added text of error message 'DBENG_NO_INIT'. Jun/2003,
Rick Smereka
Added text of error message 'DBENG_NO_CATALOG'. Nov/2003,
Rick Smereka
Changed all logging calls from 'sys_log' to 'logman'.
Mar/2004, Rick Smereka */
#include "stdhead.h"
#include "dbmess.h"
#include "dbiocode.h"
/* high level API functions */
void db_io_code_string(const int io_stat, char *out_str)
{
/* High level entry for 'dbeng_io_code_string'. */
dbeng_io_code_string(io_stat, out_str);
}
void db_io_code_log(char *mname, char *desc, int io_code)
{
/* High level entry for 'dbeng_io_code_log'. */
dbeng_io_code_log(mname, desc, io_code);
}
void dbeng_io_code_string(const int io_stat, char *out_str)
{
/* Interpret 'io_stat' and return an explanation of the code
in English in the variable 'out_str' which must have already
been allocated to a sufficient size. */
if (out_str == NULL)
return;
switch(io_stat)
{
case DBENG_OK:
strcpy(out_str, "ok");
break;
case DBENG_EXISTS:
strcpy(out_str, "already exists");
break;
case DBENG_NOT_EXIST:
strcpy(out_str, "does not exist");
break;
case DBENG_RECORD_CHANGED:
strcpy(out_str, "record changed");
break;
case DBENG_NO_RECORD:
strcpy(out_str, "no current record");
break;
case DBENG_EOF:
strcpy(out_str, "end of file");
break;
case DBENG_NO_SUCH_FIELD:
strcpy(out_str, "no such field");
break;
case DBENG_INVALID_FILE_NAME:
strcpy(out_str, "invalid file name");
break;
case DBENG_UNABLE_TO_OPEN:
strcpy(out_str, "unable to open");
break;
case DBENG_WRITE_FAIL:
strcpy(out_str, "write fail, disk full?");
break;
case DBENG_NO_EXISTING_RECORD:
strcpy(out_str, "no existing record");
break;
case DBENG_CANNOT_CREATE_TABLE:
strcpy(out_str, "cannot create table");
break;
case DBENG_MAX_OPEN_TABLE:
strcpy(out_str, "already at max. open tables");
break;
case DBENG_NO_SUCH_FILE:
strcpy(out_str, "table does not exist");
break;
case DBENG_RECORD_TOO_LARGE:
strcpy(out_str, "record size too large");
break;
case DBENG_MEMORY_FAIL:
strcpy(out_str, "memory allocation failure");
break;
case DBENG_INVALID_FUNCTION:
strcpy(out_str, "invalid database function");
break;
case DBENG_VC_ERROR:
#ifdef IPC_TCP
strcpy(out_str, "socket communication error");
#endif
#ifdef IPC_QNX
strcpy(out_str, "virtual circuit communication error");
#endif
break;
case DBENG_ACCESS_DENIED:
strcpy(out_str, "access denied");
break;
case DBENG_FUNCTION_NOT_IMPLEMENTED:
strcpy(out_str, "function not yet implemented");
break;
case DBENG_PUT_ERROR:
strcpy(out_str, "error putting data into record");
break;
case DBENG_NO_SUCH_SUBFIELD:
strcpy(out_str, "no such subfield");
break;
case DBENG_NO_SUCH_SUBSUBFIELD:
strcpy(out_str, "no such subsubfield");
break;
case DBENG_FILENAME_TOO_LONG:
strcpy(out_str, "filename too long");
break;
case DBENG_NO_SUCH_TID:
strcpy(out_str, "unknown table ID (tid)");
break;
case DBENG_TABLE_LOCKED:
strcpy(out_str, "table is locked");
break;
case DBENG_RENAME_ERROR:
strcpy(out_str, "error renaming table");
break;
case DBENG_INTERNAL_ERROR:
strcpy(out_str, "unexpected internal error");
break;
case DBENG_FILE_DATA_ERROR:
strcpy(out_str, "error in file data format");
break;
case DBENG_CONFIG_INVALID_PARAMETER:
strcpy(out_str, "invalid config parameter");
break;
case DBENG_CONFIG_PARAMETER_MISSING:
strcpy(out_str, "config parameter missing");
break;
case DBENG_CONFIG_UNABLE_TO_OPEN:
strcpy(out_str, "unable to open config file");
break;
case DBENG_CONFIG_TMP_PATH_SIZE:
strcpy(out_str, "temp files path is too long");
break;
case DBENG_CONFIG_LOG_SIZE:
strcpy(out_str, "log name is too long");
break;
case DBENG_CONFIG_SESSION_TABLE_SIZE:
strcpy(out_str, "session table path/name is too long");
break;
case DBENG_CONFIG_INVALID_TMP_PATH:
strcpy(out_str, "temp files path is invalid");
break;
case DBENG_CONFIG_INVALID_LOG:
strcpy(out_str, "log name is invalid");
break;
case DBENG_CONFIG_INVALID_SESSION_TABLE:
strcpy(out_str, "session table path/name is invalid");
break;
case DBENG_CONFIG_INVALID_CATALOG:
strcpy(out_str, "catalog path/name is invalid");
break;
case DBENG_SOCLOC_NO_INIT:
strcpy(out_str, "socloc not initialized");
break;
case DBENG_NO_SERVER:
strcpy(out_str, "no Bbuuzzb server available");
break;
case DBENG_FAILOVER:
strcpy(out_str, "failover:new connection established");
break;
case DBENG_BAD_IP:
strcpy(out_str, "bad IP address");
break;
case DBENG_NO_CATALOG_ENTRY:
strcpy(out_str, "no catalog entry");
break;
case DBENG_CATALOG_ENTRY_EXISTS:
strcpy(out_str, "catalog entry already exists");
break;
case DBENG_RECORD_POSITION_CHANGED:
strcpy(out_str, "start rec pos changed[table packed?]");
break;
case DBENG_REPLICATION_NOT_ACTIVE:
strcpy(out_str, "table replication not active");
break;
case DBENG_NO_REPLICATION_ENTRY:
strcpy(out_str, "no table replication entry");
break;
case DBENG_TABLE_IN_USE:
strcpy(out_str, "table in use by other tid(s)");
break;
case DBENG_NO_INIT:
strcpy(out_str, "bbuuzzb API not initialized");
break;
case DBENG_NO_CATALOG:
strcpy(out_str, "no catalog present");
break;
default:
strcpy(out_str, "unknown error code");
break;
};
}
void dbeng_io_code_log(char *mname, char *desc, int io_code)
{
/* Send a message to the log manager (which must already be active).
The format of the message is:
mname:desc,rc=io_code(string)
Where 'mname' is the module name, 'desc' is a desciption of
the fault and 'io_code' is a valid 'DBENG' I/O error code.
Length of module name, description and io code string cannot
exceed (MAXMES - 1) bytes. */
char io_code_string[75];
char *tmp;
if ((tmp = (char *)malloc(MAXMES)) == (char *)NULL)
return;
dbeng_io_code_string(io_code, io_code_string);
sprintf(tmp, "%s:%s,rc=%s", mname, desc, io_code_string);
logman_nf(tmp);
free(tmp);
}