292 lines
6.2 KiB
Text
292 lines
6.2 KiB
Text
head 2.2;
|
|
access;
|
|
symbols
|
|
V4_1_1_1:2.2
|
|
Rel_2_1:1.3;
|
|
locks; strict;
|
|
comment @ @;
|
|
|
|
|
|
2.2
|
|
date 2001.01.25.14.06.47; author cibrario; state Exp;
|
|
branches;
|
|
next 1.3;
|
|
|
|
1.3
|
|
date 96.06.21.14.19.22; author cibrario; state Rel;
|
|
branches;
|
|
next 1.1;
|
|
|
|
1.1
|
|
date 96.05.28.12.55.15; author cibrario; state Exp;
|
|
branches;
|
|
next ;
|
|
|
|
|
|
desc
|
|
@This module contains the CHF initialization function ChfMsgcatInit()
|
|
@
|
|
|
|
|
|
2.2
|
|
log
|
|
@Added partial Win32 support (Windows CE only).
|
|
@
|
|
text
|
|
@/* .+
|
|
|
|
.identifier : $Id: chf_msgc.c,v 1.3 1996/06/21 14:19:22 cibrario Rel cibrario $
|
|
.context : CHF, Condition Handling Facility
|
|
.title : $RCSfile: chf_msgc.c,v $, condition generation
|
|
.kind : C source
|
|
.author : Ivan Cibrario B.
|
|
.site : CSTV-CNR
|
|
.creation : 17-May-1996
|
|
.keywords : *
|
|
.description :
|
|
This module contains the CHF initialization function ChfMsgcatInit()
|
|
|
|
.include : Chf.h
|
|
|
|
.notes :
|
|
$Log: chf_msgc.c,v $
|
|
Revision 1.3 1996/06/21 14:19:22 cibrario
|
|
Bug fix: the private context of the message retrieval facility was
|
|
never freed by ExitMessage()
|
|
|
|
Revision 1.1 1996/05/28 12:55:15 cibrario
|
|
Initial revision
|
|
|
|
|
|
.- */
|
|
|
|
#ifndef lint
|
|
static char rcs_id[] = "$Id: chf_msgc.c,v 1.3 1996/06/21 14:19:22 cibrario Rel cibrario $";
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#ifndef _WIN32
|
|
#include <errno.h>
|
|
#endif
|
|
#include <setjmp.h>
|
|
#include <string.h>
|
|
#ifndef _WIN32
|
|
#include <locale.h>
|
|
#include <nl_types.h>
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#include <tchar.h>
|
|
#endif
|
|
|
|
#include "Chf.h"
|
|
#include "ChfPriv.h"
|
|
|
|
|
|
/* -------------------------------------------------------------------------
|
|
Global and static variables
|
|
------------------------------------------------------------------------- */
|
|
|
|
/* -------------------------------------------------------------------------
|
|
Private type definitions
|
|
------------------------------------------------------------------------- */
|
|
|
|
#ifndef _WIN32
|
|
typedef struct
|
|
{
|
|
nl_catd catalog; /* Message catalog descriptor */
|
|
}
|
|
ChfMsgcatContext;
|
|
#endif
|
|
|
|
|
|
/* -------------------------------------------------------------------------
|
|
Private functions
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
#ifndef _WIN32
|
|
static const char *GetMessage(
|
|
void *private_context,
|
|
const int module_id,
|
|
const int condition_code,
|
|
const char *default_message
|
|
)
|
|
{
|
|
return(catgets(((ChfMsgcatContext *)private_context)->catalog, module_id,
|
|
condition_code, default_message));
|
|
}
|
|
|
|
static void ExitMessage(
|
|
void *private_context
|
|
)
|
|
{
|
|
(void)catclose(((ChfMsgcatContext *)private_context)->catalog);
|
|
free(private_context);
|
|
}
|
|
#endif
|
|
|
|
|
|
/* -------------------------------------------------------------------------
|
|
Public functions
|
|
------------------------------------------------------------------------- */
|
|
|
|
/* .+
|
|
|
|
.title : ChfMsgcatInit
|
|
.kind : C function
|
|
.creation : 17-May-1996
|
|
.description :
|
|
This function initializes CHF and returns to the caller a condition code;
|
|
that code will be either CHF_S_OK if the initialization was succesful,
|
|
or one of the other values listed below.
|
|
|
|
It's necessary to invoke succesfully either ChfMsgcatInit() or one of the
|
|
other CHF initialization routines before using any other CHF function.
|
|
|
|
NOTE: This function will call ChfAbort() with abort code CHF_ABORT_DUP_INIT
|
|
if CHF has already been initialized before.
|
|
|
|
WIN32:
|
|
|
|
- this function is not available due to lack of system support, and
|
|
always returns CHF_F_NOT_AVAILABLE
|
|
|
|
.call :
|
|
cc = ChfMsgcatInit(app_name, options,
|
|
msgcat_name,
|
|
condition_stack_size, handler_stack_size,
|
|
exit_code);
|
|
.input :
|
|
const char *app_name, Application's name
|
|
const ChfOptions options, Options
|
|
const char *msgcat_name, Name of the message catalog
|
|
const int condition_stack_size, Size of the condition stack
|
|
const int handler_stack_size, Size of the handler stack
|
|
const int exit_code, Abnormal exit code
|
|
.output :
|
|
int cc, condition code
|
|
.status_codes :
|
|
CHF_F_SETLOCALE, setlocale() failed
|
|
CHF_F_CATOPEN, catopen() failed
|
|
CHF_F_MALLOC, FATAL, memory allocation failed
|
|
CHF_F_NOT_AVAILABLE, FATAL, function not available
|
|
.notes :
|
|
1.1, 17-May-1996, creation
|
|
2.2, 22-Jan-2001, update:
|
|
- added Win32 support
|
|
|
|
.- */
|
|
int ChfMsgcatInit( /* Initialization with msgcat subsystem */
|
|
const ChfChar *app_name, /* Application's name */
|
|
const ChfOptions options, /* Options */
|
|
const ChfChar *msgcat_name, /* Name of the message catalog */
|
|
const int condition_stack_size, /* Size of the condition stack */
|
|
const int handler_stack_size, /* Size of the handler stack */
|
|
const int exit_code /* Abnormal exit code */
|
|
)
|
|
{
|
|
#ifdef _WIN32
|
|
/* This function always fails in _WIN32, because message catalogs
|
|
are not supported.
|
|
*/
|
|
return CHF_F_NOT_AVAILABLE;
|
|
|
|
#else
|
|
ChfMsgcatContext *private_context;
|
|
int cc;
|
|
|
|
if((private_context =
|
|
(ChfMsgcatContext *)malloc(sizeof(ChfMsgcatContext))) ==
|
|
(ChfMsgcatContext *)NULL)
|
|
cc = CHF_F_MALLOC;
|
|
|
|
else if(setlocale(LC_ALL, "") == (char *)NULL)
|
|
{
|
|
free(private_context);
|
|
cc = CHF_F_SETLOCALE;
|
|
}
|
|
|
|
else if((private_context->catalog = catopen(msgcat_name, 0)) ==
|
|
(nl_catd)(-1))
|
|
{
|
|
free(private_context);
|
|
cc = CHF_F_CATOPEN;
|
|
}
|
|
|
|
else if((cc = ChfInit(app_name, options, (void *)private_context,
|
|
GetMessage, ExitMessage, condition_stack_size, handler_stack_size,
|
|
exit_code)) != CHF_S_OK)
|
|
{
|
|
(void)catclose(private_context->catalog);
|
|
free(private_context);
|
|
}
|
|
|
|
else
|
|
cc = CHF_S_OK;
|
|
|
|
return cc;
|
|
|
|
#endif
|
|
}
|
|
@
|
|
|
|
|
|
1.3
|
|
log
|
|
@Bug fix: the private context of the message retrieval facility was
|
|
never freed by ExitMessage()
|
|
@
|
|
text
|
|
@d3 1
|
|
a3 1
|
|
.identifier : $Id: chf_msgc.c,v 1.1 1996/05/28 12:55:15 cibrario Exp cibrario $
|
|
d18 4
|
|
d29 1
|
|
a29 1
|
|
static char rcs_id[] = "$Id: chf_msgc.c,v 1.1 1996/05/28 12:55:15 cibrario Exp cibrario $";
|
|
d34 1
|
|
d36 1
|
|
d39 1
|
|
d42 1
|
|
d44 5
|
|
d61 1
|
|
d67 1
|
|
d75 1
|
|
d94 1
|
|
d117 5
|
|
d140 1
|
|
d143 2
|
|
d148 1
|
|
a148 1
|
|
const char *app_name, /* Application's name */
|
|
d150 1
|
|
a150 1
|
|
const char *msgcat_name, /* Name of the message catalog */
|
|
d156 7
|
|
d196 2
|
|
@
|
|
|
|
|
|
1.1
|
|
log
|
|
@Initial revision
|
|
@
|
|
text
|
|
@d3 1
|
|
a3 1
|
|
.identifier : $Id$
|
|
d5 1
|
|
a5 1
|
|
.title : $RCSfile$, condition generation
|
|
d17 3
|
|
a19 1
|
|
$Log$
|
|
d21 1
|
|
d25 1
|
|
a25 1
|
|
static char rcs_id[] = "$Id$";
|
|
d76 1
|
|
@
|