[build] clean libChf build, remove win32 from it too; refactor Makefiles

This commit is contained in:
Gwenhael Le Moine 2024-09-19 15:18:53 +02:00
parent fdcac7363a
commit 65cab00068
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
43 changed files with 205 additions and 1371 deletions

52
.gitignore vendored
View file

@ -1,33 +1,35 @@
libChf/mt_build/
libChf/st_build/
src/*.o src/*.o
dist/pack dist/pack
dist/saturn dist/saturn
dist/Saturn dist/Saturn
dist/pack dist/pack
dist/saturn dist/saturn
dist/saturn.cat dist/saturn.cat
dist/stateDir.*
dist/ROMs/*rom* dist/ROMs/*rom*
manual/saturn.toc
manual/saturn.aux docs/saturn.toc
manual/saturn.cp docs/saturn.aux
manual/saturn.cps docs/saturn.cp
manual/saturn.dvi docs/saturn.cps
manual/saturn.info docs/saturn.dvi
manual/saturn.pdf docs/saturn.info
manual/saturn.ps docs/saturn.pdf
manual/saturn.log docs/saturn.ps
libChf/chf.tps docs/saturn.log
libChf/chf.tp
libChf/chf.toc libChf/docs/chf.tps
libChf/chf.pdf libChf/docs/chf.tp
libChf/chf.log libChf/docs/chf.toc
libChf/chf.info libChf/docs/chf.pdf
libChf/chf.fns libChf/docs/chf.log
libChf/chf.fn libChf/docs/chf.info
libChf/chf.cps libChf/docs/chf.fns
libChf/chf.cp libChf/docs/chf.fn
libChf/chf.aux libChf/docs/chf.cps
libChf/chf.dvi libChf/docs/chf.cp
libChf/chf.ps libChf/docs/chf.aux
libChf/docs/chf.dvi
libChf/docs/chf.ps
libChf/libChf.a
libChf/src/*.o

View file

@ -11,8 +11,8 @@ DOCDIR = $(PREFIX)/doc/saturn
OPTIM ?= 2 OPTIM ?= 2
CFLAGS ?= -g -O$(OPTIM) -D_GNU_SOURCE=1 -I./src/ -I./libChf -L./libChf/mt_build CFLAGS ?= -O$(OPTIM) -D_GNU_SOURCE=1 -I./src/ -I./libChf/src/ -L./libChf
LIBS = -lm -lChf_r -lXm -lutil LIBS = -lm -lChf -lXm -lutil
X11CFLAGS = $(shell pkg-config --cflags x11 xext) X11CFLAGS = $(shell pkg-config --cflags x11 xext)
X11LIBS = $(shell pkg-config --libs x11 xext xt) X11LIBS = $(shell pkg-config --libs x11 xext xt)
@ -49,7 +49,7 @@ MSFS = src/MSFs/cpu.msf \
src/MSFs/util.msf \ src/MSFs/util.msf \
src/MSFs/x11.msf \ src/MSFs/x11.msf \
src/MSFs/x_func.msf \ src/MSFs/x_func.msf \
libChf/chf.msf libChf/src/chf.msf
MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES) MAKEFLAGS +=-j$(NUM_CORES) -l$(NUM_CORES)
@ -95,20 +95,16 @@ override CPPFLAGS := -I./src/ -D_GNU_SOURCE=1 \
.PHONY: all clean clean-all pretty-code install mrproper get-roms install .PHONY: all clean clean-all pretty-code install mrproper get-roms install
all: libChf/mt_build/libChf_r.a dist/saturn dist/saturn.cat manual all: libChf/libChf.a dist/saturn dist/saturn.cat docs
# Building # Building
libChf/mt_build/libChf_r.a: libChf/libChf.a:
make -C libChf ./mt_build/libChf_r.a CC=$(CC) make -C libChf
dist/saturn: $(DOTOS) libChf/mt_build/libChf_r.a dist/saturn: $(DOTOS) libChf/libChf.a
$(CC) $^ -o $@ $(CFLAGS) $(LIBS) $(X11LIBS) $(CC) $^ -o $@ $(CFLAGS) $(LIBS) $(X11LIBS)
libChf/st_build/libChf.a: dist/pack: src/pack.o src/disk_io.o src/debug.o libChf/libChf.a
# UNUSED
make -C libChf ./st_build/libChf.a CC=$(CC)
dist/pack: src/pack.o src/disk_io.o src/debug.o libChf/mt_build/libChf_r.a
# UNUSED # UNUSED
$(CC) $^ -o $@ $(CFLAGS) $(LIBS) $(CC) $^ -o $@ $(CFLAGS) $(LIBS)
@ -117,19 +113,20 @@ dist/saturn.cat: $(MSFS)
do gencat $@ $$msf ; \ do gencat $@ $$msf ; \
done done
manual: doc:
make -C manual make -C docs
# Cleaning # Cleaning
clean: clean:
rm -f src/*.o rm -f src/*.o
rm -f libChf/*_build/*.o make -C libChf clean
make -C docs clean
mrproper: clean mrproper: clean
rm -f dist/saturn dist/saturn.cat dist/pack rm -f dist/saturn dist/saturn.cat dist/pack
make -C dist/ROMs mrproper make -C dist/ROMs mrproper
make -C libChf clean make -C libChf mrproper
make -C manual clean make -C docs mrproper
clean-all: mrproper clean-all: mrproper
@ -142,7 +139,7 @@ get-roms:
make -C dist/ROMs get-roms make -C dist/ROMs get-roms
# Installation # Installation
install: dist/saturn dist/saturn.cat dist/Saturn.ad manual install: dist/saturn dist/saturn.cat dist/Saturn.ad doc
install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin
install -c -m 755 dist/saturn $(DESTDIR)$(PREFIX)/bin/saturn install -c -m 755 dist/saturn $(DESTDIR)$(PREFIX)/bin/saturn
install -c -m 755 dist/saturn48gx $(DESTDIR)$(PREFIX)/bin/saturn48gx install -c -m 755 dist/saturn48gx $(DESTDIR)$(PREFIX)/bin/saturn48gx
@ -162,7 +159,7 @@ install: dist/saturn dist/saturn.cat dist/Saturn.ad manual
install -c -m 644 dist/Saturn.ad $(DESTDIR)/etc/X11/app-defaults/Saturn install -c -m 644 dist/Saturn.ad $(DESTDIR)/etc/X11/app-defaults/Saturn
install -m 755 -d -- $(DESTDIR)$(DOCDIR) install -m 755 -d -- $(DESTDIR)$(DOCDIR)
cp -R COPYING LICENSE README* docs* manual/ $(DESTDIR)$(DOCDIR) cp -R COPYING LICENSE README* docs* docs/ $(DESTDIR)$(DOCDIR)
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/applications
sed "s|@PREFIX@|$(PREFIX)|g" dist/saturn48gx.desktop > $(DESTDIR)$(PREFIX)/share/applications/saturn48gx.desktop sed "s|@PREFIX@|$(PREFIX)|g" dist/saturn48gx.desktop > $(DESTDIR)$(PREFIX)/share/applications/saturn48gx.desktop

19
docs/Makefile Normal file
View file

@ -0,0 +1,19 @@
all: saturn.info saturn.dvi saturn.ps saturn.pdf
saturn.info: saturn.texi
makeinfo saturn.texi
saturn.dvi: saturn.texi
texi2dvi saturn.texi
saturn.ps: saturn.dvi
dvips -o saturn.ps saturn.dvi
saturn.pdf: saturn.dvi
dvips -o saturn.pdf saturn.dvi
clean:
rm -f saturn.aux saturn.cp saturn.cps saturn.fn saturn.fns saturn.log saturn.toc saturn.tp saturn.tps
mrproper: clean
rm -f saturn.info saturn.dvi saturn.ps saturn.pdf

View file

@ -1,209 +1,50 @@
# ICB, 2-Oct-2000
# Minor off-line changes to support stand-alone build in saturn
# #
# ICB, 16-Nov-2000 # Source files
# Off-line change: added default compile mode for unsupported platforms
# .+
# #
# .identifier : $Id: Makefile,v 2.1 2000/05/29 13:53:07 cibrario Rel $ SRC = src/chf_init.c \
# .context : CHF, Condition Handling Facility src/chf_gen.c \
# .title : $RCSfile: Makefile,v $, Makefile src/chf_sig.c \
# .kind : Makefile src/chf_abrt.c \
# .author : Ivan Cibrario B. src/chf_hdlr.c \
# .site : CSTV-CNR src/chf_msgc.c \
# .creation : 3-May-1996 src/chf_st.c \
# .keywords : * src/chf_top.c
# .description :
# Makefile for the CHF library
# .notes :
# $Log: Makefile,v $
# Revision 2.1 2000/05/29 13:53:07 cibrario
# - Deep revision to support transparent, multi-platform builds
# - Added multithreading support
# - New/revised targets: test, doc, clean
#
# Revision 1.2 1996/06/11 13:03:06 cibrario
# Added new module chf_top.c
#
# Revision 1.1 1996/05/29 09:12:10 cibrario
# Initial revision
#
#
# .-
# #
# Platform-dependent definitions. Edit when required, for example to # Target object files
# add a new platform.
# #
# There is a set of definitions per platform; the prefix or the definition OBJS = $(SRC:.c=.o)
# names is the value returned by a plain 'uname' on that platform.
#
# CC: cc compiler
# TS_CFLAGS: cc flags to enable multithreading
# TS_LOADLIBES: ld flags and additional libraries to enable multithreading
# F_CFLAGS: cc feature test macros
# O_CFLAGS: cc optimization control flags and other, additional flags
#
# Supported platforms:
# OSF1 Digital UNIX v4.0
# SunOS Solaris v2.6
# Linux Linux 2.1
#
# In addition, if the first build fails, a second attempt is made
# using the X_CC and X_CFLAGS fallback values.
OSF1_CC = cc
OSF1_TS_CFLAGS = -pthread
OSF1_TS_LOADLIBES = -pthread
OSF1_F_CFLAGS = "-D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE"
OSF1_O_CFLAGS = "-O3 -std1"
SunOS_CC = gcc
SunOS_TS_CFLAGS = -D_REENTRANT
SunOS_TS_LOADLIBES = -lpthread
SunOS_F_CFLAGS = -D_POSIX_C_SOURCE=199506L
SunOS_O_CFLAGS = "-O3 -ansi -pedantic"
Linux_CC = cc
Linux_TS_CFLAGS = -D_REENTRANT
Linux_TS_LOADLIBES = -lpthread
Linux_F_CFLAGS = -D_POSIX_C_SOURCE=199506L
Linux_O_CFLAGS = "-O3 -ansi -pedantic"
# #
# Destination paths for library objects, C headers, binaries, message catalog # Other definitions
# sources and X resource files. Edit as required.
# #
DESTLIBDIR = $(HOME)/lib OPTIM ?= 2
DESTHDRDIR = $(HOME)/include
DESTBINDIR = $(HOME)/bin
DESTMSFDIR = $(HOME)/msf
DESTRESDIR = $(HOME)/res
# CFLAGS ?= -O$(OPTIM) -ansi -pedantic -D_POSIX_C_SOURCE=199506L -I.
# The default target recursively invokes make defining UNAME to the ifeq ($(MT), yes)
# string returned by uname; this is used to make appropriate override CFLAGS := -D_REENTRANT $(CFLAGS)
# platform-dependent definitions above. endif
#
all:
@$(MAKE) UNAME=`uname` build || \
$(MAKE) UNAME=Unknown CC='"$(X_CC)"' O_CFLAGS='"$(X_CFLAGS)"' build
# LFLAGS ?= $(CFLAGS)
# Vectored definitions; see above and do not edit. LDFLAGS = -L.
#
CC = $($(UNAME)_CC)
TS_CFLAGS = $($(UNAME)_TS_CFLAGS)
TS_LOADLIBES = $($(UNAME)_TS_LOADLIBES)
F_CFLAGS = $($(UNAME)_F_CFLAGS)
O_CFLAGS = $($(UNAME)_O_CFLAGS)
#
# Include common definitions
#
include Makefile_def
#
# Build directories for single-threaded and multi-threaded lib versions
#
ST_BUILD_DIR = ./st_build
MT_BUILD_DIR = ./mt_build
# #
# Library names # Library names
# #
ST_LIB_NAME = libChf.a TARGET = libChf.a
MT_LIB_NAME = libChf_r.a
# all: $(TARGET)
# Library paths
#
ST_LIB_PATH = $(ST_BUILD_DIR)/$(ST_LIB_NAME)
MT_LIB_PATH = $(MT_BUILD_DIR)/$(MT_LIB_NAME)
#
# build: Create and populate build directories; for each build directory,
# make dependencies and rebuild
#
build: $(ST_LIB_PATH) $(MT_LIB_PATH)
#
# test: Build and executes test programs
#
test:
@$(MAKE) UNAME=`uname` do_test
@echo "All tests completed successfully"
do_test: $(ST_LIB_PATH) $(MT_LIB_PATH)
@cd $(ST_BUILD_DIR) && \
$(MAKE) test CC=$(CC) LIB=$(ST_LIB_NAME) \
F_CFLAGS=$(F_CFLAGS) O_CFLAGS=$(O_CFLAGS) > test.log 2>&1
@cd $(MT_BUILD_DIR) && \
$(MAKE) test CC=$(CC) LIB=$(MT_LIB_NAME) \
F_CFLAGS=$(F_CFLAGS) O_CFLAGS=$(O_CFLAGS) \
TS_CFLAGS=$(TS_CFLAGS) TS_LOADLIBES=$(TS_LOADLIBES) >> test.log 2>&1
#
# doc: Make documentation files
#
doc: doc:
makeinfo chf.texi make -C docs
texi2dvi chf.texi; dvips -o chf.ps chf.dvi
#
# clean: Remove build directories
#
clean: clean:
rm -rf $(ST_BUILD_DIR) $(MT_BUILD_DIR) rm -f $(OBJS)
make -C docs clean
# mrproper: clean
# install: Move all files to their directories rm -f $(TARGET)
# ICB, 23-Oct-2000: Do nothing make -C docs mrproper
#
install: $(ST_LIB_PATH) $(MT_LIB_PATH) $(HDR) $(MSF) $(RES)
# $(TARGET): $(OBJS)
# Prepare the build directories for use $(AR) $(ARFLAGS) $@ $?
#
# ICB, 16-Nov-2000
# Off-line change: Force the build to fail with exit 1 if CC is undefined
#
$(ST_BUILD_DIR) $(MT_BUILD_DIR):
@[ "$(CC)" = "" ] && \
{ echo "Warning: using X_ defaults"; exit 1; } ; \
mkdir $@ && \
cd $@ && \
ln -s ../Makefile_sub Makefile && \
for s in $(SRC) $(TSRC) $(HDR) $(MSF) $(TMSF) $(RES) ; do \
ln -s ../$$s $$s ; \
done
#
# Make the libraries; the rebuild is forced here because only the
# sub-makes have module dependencies.
#
# ICB, 16-Nov-2000
# Off-line change: Force the build to fail with exit 1 if CC is undefined
#
$(ST_LIB_PATH): $(ST_BUILD_DIR) force
@[ "$(CC)" = "" ] && \
{ echo "Warning: using X_ defaults"; exit 1; } ; \
cd $(ST_BUILD_DIR) && \
$(MAKE) depend CC=$(CC) LIB=$(ST_LIB_NAME) \
F_CFLAGS=$(F_CFLAGS) O_CFLAGS=$(O_CFLAGS) && \
$(MAKE) all CC=$(CC) LIB=$(ST_LIB_NAME) \
F_CFLAGS=$(F_CFLAGS) O_CFLAGS=$(O_CFLAGS)
$(MT_LIB_PATH): $(MT_BUILD_DIR) force
@[ "$(CC)" = "" ] && \
{ echo "Warning: using X_ defaults"; exit 1; } ; \
cd $(MT_BUILD_DIR) && \
$(MAKE) depend CC=$(CC) LIB=$(MT_LIB_NAME) \
F_CFLAGS=$(F_CFLAGS) O_CFLAGS=$(O_CFLAGS) \
TS_CFLAGS=$(TS_CFLAGS) TS_LOADLIBES=$(TS_LOADLIBES) && \
$(MAKE) all CC=$(CC) LIB=$(MT_LIB_NAME) \
F_CFLAGS=$(F_CFLAGS) O_CFLAGS=$(O_CFLAGS) \
TS_CFLAGS=$(TS_CFLAGS) TS_LOADLIBES=$(TS_LOADLIBES)
force:

View file

@ -1,68 +0,0 @@
# .+
#
# .identifier : $Id: Makefile_def,v 2.2 2001/01/25 11:59:19 cibrario Exp $
# .context : CHF, Condition Handling Facility
# .title : $RCSfile: Makefile_def,v $, Makefile
# .kind : Makefile
# .author : Ivan Cibrario B.
# .site : CSTV-CNR
# .creation : 22-May-2000
# .keywords : *
# .description :
# Makefile for CHF library common definitions; no platform dependencies here.
# .notes :
# $Log: Makefile_def,v $
# Revision 2.2 2001/01/25 11:59:19 cibrario
# Added partial Win32 support (Windows CE only).
#
# Revision 2.1 2000/05/29 13:08:39 cibrario
# *** empty log message ***
#
#
# .-
#
# Source files
#
SRC = chf_init.c chf_gen.c chf_sig.c chf_abrt.c chf_hdlr.c \
chf_msgc.c chf_st.c \
chf_top.c \
chf_win32.c
TSRC = test01.c test02.c test03.c test04.c test05.c test06.c \
test07.c
HDR = Chf.h ChfPriv.h
MSF = chf.msf
TMSF = test01.msf
RES =
#
# Target object files
#
OBJ = $(SRC:.c=.o)
#
# Target test programs
#
TBIN = $(TSRC:.c=)
#
# Other definitions
#
HPATH = -I.
LPATH = -L.
CFLAGS = $(F_CFLAGS) $(O_CFLAGS) $(TS_CFLAGS) $(U_CFLAGS) $(HPATH)
LFLAGS = $(F_CFLAGS) $(L_CFLAGS) $(TS_LFLAGS) $(U_CFLAGS) $(HPATH)
LDFLAGS = $(LPATH)
LOADLIBES = $(LIB) $(TS_LOADLIBES) $(I_LOADLIBES) $(U_LOADLIBES)
#
# Solaris spelling of LOADLIBES
#
LDLIBS = $(LOADLIBES)

View file

@ -1,40 +0,0 @@
# .+
#
# .identifier : $Id: Makefile_sub,v 2.1 2000/05/29 13:08:51 cibrario Rel $
# .context : CHF, Condition Handling Facility
# .title : $RCSfile: Makefile_sub,v $, Makefile
# .kind : Makefile
# .author : Ivan Cibrario B.
# .site : CSTV-CNR
# .creation : 22-May-2000
# .keywords : *
# .description :
# Makefile for CHF library subdirectories
# .notes :
# $Log: Makefile_sub,v $
# Revision 2.1 2000/05/29 13:08:51 cibrario
# *** empty log message ***
#
#
# .-
#
# Include common definitions
#
include ../Makefile_def
#
# Targets
#
all: $(LIB)
$(LIB): $(OBJ)
$(AR) $(ARFLAGS) $@ $?
test: $(TBIN)
@for b in $(TBIN) ; do \
./$$b ; \
done
depend: $(SRC)
@makedepend $(HPATH) $(SRC)

View file

@ -1,99 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
1002 "Chf"
END
STRINGTABLE DISCARDABLE
BEGIN
2001 "Condition stack is full"
2002 "Handler stack is full"
2003 "Handler stack is empty"
2004 "Wrong state for requested operation"
2005 "Invalid action code from handler (code=<%d>d)"
2006 "Dynamic memory allocation failed"
2007 "Function not available"
2010 "setlocale() failed"
2011 "catopen() failed"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Italian (Italy) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
#ifdef _WIN32
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // Italian (Italy) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -1,169 +0,0 @@
/* .+
.identifier : $Id: chf_win32.c,v 2.2 2001/01/25 14:11:58 cibrario Exp $
.context : CHF, Condition Handling Facility
.title : $RCSfile: chf_win32.c,v $, Win32 initialization function
.kind : C source
.author : Ivan Cibrario B.
.site : CSTV-CNR
.creation : 19-Jan-2001
.keywords : *
.description :
This module contains the CHF initialization function ChfWin32Init()
.include : Chf.h
.notes :
$Log: chf_win32.c,v $
Revision 2.2 2001/01/25 14:11:58 cibrario
*** empty log message ***
.- */
#ifndef lint
static char rcs_id[] = "$Id: chf_win32.c,v 2.2 2001/01/25 14:11:58 cibrario Exp $";
#endif
#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN32
# include <errno.h>
#endif
#include <setjmp.h>
#include <string.h>
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
#endif
#include "Chf.h"
#include "ChfPriv.h"
/* -------------------------------------------------------------------------
Global and static variables
------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------
Private type definitions
------------------------------------------------------------------------- */
#ifdef _WIN32
typedef struct {
HINSTANCE instance; /* App. instance handle */
ChfChar buffer[ CHF_MAX_MESSAGE_LENGTH ]; /* Temporary buffer */
} ChfWin32Context;
#endif
/* -------------------------------------------------------------------------
Private functions
------------------------------------------------------------------------- */
#ifdef _WIN32
static const ChfChar* Win32GetMessage( void* private_context, const int module_id, const int condition_code,
const ChfChar* default_message )
{
if ( !LoadString( ( ( ChfWin32Context* )private_context )->instance, module_id * 1000 + condition_code,
( ( ChfWin32Context* )private_context )->buffer, CHF_MAX_MESSAGE_LENGTH - 1 ) )
return default_message;
return ( ( ChfWin32Context* )private_context )->buffer;
}
static void ExitMessage( void* private_context ) { free( private_context ); }
#endif
/* -------------------------------------------------------------------------
Public functions
------------------------------------------------------------------------- */
/* .+
.title : ChfWin32Init
.kind : C function
.creation : 19-Jan-2001
.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 ChfWin32Init() 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 available in Win32 only; it will return
CHF_F_NOT_AVAILABLE on Unix platforma.
- message retrieval is done through the LoadString() Win32 function.
This function does not support message sets, so the linear message id
passed to it is made by module_id*1000 + condition_code. The following
limits are in effect:
0 <= condition_code <= 999
0 <= module_id <= 64
.call :
cc = ChfWin32Init(app_name, options,
msgcat_name,
condition_stack_size, handler_stack_size,
exit_code);
.input :
const ChfChar *app_name, Application's name
const ChfOptions options, Options
HINSTANCE instance, App. instance handle
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_MALLOC, FATAL, memory allocation failed
CHF_F_NOT_AVAILABLE, FATAL, function not available
.notes :
2.2, 19-Jan-2001, creation
.- */
int ChfWin32Init( /* Initialization within _WIN32 */
const ChfChar* app_name, /* Application's name */
const ChfOptions options, /* Options */
#ifndef _WIN32
void* instance, /* Fake arguments */
#else
HINSTANCE instance, /* App. instance handle */
#endif
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 */
)
{
#ifndef _WIN32
/* This function is available only in Win32 */
return CHF_F_NOT_AVAILABLE;
#else
ChfWin32Context* private_context;
int cc;
if ( ( private_context = ( ChfWin32Context* )malloc( sizeof( ChfWin32Context ) ) ) == ( ChfWin32Context* )NULL )
cc = CHF_F_MALLOC;
else if ( ( cc = ChfInit( app_name, options, ( void* )private_context, Win32GetMessage, ExitMessage, condition_stack_size,
handler_stack_size, exit_code ) ) != CHF_S_OK ) {
free( private_context );
}
else {
/* Save Win32 specific context items into private Chf context */
private_context->instance = instance;
cc = CHF_S_OK;
}
return cc;
#endif
}

19
libChf/docs/Makefile Normal file
View file

@ -0,0 +1,19 @@
all: chf.info chf.dvi chf.ps chf.pdf
chf.info: chf.texi
makeinfo chf.texi
chf.dvi: chf.texi
texi2dvi chf.texi
chf.ps: chf.dvi
dvips -o chf.ps chf.dvi
chf.pdf: chf.dvi
dvips -o chf.pdf chf.dvi
clean:
rm -f chf.aux chf.cp chf.cps chf.fn chf.fns chf.log chf.toc chf.tp chf.tps
mrproper: clean
rm -f chf.info chf.dvi chf.ps chf.pdf

View file

@ -1,485 +0,0 @@
# Microsoft eMbedded Visual Tools Project File - Name="libChf" - Package Owner=<4>
# Microsoft eMbedded Visual Tools Generated Build File, Format Version 6.02
# ** DO NOT EDIT **
# TARGTYPE "Win32 (WCE x86em) Static Library" 0x7f04
# TARGTYPE "Win32 (WCE ARM) Static Library" 0x8504
CFG=libChf - Win32 (WCE ARM) Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "libChf.vcn".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "libChf.vcn" CFG="libChf - Win32 (WCE ARM) Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "libChf - Win32 (WCE ARM) Release" (based on "Win32 (WCE ARM) Static Library")
!MESSAGE "libChf - Win32 (WCE ARM) Debug" (based on "Win32 (WCE ARM) Static Library")
!MESSAGE "libChf - Win32 (WCE x86em) Release" (based on "Win32 (WCE x86em) Static Library")
!MESSAGE "libChf - Win32 (WCE x86em) Debug" (based on "Win32 (WCE x86em) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
# PROP ATL_Project 2
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "ARMRel"
# PROP BASE Intermediate_Dir "ARMRel"
# PROP BASE CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}"
# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "ARMRel"
# PROP Intermediate_Dir "ARMRel"
# PROP CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}"
# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
# PROP Target_Dir ""
CPP=clarm.exe
# ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "NDEBUG" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_LIB" /YX /Oxs /M$(CECrtMT) /c
# ADD CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "NDEBUG" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_LIB" /YX /Oxs /M$(CECrtMT) /c
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "ARMDbg"
# PROP BASE Intermediate_Dir "ARMDbg"
# PROP BASE CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}"
# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "ARMDbg"
# PROP Intermediate_Dir "ARMDbg"
# PROP CPU_ID "{D6518FFC-710F-11D3-99F2-00105A0DF099}"
# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
# PROP Target_Dir ""
CPP=clarm.exe
# ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_LIB" /YX /M$(CECrtMTDebug) /c
# ADD CPP /nologo /W3 /Zi /Od /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_LIB" /YX /M$(CECrtMTDebug) /c
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "X86EMRel"
# PROP BASE Intermediate_Dir "X86EMRel"
# PROP BASE CPU_ID "{D6518FF4-710F-11D3-99F2-00105A0DF099}"
# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "X86EMRel"
# PROP Intermediate_Dir "X86EMRel"
# PROP CPU_ID "{D6518FF4-710F-11D3-99F2-00105A0DF099}"
# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "WIN32" /D "STRICT" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "$(CePlatform)" /D "i486" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /D "_LIB" /YX /Oxs /Gz /c
# ADD CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D "WIN32" /D "STRICT" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "$(CePlatform)" /D "i486" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "NDEBUG" /D "_LIB" /YX /Oxs /Gz /c
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "X86EMDbg"
# PROP BASE Intermediate_Dir "X86EMDbg"
# PROP BASE CPU_ID "{D6518FF4-710F-11D3-99F2-00105A0DF099}"
# PROP BASE Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "X86EMDbg"
# PROP Intermediate_Dir "X86EMDbg"
# PROP CPU_ID "{D6518FF4-710F-11D3-99F2-00105A0DF099}"
# PROP Platform_ID "{8A9A2F80-6887-11D3-842E-005004848CBA}"
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Zi /Od /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "WIN32" /D "STRICT" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "$(CePlatform)" /D "i486" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "_LIB" /YX /Gz /c
# ADD CPP /nologo /W3 /Zi /Od /D "DEBUG" /D _WIN32_WCE=$(CEVersion) /D "WIN32" /D "STRICT" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "$(CePlatform)" /D "i486" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "_X86_" /D "x86" /D "_LIB" /FR /YX /Gz /c
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
!ENDIF
# Begin Target
# Name "libChf - Win32 (WCE ARM) Release"
# Name "libChf - Win32 (WCE ARM) Debug"
# Name "libChf - Win32 (WCE x86em) Release"
# Name "libChf - Win32 (WCE x86em) Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\chf_abrt.c
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
DEP_CPP_CHF_A=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
DEP_CPP_CHF_A=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
DEP_CPP_CHF_A=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
DEP_CPP_CHF_A=\
".\Chf.h"\
".\ChfPriv.h"\
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\chf_gen.c
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
DEP_CPP_CHF_G=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
DEP_CPP_CHF_G=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
DEP_CPP_CHF_G=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
DEP_CPP_CHF_G=\
".\Chf.h"\
".\ChfPriv.h"\
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\chf_hdlr.c
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
DEP_CPP_CHF_H=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
DEP_CPP_CHF_H=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
DEP_CPP_CHF_H=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
DEP_CPP_CHF_H=\
".\Chf.h"\
".\ChfPriv.h"\
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\chf_init.c
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
DEP_CPP_CHF_I=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
DEP_CPP_CHF_I=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
DEP_CPP_CHF_I=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
DEP_CPP_CHF_I=\
".\Chf.h"\
".\ChfPriv.h"\
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\chf_msgc.c
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
DEP_CPP_CHF_M=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
DEP_CPP_CHF_M=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
DEP_CPP_CHF_M=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
DEP_CPP_CHF_M=\
".\Chf.h"\
".\ChfPriv.h"\
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\chf_sig.c
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
DEP_CPP_CHF_S=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
DEP_CPP_CHF_S=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
DEP_CPP_CHF_S=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
DEP_CPP_CHF_S=\
".\Chf.h"\
".\ChfPriv.h"\
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\chf_st.c
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
DEP_CPP_CHF_ST=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
DEP_CPP_CHF_ST=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
DEP_CPP_CHF_ST=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
DEP_CPP_CHF_ST=\
".\Chf.h"\
".\ChfPriv.h"\
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\chf_top.c
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
DEP_CPP_CHF_T=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
DEP_CPP_CHF_T=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
DEP_CPP_CHF_T=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
DEP_CPP_CHF_T=\
".\Chf.h"\
".\ChfPriv.h"\
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\chf_win32.c
!IF "$(CFG)" == "libChf - Win32 (WCE ARM) Release"
DEP_CPP_CHF_W=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE ARM) Debug"
DEP_CPP_CHF_W=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Release"
DEP_CPP_CHF_W=\
".\Chf.h"\
".\ChfPriv.h"\
!ELSEIF "$(CFG)" == "libChf - Win32 (WCE x86em) Debug"
DEP_CPP_CHF_W=\
".\Chf.h"\
".\ChfPriv.h"\
!ENDIF
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\Chf.h
# End Source File
# Begin Source File
SOURCE=.\ChfPriv.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "rc"
# Begin Source File
SOURCE=.\chf.rc
# End Source File
# End Group
# End Target
# End Project

View file

@ -55,19 +55,11 @@
Win32 & UNICODE support Win32 & UNICODE support
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#ifdef _WIN32 #define ChfChar char
# define ChfChar TCHAR #define ChfText( x ) x
# define ChfText( x ) _T( x ) #define ChfSigjmp_buf sigjmp_buf
# define ChfSigjmp_buf jmp_buf #define ChfSigsetjmp( x, y ) sigsetjmp( x, y )
# define ChfSigsetjmp( x, y ) setjmp( x ) #define ChfSiglongjmp( x, y ) siglongjmp( x, y )
# define ChfSiglongjmp( x, y ) longjmp( x, y )
#else
# define ChfChar char
# define ChfText( x ) x
# define ChfSigjmp_buf sigjmp_buf
# define ChfSigsetjmp( x, y ) sigsetjmp( x, y )
# define ChfSiglongjmp( x, y ) siglongjmp( x, y )
#endif
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
CHF implementation limits and other symbolic constants CHF implementation limits and other symbolic constants
@ -175,11 +167,7 @@ typedef /* Message retrieval 'exit' function */
CHF_MODULE_ID, \ CHF_MODULE_ID, \
ChfText(__FILE__), __LINE__, ChfText(__FILE__), __LINE__,
# ifdef _WIN32 # define ChfErrnoCondition ChfGenerate( CHF_ERRNO_SET, ChfText( __FILE__ ), __LINE__, errno, CHF_ERROR )
# define ChfErrnoCondition
# else
# define ChfErrnoCondition ChfGenerate( CHF_ERRNO_SET, ChfText( __FILE__ ), __LINE__, errno, CHF_ERROR )
# endif
#else #else
# define ChfCondition \ # define ChfCondition \
@ -187,11 +175,7 @@ typedef /* Message retrieval 'exit' function */
CHF_MODULE_ID, \ CHF_MODULE_ID, \
CHF_UNKNOWN_FILE_NAME, CHF_UNKNOWN_LINE_NUMBER, CHF_UNKNOWN_FILE_NAME, CHF_UNKNOWN_LINE_NUMBER,
# ifdef _WIN32 # define ChfErrnoCondition ChfGenerate( CHF_ERRNO_SET, CHF_UNKNOWN_FILE_NAME, CHF_UNKNOWN_LINE_NUMBER, errno, CHF_ERROR )
# define ChfErrnoCondition
# else
# define ChfErrnoCondition ChfGenerate( CHF_ERRNO_SET, CHF_UNKNOWN_FILE_NAME, CHF_UNKNOWN_LINE_NUMBER, errno, CHF_ERROR )
# endif
#endif #endif
@ -234,9 +218,8 @@ typedef /* Message retrieval 'exit' function */
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
Function prototypes Function prototypes
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
/* Generic initialization */
int ChfInit( /* Generic initialization */ int ChfInit( const ChfChar* app_name, /* Application's name */
const ChfChar* app_name, /* Application's name */
const ChfOptions options, /* Options */ const ChfOptions options, /* Options */
void* mrs_data, /* Message retrieval private data */ void* mrs_data, /* Message retrieval private data */
ChfMrsGet mrs_get, /* 'GetMessage' function */ ChfMrsGet mrs_get, /* 'GetMessage' function */
@ -245,18 +228,16 @@ int ChfInit( /* Generic initialization */
const int handler_stack_size, /* Size of the handler stack */ const int handler_stack_size, /* Size of the handler stack */
const int exit_code /* Abnormal exit code */ const int exit_code /* Abnormal exit code */
); );
/* Initialization with msgcat subsystem */
int ChfMsgcatInit( /* Initialization with msgcat subsystem */ int ChfMsgcatInit( const ChfChar* app_name, /* Application's name */
const ChfChar* app_name, /* Application's name */
const ChfOptions options, /* Options */ const ChfOptions options, /* Options */
const ChfChar* msgcat_name, /* Name of the message catalog */ const ChfChar* msgcat_name, /* Name of the message catalog */
const int condition_stack_size, /* Size of the condition stack */ const int condition_stack_size, /* Size of the condition stack */
const int handler_stack_size, /* Size of the handler stack */ const int handler_stack_size, /* Size of the handler stack */
const int exit_code /* Abnormal exit code */ const int exit_code /* Abnormal exit code */
); );
/* Initialization with static message tables */
int ChfStaticInit( /* Initialization with static message tables */ int ChfStaticInit( const ChfChar* app_name, /* Application's name */
const ChfChar* app_name, /* Application's name */
const ChfOptions options, /* Options */ const ChfOptions options, /* Options */
const ChfTable* table, /* Static message table */ const ChfTable* table, /* Static message table */
const size_t table_size, /* Size of the message table */ const size_t table_size, /* Size of the message table */
@ -264,50 +245,27 @@ int ChfStaticInit( /* Initialization with static
const int handler_stack_size, /* Size of the handler stack */ const int handler_stack_size, /* Size of the handler stack */
const int exit_code /* Abnormal exit code */ const int exit_code /* Abnormal exit code */
); );
/* Exit */
int ChfWin32Init( /* Initialization within _WIN32 */ void ChfExit( void );
const ChfChar* app_name, /* Application's name */ /* Abort application */
const ChfOptions options, /* Options */ void ChfAbort( const int abort_code );
#ifndef _WIN32 /* Push a new handler into the stack */
void* instance, /* Fake arguments */ void ChfPushHandler( ChfHandler new_handler, /* Handler to be added */
#else
HINSTANCE instance, /* App. instance handle */
#endif
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 */
);
void ChfExit( /* Exit */
void );
void ChfAbort( /* Abort application */
const int abort_code );
void ChfPushHandler( /* Push a new handler into the stack */
ChfHandler new_handler, /* Handler to be added */
void* unwind_context, /* Unwind context */ void* unwind_context, /* Unwind context */
ChfPointer handler_context /* Private handler context */ ChfPointer handler_context /* Private handler context */
); );
/* Pop a handler */
void ChfPopHandler( /* Pop a handler */ void ChfPopHandler( void );
void ); /* Build a condition message */
ChfChar* ChfBuildMessage( const ChfDescriptor* descriptor );
ChfChar* ChfBuildMessage( /* Build a condition message */ /* Signal the current conditions */
const ChfDescriptor* descriptor ); void ChfSignal( void );
/* Discard the current conditions */
void ChfSignal( /* Signal the current conditions */ void ChfDiscard( void );
void ); /* Generate a condition into the stack */
void ChfGenerate( const int module_id, const ChfChar* file_name, const int line_number, const int condition_code,
void ChfDiscard( /* Discard the current conditions */
void );
void ChfGenerate( /* Generate a condition into the stack */
const int module_id, const ChfChar* file_name, const int line_number, const int condition_code,
const ChfSeverity severity, ... ); const ChfSeverity severity, ... );
/* Retrieve a condition message */
const ChfChar* ChfGetMessage( /* Retrieve a condition message */ const ChfChar* ChfGetMessage( const int module_id, const int condition_code, const ChfChar* default_message );
const int module_id, const int condition_code, const ChfChar* default_message ); /* Retrieve top condition */
const ChfDescriptor* ChfGetTopCondition( void );
const ChfDescriptor* ChfGetTopCondition( /* Retrieve top condition */
void );

View file

@ -126,18 +126,9 @@ ChfContext* _ChfGetContext( void );
Private redirection of stdlib functions needed by Win32 Private redirection of stdlib functions needed by Win32
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#ifdef _WIN32 #define ChfStrlen strlen
# define ChfStrlen _tcslen #define ChfStrcpy strcpy
# define ChfStrcpy _tcscpy #define ChfStrcat strcat
# define ChfStrcat _tcscat #define ChfStrncpy strncpy
# define ChfStrncpy _tcsncpy #define ChfSprintf sprintf
# define ChfSprintf _stprintf #define ChfVsprintf vsprintf
# define ChfVsprintf _vstprintf
#else
# define ChfStrlen strlen
# define ChfStrcpy strcpy
# define ChfStrcat strcat
# define ChfStrncpy strncpy
# define ChfSprintf sprintf
# define ChfVsprintf vsprintf
#endif

View file

@ -36,16 +36,9 @@ static char rcs_id[] = "$Id: chf_abrt.c,v 2.2 2001/01/25 12:08:24 cibrario Exp $
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32 #include <errno.h>
# include <errno.h>
#endif
#include <setjmp.h> #include <setjmp.h>
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
#endif
#include "Chf.h" #include "Chf.h"
#include "ChfPriv.h" #include "ChfPriv.h"
@ -120,49 +113,10 @@ static const ChfChar* message_table[] = { ( const ChfChar* )NULL,
void ChfAbort( /* Abort application */ void ChfAbort( /* Abort application */
const int abort_code ) const int abort_code )
{ {
#ifdef _WIN32
if ( abort_code != CHF_ABORT_SILENT ) {
TCHAR abort_msg[ CHF_MAX_MESSAGE_LENGTH ];
HWND active_window;
/* stderr not available;
put complaint in a message box and display it
*/
if ( abort_code < 0 || abort_code >= MESSAGE_TABLE_SIZE )
_stprintf( abort_msg, CHF_ABORT_BAD_CODE_FMT, abort_code );
else
_stprintf( abort_msg, CHF_ABORT_GOOD_CODE_FMT, message_table[ abort_code ] );
/* Return value of MessageBox() ignored, because there is only
one available choice (abort) here. Avoid using a NULL handle.
*/
if ( chf_context.state != CHF_UNKNOWN && ( active_window = GetActiveWindow() ) != ( HWND )NULL )
( void )MessageBox( active_window, abort_msg, chf_context.app_name, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND );
}
/* Immediately exit the application with exit code EXIT_FAILURE
if CHF_ABORT option is set or if something is wrong with Chf state.
*/
if ( chf_context.state == CHF_UNKNOWN || chf_context.options & CHF_ABORT )
exit( EXIT_FAILURE );
else
/* Else, exit the application anyway, but with the exit code
registered by the application. Don't use PostQuitMessage(),
because the contract is that ChfAbort() never returns to the caller.
*/
# ifndef _REENTRANT
exit( chf_context.exit_code );
# else
# error "_REENTRANT not supported yet"
# endif
#else
if ( abort_code != CHF_ABORT_SILENT ) { if ( abort_code != CHF_ABORT_SILENT ) {
fputs( CHF_ABORT_HEADER, stderr ); fputs( CHF_ABORT_HEADER, stderr );
if ( abort_code < 0 || abort_code >= MESSAGE_TABLE_SIZE ) if ( abort_code < 0 || abort_code >= ( int )MESSAGE_TABLE_SIZE )
fprintf( stderr, CHF_ABORT_BAD_CODE_FMT, abort_code ); fprintf( stderr, CHF_ABORT_BAD_CODE_FMT, abort_code );
else else
@ -173,10 +127,9 @@ void ChfAbort( /* Abort application */
abort(); abort();
else else
# ifndef _REENTRANT #ifndef _REENTRANT
exit( chf_context.exit_code ); exit( chf_context.exit_code );
# else #else
pthread_exit( ( void* )( chf_context.exit_code ) ); pthread_exit( ( void* )( chf_context.exit_code ) );
# endif
#endif #endif
} }

View file

@ -30,18 +30,11 @@ static char rcs_id[] = "$Id: chf_gen.c,v 2.2 2001/01/25 12:10:22 cibrario Exp $"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32 #include <errno.h>
# include <errno.h>
#endif
#include <setjmp.h> #include <setjmp.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
#endif
#include "Chf.h" #include "Chf.h"
#include "ChfPriv.h" #include "ChfPriv.h"

View file

@ -43,16 +43,9 @@ static char rcs_id[] = "$Id: chf_hdlr.c,v 2.2 2001/01/25 12:12:46 cibrario Exp $
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32 #include <errno.h>
# include <errno.h>
#endif
#include <setjmp.h> #include <setjmp.h>
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
#endif
#include "Chf.h" #include "Chf.h"
#include "ChfPriv.h" #include "ChfPriv.h"

View file

@ -53,17 +53,10 @@ static char rcs_id[] = "$Id: chf_init.c,v 2.2 2001/01/25 14:05:23 cibrario Exp $
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32 #include <errno.h>
# include <errno.h>
#endif
#include <setjmp.h> #include <setjmp.h>
#include <string.h> #include <string.h>
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
#endif
#include "Chf.h" #include "Chf.h"
#include "ChfPriv.h" #include "ChfPriv.h"
@ -185,10 +178,8 @@ static ChfAction DefaultHandler( const ChfDescriptor* desc, const ChfState state
if ( pthread_mutex_lock( &fputs_mutex ) ) if ( pthread_mutex_lock( &fputs_mutex ) )
ChfAbort( CHF_ABORT_PTHREAD ); ChfAbort( CHF_ABORT_PTHREAD );
#endif #endif
#ifndef _WIN32
for ( d = desc; d != CHF_NULL_DESCRIPTOR; d = ChfGetNextDescriptor( d ) ) for ( d = desc; d != CHF_NULL_DESCRIPTOR; d = ChfGetNextDescriptor( d ) )
fputs( ChfBuildMessage( d ), stderr ); fputs( ChfBuildMessage( d ), stderr );
#endif
#ifdef _REENTRANT #ifdef _REENTRANT
if ( pthread_mutex_unlock( &fputs_mutex ) ) if ( pthread_mutex_unlock( &fputs_mutex ) )
ChfAbort( CHF_ABORT_PTHREAD ); ChfAbort( CHF_ABORT_PTHREAD );
@ -320,11 +311,7 @@ const ChfChar* ChfGetMessage( /* Retrieve a condition message */
if ( ( message = chf_context.mrs_get( chf_context.mrs_data, module_id, condition_code, default_message ) ) == default_message && if ( ( message = chf_context.mrs_get( chf_context.mrs_data, module_id, condition_code, default_message ) ) == default_message &&
module_id == CHF_ERRNO_SET ) module_id == CHF_ERRNO_SET )
#ifdef _WIN32
message = default_message;
#else
message = strerror( condition_code ); message = strerror( condition_code );
#endif
return ( message ); return ( message );
} }
@ -379,7 +366,6 @@ ChfChar* ChfBuildMessage( /* Build a condition message */
tmp_p = chf_context.message_buffer; tmp_p = chf_context.message_buffer;
tmp_end = tmp_p + CHF_MAX_MESSAGE_LENGTH; tmp_end = tmp_p + CHF_MAX_MESSAGE_LENGTH;
#ifndef _WIN32
/* The message starts with "<app_name>: " if the condition is the first of /* The message starts with "<app_name>: " if the condition is the first of
its condition group, with "\t" if not. its condition group, with "\t" if not.
*/ */
@ -390,7 +376,6 @@ ChfChar* ChfBuildMessage( /* Build a condition message */
else else
tmp_p = scopy( tmp_p, ChfText( "\t" ), tmp_end ); tmp_p = scopy( tmp_p, ChfText( "\t" ), tmp_end );
#endif
/* The message continues with the module name */ /* The message continues with the module name */
ChfSprintf( def_message, CHF_DEF_MID_MSG_FMT, ChfGetModuleId( descriptor ) ); ChfSprintf( def_message, CHF_DEF_MID_MSG_FMT, ChfGetModuleId( descriptor ) );
@ -408,7 +393,6 @@ ChfChar* ChfBuildMessage( /* Build a condition message */
tmp_p = scopy( tmp_p, separator, tmp_end ); tmp_p = scopy( tmp_p, separator, tmp_end );
#ifndef _WIN32
/* Add the severity code of the message */ /* Add the severity code of the message */
tmp_p = scopy( tmp_p, tmp_p = scopy( tmp_p,
( ( severity = ChfGetSeverity( descriptor ) ) < CHF_SUCCESS || severity > CHF_FATAL ) ? CHF_UNKNOWN_SEVERITY ( ( severity = ChfGetSeverity( descriptor ) ) < CHF_SUCCESS || severity > CHF_FATAL ) ? CHF_UNKNOWN_SEVERITY
@ -416,7 +400,6 @@ ChfChar* ChfBuildMessage( /* Build a condition message */
tmp_end ); tmp_end );
tmp_p = scopy( tmp_p, separator, tmp_end ); tmp_p = scopy( tmp_p, separator, tmp_end );
#endif
/* The message ends with the partial message from the descriptor */ /* The message ends with the partial message from the descriptor */
tmp_p = scopy( tmp_p, ChfGetPartialMessage( descriptor ), tmp_end ); tmp_p = scopy( tmp_p, ChfGetPartialMessage( descriptor ), tmp_end );

View file

@ -34,20 +34,11 @@ static char rcs_id[] = "$Id: chf_msgc.c,v 2.2 2001/01/25 14:06:47 cibrario Exp $
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32 #include <errno.h>
# include <errno.h>
#endif
#include <setjmp.h> #include <setjmp.h>
#include <string.h> #include <string.h>
#ifndef _WIN32 #include <locale.h>
# include <locale.h> #include <nl_types.h>
# include <nl_types.h>
#endif
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
#endif
#include "Chf.h" #include "Chf.h"
#include "ChfPriv.h" #include "ChfPriv.h"
@ -60,17 +51,14 @@ static char rcs_id[] = "$Id: chf_msgc.c,v 2.2 2001/01/25 14:06:47 cibrario Exp $
Private type definitions Private type definitions
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#ifndef _WIN32
typedef struct { typedef struct {
nl_catd catalog; /* Message catalog descriptor */ nl_catd catalog; /* Message catalog descriptor */
} ChfMsgcatContext; } ChfMsgcatContext;
#endif
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
Private functions Private functions
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#ifndef _WIN32
static const char* GetMessage( void* private_context, const int module_id, const int condition_code, const char* default_message ) 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 ) ); return ( catgets( ( ( ChfMsgcatContext* )private_context )->catalog, module_id, condition_code, default_message ) );
@ -81,7 +69,6 @@ static void ExitMessage( void* private_context )
( void )catclose( ( ( ChfMsgcatContext* )private_context )->catalog ); ( void )catclose( ( ( ChfMsgcatContext* )private_context )->catalog );
free( private_context ); free( private_context );
} }
#endif
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
Public functions Public functions
@ -142,39 +129,23 @@ int ChfMsgcatInit( /* Initialization with msgcat
const int exit_code /* Abnormal exit code */ 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; ChfMsgcatContext* private_context;
int cc; int cc;
if ( ( private_context = ( ChfMsgcatContext* )malloc( sizeof( ChfMsgcatContext ) ) ) == ( ChfMsgcatContext* )NULL ) if ( ( private_context = ( ChfMsgcatContext* )malloc( sizeof( ChfMsgcatContext ) ) ) == ( ChfMsgcatContext* )NULL )
cc = CHF_F_MALLOC; cc = CHF_F_MALLOC;
else if ( setlocale( LC_ALL, "" ) == ( char* )NULL ) { else if ( setlocale( LC_ALL, "" ) == ( char* )NULL ) {
free( private_context ); free( private_context );
cc = CHF_F_SETLOCALE; cc = CHF_F_SETLOCALE;
} } else if ( ( private_context->catalog = catopen( msgcat_name, 0 ) ) == ( nl_catd )( -1 ) ) {
else if ( ( private_context->catalog = catopen( msgcat_name, 0 ) ) == ( nl_catd )( -1 ) ) {
free( private_context ); free( private_context );
cc = CHF_F_CATOPEN; cc = CHF_F_CATOPEN;
} } else if ( ( cc = ChfInit( app_name, options, ( void* )private_context, GetMessage, ExitMessage, condition_stack_size,
else if ( ( cc = ChfInit( app_name, options, ( void* )private_context, GetMessage, ExitMessage, condition_stack_size,
handler_stack_size, exit_code ) ) != CHF_S_OK ) { handler_stack_size, exit_code ) ) != CHF_S_OK ) {
( void )catclose( private_context->catalog ); ( void )catclose( private_context->catalog );
free( private_context ); free( private_context );
} } else
else
cc = CHF_S_OK; cc = CHF_S_OK;
return cc; return cc;
#endif
} }

View file

@ -43,16 +43,9 @@ static char rcs_id[] = "$Id: chf_sig.c,v 2.2 2001/01/25 14:07:42 cibrario Exp $"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32 #include <errno.h>
# include <errno.h>
#endif
#include <setjmp.h> #include <setjmp.h>
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
#endif
#include "Chf.h" #include "Chf.h"
#include "ChfPriv.h" #include "ChfPriv.h"

View file

@ -30,17 +30,10 @@ static char rcs_id[] = "$Id: chf_st.c,v 2.2 2001/01/25 14:08:45 cibrario Exp $";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32 #include <errno.h>
# include <errno.h>
#endif
#include <setjmp.h> #include <setjmp.h>
#include <string.h> #include <string.h>
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
#endif
#include "Chf.h" #include "Chf.h"
#include "ChfPriv.h" #include "ChfPriv.h"
@ -61,34 +54,6 @@ typedef struct {
Private functions Private functions
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#ifdef _WIN32
/* Win32 does not have bsearch();
provide a simple one from glibc here.
*/
static void* bsearch( const void* key, const void* base, size_t nmemb, size_t size, int ( *compar )( const void*, const void* ) )
{
size_t l, u, idx;
const void* p;
int comparison;
l = 0;
u = nmemb;
while ( l < u ) {
idx = ( l + u ) / 2;
p = ( void* )( ( ( const char* )base ) + ( idx * size ) );
comparison = ( *compar )( key, p );
if ( comparison < 0 )
u = idx;
else if ( comparison > 0 )
l = idx + 1;
else
return ( void* )p;
}
return NULL;
}
#endif
#define GT 1 #define GT 1
#define LT -1 #define LT -1
#define EQ 0 #define EQ 0
@ -183,11 +148,9 @@ int ChfStaticInit( /* Initialization with static
if ( ( private_context = ( ChfStaticContext* )malloc( sizeof( ChfStaticContext ) ) ) == ( ChfStaticContext* )NULL ) if ( ( private_context = ( ChfStaticContext* )malloc( sizeof( ChfStaticContext ) ) ) == ( ChfStaticContext* )NULL )
cc = CHF_F_MALLOC; cc = CHF_F_MALLOC;
else if ( ( cc = ChfInit( app_name, options, ( void* )private_context, StGetMessage, ExitMessage, condition_stack_size, else if ( ( cc = ChfInit( app_name, options, ( void* )private_context, StGetMessage, ExitMessage, condition_stack_size,
handler_stack_size, exit_code ) ) != CHF_S_OK ) handler_stack_size, exit_code ) ) != CHF_S_OK )
free( private_context ); free( private_context );
else { else {
private_context->table = table; private_context->table = table;
private_context->size = table_size; private_context->size = table_size;

View file

@ -34,17 +34,10 @@ static char rcs_id[] = "$Id: chf_top.c,v 2.2 2001/01/25 14:09:21 cibrario Exp $"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32 #include <errno.h>
# include <errno.h>
#endif
#include <setjmp.h> #include <setjmp.h>
#include <string.h> #include <string.h>
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
#endif
#include "Chf.h" #include "Chf.h"
#include "ChfPriv.h" #include "ChfPriv.h"

40
libChf/tests/chf.msf Normal file
View file

@ -0,0 +1,40 @@
$ .+
$ .
$ .identifier : $Id: chf.msf,v 2.2 2001/01/25 12:00:19 cibrario Exp $
$ .context :
$ .title : $RCSfile: chf.msf,v $
$ .kind : Makefile
$ .author : Ivan Cibrario B.
$ .site : CSTV-CNR
$ .creation : 27-May-1996
$ .keywords : *
$ .description :
$ . Message source file for the CHF conditions
$ .notes :
$ . $Log: chf.msf,v $
$ . Revision 2.2 2001/01/25 12:00:19 cibrario
$ . Added partial Win32 support (Windows CE only).
$ .
$ . Revision 2.1 2000/05/26 14:17:21 cibrario
$ . Updated documentation block and RCS log message header to prevent
$ . gencat warnings on Linux boxes
$ .
$ . Revision 1.1 1996/05/28 12:57:06 cibrario
$ . Initial revision
$ .
$ .-
$set 1
2 Chf
3 Errno
$set 2
1 Condition stack is full
2 Handler stack is full
3 Handler stack is empty
4 Wrong Chf state for requested operation
5 Invalid action code from handler (code=<%d>d)
6 Dynamic memory allocation failed
7 Function not implemented
10 setlocale() failed
11 catopen() failed

View file

@ -1,14 +0,0 @@
#
# TexInfo Documentation
#
MAKEINFO= makeinfo
TEXI2DVI= texi2dvi
DVIPS= dvips
doc:
$(MAKEINFO) saturn.texi
$(TEXI2DVI) saturn.texi && $(DVIPS) -o saturn.ps saturn.dvi
@echo "*** Install saturn.info manually, please"
clean:
rm -f saturn.aux saturn.cp saturn.cps saturn.dvi saturn.info saturn.log saturn.ps saturn.toc