Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
55
cde/programs/dtappbuilder/src/libAButil/AB.h
Normal file
55
cde/programs/dtappbuilder/src/libAButil/AB.h
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: AB.h /main/4 1995/11/06 18:48:43 rswiston $
|
||||
*
|
||||
* @(#)AB.h 1.1 11 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ABUTIL_AB_H_
|
||||
#define _ABUTIL_AB_H_
|
||||
/*
|
||||
* <ab_private/AB.h>
|
||||
*
|
||||
* This file should be included by ALL app builder source files!
|
||||
* And it should be included before any other ab include files
|
||||
* ( <ab_private/x.h>, <ab/x.h>, "x.h" ).
|
||||
*
|
||||
* It sets DEBUG parameters, and affects the entire product
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Turn on POSIX compliance. This mostly affect system header files.
|
||||
*/
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Set the DEBUG compile-time parameter to be exactly the opposite of
|
||||
* NDEBUG
|
||||
*/
|
||||
#ifndef NDEBUG
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
#else
|
||||
#undef DEBUG
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _ABUTIL_AB_H_ */
|
||||
95
cde/programs/dtappbuilder/src/libAButil/Imakefile
Normal file
95
cde/programs/dtappbuilder/src/libAButil/Imakefile
Normal file
@@ -0,0 +1,95 @@
|
||||
XCOMM $XConsortium: Imakefile /main/10 1996/10/09 14:03:49 drk $
|
||||
#define DoNormalLib YES
|
||||
#define DoSharedLib NO
|
||||
#define DoDebugLib NO
|
||||
#define DoProfileLib NO
|
||||
#define LibName AButil
|
||||
#define LibHeaders NO
|
||||
#define LibInstall NO
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
|
||||
#include "../ab.tmpl"
|
||||
#include "../ab.rules"
|
||||
|
||||
INCLUDES = -I. -I$(ABINCLUDES)
|
||||
|
||||
LINTLIBS = $(LINTXLIB) $(LINTXTOOL)
|
||||
|
||||
SOURCES.h.shipped = \
|
||||
util_types.h
|
||||
|
||||
SOURCES.h.shared = \
|
||||
AB.h \
|
||||
abio.h \
|
||||
istr.h \
|
||||
strlist.h \
|
||||
util.h \
|
||||
util_ds.h \
|
||||
util_err.h \
|
||||
XmAll.h \
|
||||
MwmUtil.h \
|
||||
UilDef.h
|
||||
|
||||
SOURCES.h.unshared = \
|
||||
utilP.h
|
||||
|
||||
SRCS = \
|
||||
abio.c \
|
||||
abio_path.c \
|
||||
istr.c \
|
||||
strlist.c \
|
||||
util.c \
|
||||
util_convert.c \
|
||||
util_ds.c \
|
||||
util_err.c \
|
||||
util_file.c \
|
||||
util_string.c
|
||||
|
||||
OBJS = \
|
||||
abio.o \
|
||||
abio_path.o \
|
||||
istr.o \
|
||||
strlist.o \
|
||||
util.o \
|
||||
util_convert.o \
|
||||
util_ds.o \
|
||||
util_err.o \
|
||||
util_file.o \
|
||||
util_string.o
|
||||
|
||||
SYS_LIBRARIES = -lm $(ICONVSYSLIB) $(DYNLIBSYSLIB) $(REGEXSYSLIB)
|
||||
|
||||
#ifdef SunArchitecture
|
||||
WAITTARGET = .WAIT
|
||||
#endif /* SunArchitecture */
|
||||
|
||||
LINTLIBS = $(XINPUTLIB) $(DTHELPLIB) $(DTSVCLIB) $(XMLIB) $(XTOOLLIB) $(XLIB)
|
||||
LOCAL_LIBRARIES = $(XINPUTLIB) $(DTHELPLIB) $(DTSVCLIB) $(XMLIB) $(XTOOLLIB) $(XLIB)
|
||||
|
||||
#include <Library.tmpl>
|
||||
|
||||
PROGRAMS = util_test istr_test
|
||||
|
||||
SRCS2 = util_test.c
|
||||
OBJS2 = util_test.o
|
||||
DEPLIBS2 = libAButil.a
|
||||
ComplexProgramTarget_2(util_test,$(DEPLIBS2),$(SYS_LIBRARIES))
|
||||
|
||||
SRCS3 = istr_test.c
|
||||
OBJS3 = istr_test.o
|
||||
DEPLIBS2 = libAButil.a
|
||||
ComplexProgramTarget_3(istr_test,$(DEPLIBS3),$(SYS_LIBRARIES))
|
||||
|
||||
DependTarget3($(SRCS),$(SRCS2),$(SRCS3))
|
||||
|
||||
clean::
|
||||
RemoveFiles($(PROGRAMS))
|
||||
|
||||
LinkFileList(shipped_includes,$(SOURCES.h.shipped),../include/ab,../../libAButil)
|
||||
LinkFileList(shared_includes,$(SOURCES.h.shared),../include/ab_private,../../libAButil)
|
||||
|
||||
includes:: shipped_includes shared_includes $(WAITTARGET)
|
||||
sdtgilcvt: libAButil.a
|
||||
dtcodegen: libAButil.a
|
||||
89
cde/programs/dtappbuilder/src/libAButil/Makefile.install
Normal file
89
cde/programs/dtappbuilder/src/libAButil/Makefile.install
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
#
|
||||
# $XConsortium: Makefile.install /main/3 1995/11/06 18:49:08 rswiston $
|
||||
#
|
||||
# %W% %G% cde_app_builder/src/libAButil
|
||||
#
|
||||
# RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
#
|
||||
# The information in this document is subject to special
|
||||
# restrictions in a confidential disclosure agreement between
|
||||
# HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
# document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
# Sun's specific written approval. This document and all copies
|
||||
# and derivative works thereof must be returned or destroyed at
|
||||
# Sun's request.
|
||||
#
|
||||
# Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
#
|
||||
#
|
||||
|
||||
SOURCES.c = \
|
||||
guide.c \
|
||||
gio.c \
|
||||
gio_path.c \
|
||||
guide_actions.c
|
||||
|
||||
SOURCES.h = \
|
||||
guide.h \
|
||||
gio.h \
|
||||
guide_actions.h
|
||||
|
||||
SOURCES = \
|
||||
$(SOURCES.G) \
|
||||
$(SOURCES.h) \
|
||||
$(SOURCES.c)
|
||||
|
||||
TARGETS.c = \
|
||||
$(SOURCES.G:%.G=%_ui.c) \
|
||||
$(STUBS.G:%.G=%_stubs.c)
|
||||
|
||||
TARGETS.h = \
|
||||
$(SOURCES.G:%.G=%_ui.h) \
|
||||
$(SOURCES.l:%.l=%.h) \
|
||||
$(SOURCES.y:%.y=%.h)
|
||||
|
||||
TARGETS = \
|
||||
$(TARGETS.h) \
|
||||
$(TARGETS.c)
|
||||
|
||||
OBJECTS = \
|
||||
$(SOURCES.c:%.c=%.o) \
|
||||
$(TARGETS.c:%.c=%.o)
|
||||
|
||||
LIBRARY = libguide.a
|
||||
|
||||
PROJECTDIR = $(GUIDEHOME)
|
||||
DESTDIR = $(PROJECTDIR)
|
||||
|
||||
# Compiler flags.
|
||||
|
||||
CPPFLAGS += -I$(PROJECTDIR)/src/libguide -I$(OPENWINHOME)/include
|
||||
|
||||
# Make information.
|
||||
|
||||
.KEEP_STATE:
|
||||
.PRECIOUS: $(LIBRARY)
|
||||
|
||||
# Standard targets.
|
||||
|
||||
all: $(SOURCES) $(TARGETS) $(LIBRARY) $(PROGRAM)
|
||||
objects: $(SOURCES.c) $(TARGETS.c) $(TARGETS.h) $(OBJECTS)
|
||||
sources: $(SOURCES)
|
||||
targets: $(SOURCES) $(TARGETS)
|
||||
|
||||
$(LIBRARY): $(LIBRARY)($(OBJECTS))
|
||||
ar rv $@ $?
|
||||
rm -f $?
|
||||
|
||||
$(LIBRARY)(%.o): %.c
|
||||
$(COMPILE.c) $< $(OUTPUT_OPTION)
|
||||
|
||||
install: all
|
||||
@-sccs check
|
||||
/usr/ucb/install -d $(DESTDIR)/lib
|
||||
/usr/ucb/install -m 664 $(LIBRARY) $(DESTDIR)/lib
|
||||
(cd $(DESTDIR)/lib ; chmod 444 $(LIBRARY))
|
||||
|
||||
clean:
|
||||
$(RM) $(TARGETS) $(OBJECTS) $(SOURCES.G:%.G=%_stubs.c) core
|
||||
40
cde/programs/dtappbuilder/src/libAButil/MwmUtil.h
Normal file
40
cde/programs/dtappbuilder/src/libAButil/MwmUtil.h
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: MwmUtil.h /main/4 1995/11/06 18:49:29 rswiston $
|
||||
*
|
||||
* @(#)MwmUtil.h 1.4 01 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AB_MWMUTIL_H_
|
||||
#define _AB_MWMUTIL_H_
|
||||
/*
|
||||
* MwmUtil.h - include X library header files, while adding necessary
|
||||
* defines for app builder programs.
|
||||
*/
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <Xm/MwmUtil.h>
|
||||
|
||||
/*
|
||||
* Make sure we don't redefine types defined in standard X include files
|
||||
*/
|
||||
#define _AB_BOOL_DEFINED_
|
||||
#define _AB_BYTE_DEFINED_
|
||||
|
||||
#endif /* _AB_MWMUTIL_H_ */
|
||||
14
cde/programs/dtappbuilder/src/libAButil/README.src
Normal file
14
cde/programs/dtappbuilder/src/libAButil/README.src
Normal file
@@ -0,0 +1,14 @@
|
||||
XCOMM $XConsortium: README.src /main/3 1996/04/23 20:04:02 drk $
|
||||
|
||||
Library: libAButil
|
||||
|
||||
Description:
|
||||
|
||||
-------------------------------------------------------
|
||||
-------------------------------------------------------
|
||||
|
||||
Module Prefix Description
|
||||
------ ------ -----------------------
|
||||
Utilities util_
|
||||
Input/Output abio_
|
||||
IString Cache istr_
|
||||
21
cde/programs/dtappbuilder/src/libAButil/UilDef.h
Normal file
21
cde/programs/dtappbuilder/src/libAButil/UilDef.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/* $XConsortium: UilDef.h /main/2 1995/07/15 22:31:34 drk $ */
|
||||
#ifndef _AB_UILDEF_H_
|
||||
#define _AB_UILDEF_H_
|
||||
/*
|
||||
* UilDef.h - include standard header files, adding symbols for AB
|
||||
* files.
|
||||
*/
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <uil/UilDef.h>
|
||||
|
||||
/*
|
||||
* Make sure we don't redefine types defined in standard X include files
|
||||
*/
|
||||
#define _AB_BOOL_DEFINED_
|
||||
#define _AB_BYTE_DEFINED_
|
||||
|
||||
#endif /* _AB_UILDEF_H_ */
|
||||
40
cde/programs/dtappbuilder/src/libAButil/XmAll.h
Normal file
40
cde/programs/dtappbuilder/src/libAButil/XmAll.h
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: XmAll.h /main/4 1995/11/06 18:49:40 rswiston $
|
||||
*
|
||||
* @(#)XmAll.h 1.5 01 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AB_XMALL_H_
|
||||
#define _AB_XMALL_H_
|
||||
/*
|
||||
* XmAll.h - include standard header files, adding symbols for AB
|
||||
* files.
|
||||
*/
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <Xm/XmAll.h>
|
||||
|
||||
/*
|
||||
* Make sure we don't redefine types defined in standard X include files
|
||||
*/
|
||||
#define _AB_BOOL_DEFINED_
|
||||
#define _AB_BYTE_DEFINED_
|
||||
|
||||
#endif /* _AB_XMALL_H_ */
|
||||
2525
cde/programs/dtappbuilder/src/libAButil/abio.c
Normal file
2525
cde/programs/dtappbuilder/src/libAButil/abio.c
Normal file
File diff suppressed because it is too large
Load Diff
395
cde/programs/dtappbuilder/src/libAButil/abio.h
Normal file
395
cde/programs/dtappbuilder/src/libAButil/abio.h
Normal file
@@ -0,0 +1,395 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: abio.h /main/5 1995/11/06 18:50:10 rswiston $
|
||||
*
|
||||
* @(#)abio.h 1.21 11 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* abio.h
|
||||
*
|
||||
* GUIDE Intermediate Language (GIL) file input / output interface.
|
||||
*/
|
||||
|
||||
#ifndef _abio_h
|
||||
#define _abio_h
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ab_private/AB.h>
|
||||
#include <ab_private/istr.h>
|
||||
#include <ab/util_types.h>
|
||||
|
||||
/*
|
||||
* Public functions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Indentation control
|
||||
*/
|
||||
int abio_indent(FILE *text_file);
|
||||
int abio_outdent(FILE *text_file);
|
||||
int abio_set_indent(FILE *text_file, int level);
|
||||
int abio_get_indent(FILE *text_file);
|
||||
int abio_set_indent_char(FILE *text_file, int indent_char);
|
||||
int abio_get_indent_char(FILE *text_file);
|
||||
int abio_set_indent_chars_per_level(FILE *text_file, int chars_per_level);
|
||||
int abio_get_indent_chars_per_level(FILE *text_file);
|
||||
|
||||
|
||||
int abio_close_input(FILE *outFile);
|
||||
|
||||
int abio_close_output(FILE *outFile);
|
||||
|
||||
int abio_access_file(
|
||||
STRING name,
|
||||
BOOL *read_OK,
|
||||
BOOL *write_OK
|
||||
);
|
||||
|
||||
STRING abio_comment_string(void);
|
||||
|
||||
STRING abio_module_string(void);
|
||||
|
||||
STRING abio_project_string(void);
|
||||
|
||||
int abio_get_eof(FILE *inFile);
|
||||
|
||||
int abio_get_file_begin(FILE *inFile);
|
||||
|
||||
int abio_get_file_end(FILE *inFile);
|
||||
|
||||
int abio_get_handler(
|
||||
FILE *inFile,
|
||||
ISTRING *stringOut
|
||||
);
|
||||
|
||||
int abio_get_integer(
|
||||
FILE *inFile,
|
||||
int *i
|
||||
);
|
||||
|
||||
int abio_get_keyword(
|
||||
FILE *inFile,
|
||||
ISTRING *stringOut
|
||||
);
|
||||
|
||||
int abio_get_list(
|
||||
FILE *inFile,
|
||||
ISTRING *stringOut
|
||||
);
|
||||
|
||||
int abio_get_list_begin(FILE *inFile);
|
||||
|
||||
int abio_get_list_end(FILE *inFile);
|
||||
|
||||
int abio_gil_get_full_name(
|
||||
FILE *inFile,
|
||||
ISTRING *interfaceOut,
|
||||
ISTRING *parentOut,
|
||||
ISTRING *nameOut,
|
||||
ISTRING *itemOut
|
||||
);
|
||||
|
||||
int abio_gil_get_object_begin(FILE *inFile);
|
||||
|
||||
int abio_gil_get_object_end(FILE *inFile);
|
||||
|
||||
int abio_get_string(
|
||||
FILE *inFile,
|
||||
ISTRING *stringOut
|
||||
);
|
||||
|
||||
int abio_get_string_begin(FILE *inFile);
|
||||
|
||||
int abio_get_string_end(FILE *inFile);
|
||||
|
||||
STRING abio_integer_string(
|
||||
int i
|
||||
);
|
||||
|
||||
STRING abio_keyword_string(
|
||||
STRING s
|
||||
);
|
||||
|
||||
STRING abio_list_begin_string(void);
|
||||
|
||||
STRING abio_list_end_string(void);
|
||||
|
||||
STRING abio_name_string(
|
||||
STRING s
|
||||
);
|
||||
|
||||
STRING abio_gil_object_begin_string(void);
|
||||
|
||||
STRING abio_gil_object_end_string(void);
|
||||
|
||||
STRING abio_open_output(
|
||||
STRING name,
|
||||
FILE **pOutFile
|
||||
);
|
||||
|
||||
STRING abio_open_gil_input(
|
||||
STRING name,
|
||||
FILE **pInFile
|
||||
);
|
||||
|
||||
STRING abio_open_gil_output(
|
||||
STRING outFileName,
|
||||
FILE **pOutFile
|
||||
);
|
||||
|
||||
int abio_open_bil_output(
|
||||
STRING outfile,
|
||||
STRING old_file,
|
||||
FILE **pOutFile
|
||||
);
|
||||
|
||||
STRING abio_open_proj_input(
|
||||
STRING name,
|
||||
FILE **pInFile
|
||||
);
|
||||
|
||||
STRING abio_open_proj_output(
|
||||
STRING name,
|
||||
FILE **pOutFile
|
||||
);
|
||||
|
||||
STRING abio_open_resfile_input(
|
||||
STRING name,
|
||||
FILE **pInFile
|
||||
);
|
||||
|
||||
int
|
||||
abio_printf(
|
||||
FILE * outFile,
|
||||
STRING fmt,...
|
||||
);
|
||||
|
||||
int
|
||||
abio_print_line(
|
||||
FILE * outFile,
|
||||
STRING fmt,...
|
||||
);
|
||||
|
||||
int abio_putc(
|
||||
FILE *outFile,
|
||||
char c
|
||||
);
|
||||
|
||||
int abio_puts(
|
||||
FILE *outFile,
|
||||
STRING s
|
||||
);
|
||||
|
||||
int abio_put_float(
|
||||
FILE *outFile,
|
||||
double d
|
||||
);
|
||||
|
||||
int abio_put_integer(
|
||||
FILE *outFile,
|
||||
int i
|
||||
);
|
||||
|
||||
int abio_put_keyword(
|
||||
FILE *outFile,
|
||||
AB_OBJECT_TYPE abo_type
|
||||
);
|
||||
|
||||
int abio_put_keyword_name(
|
||||
FILE *outFile,
|
||||
STRING name
|
||||
);
|
||||
int abio_put_handler(
|
||||
FILE *outFile,
|
||||
STRING s
|
||||
);
|
||||
|
||||
int abio_put_full_name(
|
||||
FILE *outFile,
|
||||
STRING parent,
|
||||
STRING name,
|
||||
STRING item
|
||||
);
|
||||
|
||||
int abio_put_proj_full_name(
|
||||
FILE *outFile,
|
||||
STRING itf,
|
||||
STRING parent,
|
||||
STRING name,
|
||||
STRING item
|
||||
);
|
||||
|
||||
int abio_put_string(
|
||||
FILE *outFile,
|
||||
STRING s
|
||||
);
|
||||
|
||||
int abio_put_string_to_file(
|
||||
FILE *outFile,
|
||||
STRING s
|
||||
);
|
||||
|
||||
int abio_put_string_to_buffer(
|
||||
STRING string,
|
||||
STRING outBuf,
|
||||
int size
|
||||
);
|
||||
|
||||
STRING abio_string_begin_string(void);
|
||||
|
||||
STRING abio_string_end_string(void);
|
||||
|
||||
STRING abio_string_string(
|
||||
STRING
|
||||
);
|
||||
|
||||
int abio_open_block(FILE *outFile);
|
||||
|
||||
int abio_close_block(FILE *outFile);
|
||||
|
||||
int abio_expand_path(
|
||||
STRING path
|
||||
);
|
||||
|
||||
int abio_expand_file(
|
||||
char *file,
|
||||
char *exp_file
|
||||
);
|
||||
|
||||
/*
|
||||
* BIL functions
|
||||
*/
|
||||
int abio_expand_bil_proj_path(
|
||||
STRING path
|
||||
);
|
||||
|
||||
int abio_expand_bil_module_path(
|
||||
STRING path
|
||||
);
|
||||
|
||||
int abio_expand_bil_encapsulated_path(
|
||||
STRING path
|
||||
);
|
||||
|
||||
STRING abio_open_bil_input(
|
||||
STRING fileName,
|
||||
int *linesRead,
|
||||
FILE **pInFile
|
||||
);
|
||||
|
||||
float abio_get_bil_version(
|
||||
FILE * fp,
|
||||
int *pLinesRead
|
||||
);
|
||||
|
||||
STRING abio_bil_object_begin_string(void);
|
||||
|
||||
STRING abio_bil_object_end_string(void);
|
||||
|
||||
STRING abio_bil_boolean_string(
|
||||
BOOL value
|
||||
);
|
||||
|
||||
STRING abio_bil_true_string(void);
|
||||
|
||||
STRING abio_bil_false_string(void);
|
||||
|
||||
int abio_bil_get_boolean(
|
||||
FILE *inFile,
|
||||
BOOL *valueOut
|
||||
);
|
||||
|
||||
int abio_bil_put_boolean(
|
||||
FILE *outFile,
|
||||
BOOL value
|
||||
);
|
||||
|
||||
STRING abio_check_bil_version(
|
||||
float ver,
|
||||
STRING name
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* GIL functions
|
||||
*/
|
||||
int abio_is_gil_path(
|
||||
STRING path
|
||||
);
|
||||
|
||||
int abio_gil_expand_path(
|
||||
STRING path
|
||||
);
|
||||
|
||||
int abio_gil_expand_proj_path(
|
||||
STRING path
|
||||
);
|
||||
|
||||
int abio_is_gil_proj_path(
|
||||
STRING path
|
||||
);
|
||||
|
||||
int abio_gil_put_name(
|
||||
FILE *outFile,
|
||||
STRING s
|
||||
);
|
||||
|
||||
int abio_gil_get_name(
|
||||
FILE *inFile,
|
||||
ISTRING *stringOut
|
||||
);
|
||||
|
||||
STRING abio_gil_boolean_string(
|
||||
BOOL value
|
||||
);
|
||||
|
||||
STRING abio_gil_true_string(void);
|
||||
|
||||
STRING abio_gil_false_string(void);
|
||||
|
||||
int abio_gil_get_boolean(
|
||||
FILE *inFile,
|
||||
BOOL *valueOut
|
||||
);
|
||||
|
||||
int abio_gil_put_boolean(
|
||||
FILE *outFile,
|
||||
BOOL value
|
||||
);
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
** **
|
||||
** Inline implementation **
|
||||
** **
|
||||
*****************************************************************/
|
||||
|
||||
|
||||
#define abio_close_input(fp) (abio_close_input_impl(&(fp)))
|
||||
int abio_close_input_impl(FILE **pFp);
|
||||
|
||||
#define abio_close_output(fp) (abio_close_output_impl(&(fp)))
|
||||
int abio_close_output_impl(FILE **pFp);
|
||||
|
||||
|
||||
#endif /* _abio_h */
|
||||
446
cde/programs/dtappbuilder/src/libAButil/abio_path.c
Normal file
446
cde/programs/dtappbuilder/src/libAButil/abio_path.c
Normal file
@@ -0,0 +1,446 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: abio_path.c /main/4 1995/11/06 18:50:21 rswiston $
|
||||
*
|
||||
* @(#)abio_path.c 3.27 02 Apr 1995 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* abio_path.c
|
||||
*
|
||||
* Functions to manipulate file paths.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <ab_private/util.h>
|
||||
#include <ab_private/abio.h>
|
||||
|
||||
#define GIL_SUFFIX ".G"
|
||||
#define GIL_PROJ_SUFFIX ".P"
|
||||
#define BIL_MODULE_SUFFIX "bil"
|
||||
#define BIL_PROJ_SUFFIX "bip"
|
||||
#define BIL_ENCAP_SUFFIX "bix"
|
||||
|
||||
static char Buf[MAXPATHLEN]; /* Work buffer */
|
||||
|
||||
static void expand_path(
|
||||
char *nm,
|
||||
char *buf
|
||||
);
|
||||
|
||||
/*
|
||||
* Expands the path and file name of a file.
|
||||
* exp_dir and exp_file store the expanded path and file name returned
|
||||
* from this function.
|
||||
* Note: exp_dir and exp_file have to be allocated memory.
|
||||
*/
|
||||
|
||||
int
|
||||
abio_expand_file(
|
||||
char *file,
|
||||
char *exp_file
|
||||
)
|
||||
{
|
||||
if (!file || !*file)
|
||||
return -1;
|
||||
/*
|
||||
* Expand the file name and store to it.
|
||||
*/
|
||||
strcpy(Buf, file);
|
||||
if (abio_expand_bil_module_path(Buf) == -1)
|
||||
return -1;
|
||||
|
||||
strcpy(exp_file, Buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Expand a path in place. Returns OK if successful, otherwise sets errno
|
||||
* and returns ERROR.
|
||||
*/
|
||||
int
|
||||
abio_expand_path(char *path)
|
||||
{
|
||||
char buf[MAXPATHLEN];
|
||||
|
||||
expand_path(path, buf);
|
||||
strcpy(path, buf);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Expand a path to a GIL file in place. Returns OK if successful,
|
||||
* otherwise sets errno and returns error.
|
||||
*/
|
||||
int
|
||||
abio_gil_expand_path(char *path)
|
||||
{
|
||||
if (abio_expand_path(path) != OK)
|
||||
return ERROR;
|
||||
|
||||
if (abio_is_gil_path(path))
|
||||
return OK;
|
||||
|
||||
if (strlen(path) + strlen(GIL_SUFFIX) >= (size_t)MAXPATHLEN) {
|
||||
errno = ENAMETOOLONG;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
strcat(path, GIL_SUFFIX);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
abio_expand_bil_module_path(
|
||||
char *path
|
||||
)
|
||||
{
|
||||
if (util_file_name_is_bil_module(path))
|
||||
return 0;
|
||||
|
||||
if (strlen(path) + strlen(BIL_MODULE_SUFFIX) >= (size_t)MAXPATHLEN)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
strcat(path, ".");
|
||||
strcat(path, BIL_MODULE_SUFFIX);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Expand a path to a project file in place.
|
||||
*/
|
||||
int
|
||||
abio_gil_expand_proj_path(char *path)
|
||||
{
|
||||
if (abio_gil_expand_path(path) != 0)
|
||||
return ERROR;
|
||||
|
||||
if (abio_is_gil_proj_path(path))
|
||||
return OK;
|
||||
|
||||
if (strlen(path) + strlen(GIL_PROJ_SUFFIX) >= (size_t)MAXPATHLEN) {
|
||||
errno = ENAMETOOLONG;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
strcat(path, GIL_PROJ_SUFFIX);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
abio_expand_bil_proj_path(
|
||||
char *path
|
||||
)
|
||||
{
|
||||
if (util_file_name_is_bil_proj(path))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strlen(path) + strlen(BIL_PROJ_SUFFIX) >= (size_t)MAXPATHLEN)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
strcat(path, ".");
|
||||
strcat(path, BIL_PROJ_SUFFIX);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
abio_expand_bil_encapsulated_path(STRING path)
|
||||
{
|
||||
if (util_file_name_is_bil_encapsulated(path))
|
||||
return 0;
|
||||
|
||||
if (strlen(path) + strlen(BIL_ENCAP_SUFFIX) >= (size_t)MAXPATHLEN)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
strcat(path, ".");
|
||||
strcat(path, BIL_ENCAP_SUFFIX);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Return True if the given path ends with the gil suffix.
|
||||
*/
|
||||
int
|
||||
#ifdef __STDC__
|
||||
abio_is_gil_path(char *path)
|
||||
#else
|
||||
abio_is_gil_path(path)
|
||||
char *path;
|
||||
#endif
|
||||
{
|
||||
return (strcmp(path + strlen(path) - strlen(GIL_SUFFIX),
|
||||
GIL_SUFFIX) == 0);
|
||||
}
|
||||
|
||||
BOOL
|
||||
util_file_name_is_bil_module(STRING path)
|
||||
{
|
||||
return util_file_name_has_extension(path, BIL_MODULE_SUFFIX);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return True if the given path ends with the project suffix.
|
||||
*/
|
||||
int
|
||||
abio_is_gil_proj_path(STRING path)
|
||||
{
|
||||
return (strcmp(path + strlen(path) - strlen(GIL_PROJ_SUFFIX),
|
||||
GIL_PROJ_SUFFIX) == 0);
|
||||
}
|
||||
|
||||
BOOL
|
||||
util_file_name_is_bil_proj(STRING path)
|
||||
{
|
||||
return util_file_name_has_extension(path, BIL_PROJ_SUFFIX);
|
||||
}
|
||||
|
||||
BOOL
|
||||
util_file_name_is_bil_encapsulated(
|
||||
char *path
|
||||
)
|
||||
{
|
||||
return (strcmp(path + strlen(path) - strlen(BIL_ENCAP_SUFFIX),
|
||||
BIL_ENCAP_SUFFIX) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* expand_path from OpenWindows V2 FCS XView libraries
|
||||
*
|
||||
* Handles:
|
||||
* ~/ => home dir
|
||||
* ~user/ => user's home dir
|
||||
* If the environment variable a = "foo" and b = "bar" then:
|
||||
* $a => foo
|
||||
* $a$b => foobar
|
||||
* $a.c => foo.c
|
||||
* xxx$a => xxxfoo
|
||||
* ${a}! => foo!
|
||||
* \$a => \$a
|
||||
*
|
||||
* Arguments:
|
||||
* nm input string
|
||||
* pathname buffer to output expanded path
|
||||
*/
|
||||
static void
|
||||
expand_path(char *nm, char *buf)
|
||||
{
|
||||
register char *s, *d;
|
||||
char lnm[MAXPATHLEN];
|
||||
int q;
|
||||
register char *trimchars = "\n \t";
|
||||
|
||||
/* Strip off leading & trailing whitespace and cr */
|
||||
while (strchr(trimchars, *nm) != NULL)
|
||||
nm++;
|
||||
s = nm + (q = strlen(nm)) - 1;
|
||||
while (q-- && strchr(trimchars, *s) != NULL)
|
||||
*s = '\0';
|
||||
|
||||
s = nm;
|
||||
d = lnm;
|
||||
q = nm[0] == '\\' && nm[1] == '~';
|
||||
|
||||
/* Expand inline environment variables */
|
||||
while (*d++ = *s)
|
||||
{
|
||||
if (*s == '\\') {
|
||||
if (*(d - 1) = *++s)
|
||||
{
|
||||
s++;
|
||||
continue;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
else if (*s++ == '$') {
|
||||
register char *start = d;
|
||||
register braces = *s == '{';
|
||||
register char *value;
|
||||
while (*d++ = *s)
|
||||
if (braces ? *s == '}' : !isalnum(*s))
|
||||
break;
|
||||
else
|
||||
s++;
|
||||
*--d = 0;
|
||||
value = getenv(braces ? start + 1 : start);
|
||||
if (value) {
|
||||
for (d = start - 1; *d++ = *value++;);
|
||||
d--;
|
||||
if (braces && *s)
|
||||
s++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Expand ~ and ~user */
|
||||
nm = lnm;
|
||||
s = "";
|
||||
if (nm[0] == '~' && !q) { /* prefix ~ */
|
||||
if (nm[1] == '/' || nm[1] == 0)
|
||||
{ /* ~/filename */
|
||||
if (s = getenv("HOME"))
|
||||
{
|
||||
if (*++nm)
|
||||
nm++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* ~user/filename */
|
||||
register char *nnm;
|
||||
register struct passwd *pw;
|
||||
for (s = nm; *s && *s != '/'; s++);
|
||||
nnm = *s ? s + 1 : s;
|
||||
*s = 0;
|
||||
pw = (struct passwd *) getpwnam(nm + 1);
|
||||
if (pw == 0) {
|
||||
*s = '/';
|
||||
s = "";
|
||||
} else {
|
||||
nm = nnm;
|
||||
s = pw->pw_dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
d = buf;
|
||||
if (*s) {
|
||||
while (*d++ = *s++);
|
||||
*(d - 1) = '/';
|
||||
}
|
||||
s = nm;
|
||||
while (*d++ = *s++);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return whether a file is a BIL file. Returns non-0 version number
|
||||
* if TRUE, otherwise FALSE. Leaves file positioned at the beginning
|
||||
* of first comment (should be version number).
|
||||
*
|
||||
* pLinesRead is incremented by the # of lines read to find the
|
||||
* bil_version line. This number includes the line with the version
|
||||
* number on it.
|
||||
*/
|
||||
float
|
||||
abio_get_bil_version(
|
||||
FILE *fp,
|
||||
int *pLinesRead
|
||||
)
|
||||
{
|
||||
STRING ascii_version_num;
|
||||
STRING tmp;
|
||||
int len = strlen(":bil-version");
|
||||
long int_version_major;
|
||||
long int_version_minor;
|
||||
long first_char;
|
||||
float version = 0.0;
|
||||
char *tok = NULL;
|
||||
char *s1 = NULL;
|
||||
|
||||
rewind(fp);
|
||||
*pLinesRead = 0;
|
||||
while (fgets(Buf, sizeof(Buf), fp))
|
||||
{
|
||||
++(*pLinesRead);
|
||||
|
||||
/* Skip any leading white space.
|
||||
* Ignore lines until a BIL prefix is found.
|
||||
*/
|
||||
s1 = strdup(Buf);
|
||||
tok = strtok(s1, " \t");
|
||||
if (tok && (strncmp(tok, ":bil-version", len) == 0))
|
||||
{
|
||||
/* Prefix matched. Point to the version number
|
||||
* and convert it to a float.
|
||||
*/
|
||||
first_char = ftell(fp);
|
||||
ascii_version_num = Buf + (len);
|
||||
int_version_major = strtol(ascii_version_num, &tmp, 10);
|
||||
int_version_minor = strtol(tmp, &tmp, 10);
|
||||
|
||||
if (ascii_version_num != tmp)
|
||||
{
|
||||
version = (float) (int_version_major);
|
||||
version = version +
|
||||
((float) (((float) (int_version_minor)) /
|
||||
10.0));
|
||||
}
|
||||
fseek(fp, first_char, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef BOGUS
|
||||
version_string = strcat("// ", AB_VERSION_PREFIX);
|
||||
if (strncmp(Buf, version_string, (len + 3)) == 0)
|
||||
{
|
||||
|
||||
/*
|
||||
* Prefix matched. Point to the version number and convert it to
|
||||
* an integer.
|
||||
*/
|
||||
first_char = ftell(fp);
|
||||
Buf[strlen(Buf) - 1] = '\0';
|
||||
ascii_version_num = Buf + (len + 3);
|
||||
int_version_num = strtol(ascii_version_num, &tmp, 10);
|
||||
|
||||
if (ascii_version_num != tmp)
|
||||
version = (int) int_version_num;
|
||||
fseek(fp, first_char, 0);
|
||||
break;
|
||||
}
|
||||
#endif /* BOGUS */
|
||||
|
||||
/* Need to free space allocated by strdup() above */
|
||||
if (s1) {
|
||||
free(s1);
|
||||
s1 = NULL;
|
||||
}
|
||||
}
|
||||
if (s1) free(s1);
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
FILE *
|
||||
util_create_tmp_file(
|
||||
char *data
|
||||
)
|
||||
{
|
||||
FILE *tmpFile = NULL;
|
||||
|
||||
tmpFile = tmpfile();
|
||||
if (tmpFile != NULL)
|
||||
{
|
||||
fputs(data, tmpFile);
|
||||
rewind(tmpFile);
|
||||
}
|
||||
|
||||
return (tmpFile);
|
||||
}
|
||||
1042
cde/programs/dtappbuilder/src/libAButil/istr.c
Normal file
1042
cde/programs/dtappbuilder/src/libAButil/istr.c
Normal file
File diff suppressed because it is too large
Load Diff
268
cde/programs/dtappbuilder/src/libAButil/istr.h
Normal file
268
cde/programs/dtappbuilder/src/libAButil/istr.h
Normal file
@@ -0,0 +1,268 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: istr.h /main/4 1995/11/06 18:50:56 rswiston $
|
||||
*
|
||||
* @(#)istr.h 1.27 11 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* istr.h - string allocater
|
||||
*
|
||||
* empty value for an ISTRING is NULL.
|
||||
*/
|
||||
#ifndef _ISTR_H
|
||||
#define _ISTR_H
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <ab_private/AB.h>
|
||||
#include <ab/util_types.h>
|
||||
#include <ab_private/util.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE you_dont_want_to_use_this_field;
|
||||
} ISTRING_PUBLIC_REC;
|
||||
|
||||
typedef ISTRING_PUBLIC_REC *ISTRING;
|
||||
|
||||
/*
|
||||
* Allocate a new istring for a given string and return the value,
|
||||
* or if the string already exists return the value
|
||||
* for an existing istring. If the string was previously allocated as
|
||||
* a read only string change its status to const and its string
|
||||
* pointer.
|
||||
* Returns -1 if error.
|
||||
* Note: This string is read only. The string sent in is already
|
||||
* allocated and the destroy command will not deallocate the
|
||||
* string
|
||||
*/
|
||||
extern ISTRING istr_create_const(
|
||||
STRING string
|
||||
);
|
||||
|
||||
/*
|
||||
* Identical to istr_create_const (shortcut)
|
||||
*/
|
||||
extern ISTRING istr_const(
|
||||
STRING string
|
||||
);
|
||||
|
||||
/*
|
||||
* Allocate a new istring for a given string and return the value,
|
||||
* or if the string already exists return the value
|
||||
* for an existing istring. Returns -1 if error.
|
||||
* Note: This string is read only. The string sent in is already
|
||||
* allocated and the destroy command will deallocate the
|
||||
* string
|
||||
*/
|
||||
extern ISTRING istr_create_alloced(
|
||||
STRING string
|
||||
);
|
||||
|
||||
/*
|
||||
* Allocate a new istring for a given string and return the value,
|
||||
* or if the string already exists return the value for an
|
||||
* existing istring. Returns -1 if error.
|
||||
* Note: This string is read only. The string sent in has not
|
||||
* been allocated and the destroy command will deallocate
|
||||
* the string.
|
||||
*/
|
||||
extern ISTRING istr_create(
|
||||
STRING string
|
||||
);
|
||||
|
||||
/*
|
||||
* Deallocate for the string if refcount=0 else decrement the refcount.
|
||||
* If the string type is const then don't deallocate.
|
||||
* returns -1 if error, else returns 1
|
||||
*/
|
||||
extern int istr_destroy(
|
||||
ISTRING istring
|
||||
);
|
||||
|
||||
/*
|
||||
* Return the string value, and increment counter
|
||||
* return -1 if error
|
||||
*/
|
||||
extern ISTRING istr_dup(
|
||||
ISTRING istring
|
||||
);
|
||||
|
||||
/*
|
||||
* Return (STRING) for istring, return NULL if error
|
||||
*/
|
||||
extern STRING istr_string(
|
||||
ISTRING istring
|
||||
);
|
||||
|
||||
/*
|
||||
* Won't return NULL - returns string associated with istring,
|
||||
* or "(nil)"
|
||||
* Note: printable string returned
|
||||
*/
|
||||
extern STRING istr_string_safe(
|
||||
ISTRING istring
|
||||
);
|
||||
|
||||
/*
|
||||
* Finds the existing ISTRING value for string, returns NULL if string
|
||||
* doesn't exist
|
||||
*
|
||||
* Note that this dups the existing string, and istr_destroy() must
|
||||
* be called on the returned ISTRING when it is no longer needed.
|
||||
*/
|
||||
extern ISTRING istr_dup_existing(
|
||||
STRING s
|
||||
);
|
||||
|
||||
/*
|
||||
* Moves the istring in "from" to the istring in "to" and
|
||||
* sets "from" to NULL
|
||||
* always returns 0
|
||||
*/
|
||||
extern int istr_move(
|
||||
ISTRING to,
|
||||
ISTRING from
|
||||
);
|
||||
|
||||
/*
|
||||
* Returns the length of the string, returns NULL if the
|
||||
* string is empty
|
||||
*/
|
||||
extern int istr_len(
|
||||
ISTRING s
|
||||
);
|
||||
|
||||
/*
|
||||
* Compare the two strings, returns the same as strcmp
|
||||
*/
|
||||
extern int istr_cmp(
|
||||
ISTRING s1,
|
||||
ISTRING s2
|
||||
);
|
||||
|
||||
/*
|
||||
* Compare the two istrings, returns TRUE if equal
|
||||
*/
|
||||
extern BOOL istr_equal(
|
||||
ISTRING s1,
|
||||
ISTRING s2
|
||||
);
|
||||
|
||||
/*
|
||||
* Compare the two strings, returns the same as strcmp
|
||||
*/
|
||||
extern int istr_cmpstr(
|
||||
ISTRING s1,
|
||||
STRING s2
|
||||
);
|
||||
|
||||
/*
|
||||
* Compare the two strings, returns TRUE if equal
|
||||
*/
|
||||
extern BOOL istr_equalstr(
|
||||
ISTRING s1,
|
||||
STRING s2
|
||||
);
|
||||
|
||||
/*
|
||||
* Verifies that the given ISTRING is valid (e.g., that it exists, and that
|
||||
* it is not corrupted.
|
||||
*
|
||||
* Returns < 0 if an error is detected
|
||||
*/
|
||||
int istr_verify(ISTRING);
|
||||
|
||||
/*
|
||||
* Checks all the ISTRINGS and internal data structures to see if anything
|
||||
* has become corrupted.
|
||||
*
|
||||
* Returns < 0 if an error is detected
|
||||
*/
|
||||
int istr_verify_all(void);
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Internal functions - clients must not call these! **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int refcount;
|
||||
STRING str;
|
||||
unsigned int read_const : 1;
|
||||
} ISTR_PRIVT_STRN;
|
||||
|
||||
extern STRING Istr_null_string;
|
||||
extern int istrP_destroy_impl518283652PrivF(ISTRING*);
|
||||
extern ISTRING istrP_create_alloced_impl9726039350PrivF(STRING*);
|
||||
extern int istrP_notify_invalid2160413670PrivF(ISTRING);
|
||||
extern STRING istrP_get_string_fast3718930164PrivF(ISTRING);
|
||||
extern STRING istrP_get_string_verify4521632085PrivF(ISTRING);
|
||||
extern int istrP_num_count7608925912PrivD;
|
||||
extern ISTR_PRIVT_STRN *istrP_int_array1809065681PrivD;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Inline implementation **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
#define istr_equal(a,b) ((a) == (b))
|
||||
#define istr_len(s) ((s)==NULL? 0:strlen(istr_string(s)))
|
||||
|
||||
#define istr_destroy(s) \
|
||||
(istrP_destroy_impl518283652PrivF(&(s)))
|
||||
|
||||
#define istr_create_alloced(s) \
|
||||
(istrP_create_alloced_impl9726039350PrivF(&(s)))
|
||||
|
||||
#define istr_move(a,b) ((int)((a)=(b), (b)=NULL))
|
||||
|
||||
#define istr_cmp(a,b) (util_strcmp(istr_string(a),istr_string(b)))
|
||||
|
||||
#define istr_cmpstr(a,b) (util_strcmp(istr_string(a),(b)))
|
||||
|
||||
#define istr_equalstr(a,b) (istr_cmpstr(a,b)==0)
|
||||
|
||||
#define istr_const(s) (istr_create_const(s))
|
||||
|
||||
#define istr_string_safe(s) ((s) == NULL? Istr_null_string:istr_string(s))
|
||||
|
||||
#define istrP_get_string_fast3718930164PrivF(istring) \
|
||||
(istrP_int_array1809065681PrivD[((int)istring)].str)
|
||||
|
||||
/* istr_string - if debugging is turned on, checks ISTRINGS for validity */
|
||||
#ifdef DEBUG
|
||||
#define istr_string(istring) \
|
||||
((!debugging())? \
|
||||
istrP_get_string_fast3718930164PrivF(istring) \
|
||||
: \
|
||||
istrP_get_string_verify4521632085PrivF(istring) \
|
||||
)
|
||||
#else
|
||||
#define istr_string(istring) \
|
||||
(istrP_get_string_fast3718930164PrivF(istring))
|
||||
#endif /* DEBUG */
|
||||
|
||||
#endif /* _ISTR_H */
|
||||
406
cde/programs/dtappbuilder/src/libAButil/istr_hash.c
Normal file
406
cde/programs/dtappbuilder/src/libAButil/istr_hash.c
Normal file
@@ -0,0 +1,406 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: istr_hash.c /main/5 1996/10/02 17:09:13 drk $
|
||||
*
|
||||
* %W% %G%
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libAButil/istr_hash.h>
|
||||
|
||||
static int hash_count = 0; /* total number that has been inserted */
|
||||
|
||||
unsigned static hashing(ISTRING val);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* EXTERNAL FUNCTIONS */
|
||||
/*****************************************************************************/
|
||||
|
||||
HASH * hash_create()
|
||||
{
|
||||
HASH *table;
|
||||
int i,j;
|
||||
|
||||
table = (HASH *)malloc(HASHSIZE*sizeof(HASH));
|
||||
if(table == NULL)
|
||||
{
|
||||
fprintf(stderr,"Error in allocating memory\n");
|
||||
return NULL;
|
||||
}
|
||||
for(i=0; i< HASHSIZE; i++)
|
||||
{
|
||||
table[i].next = NULL;
|
||||
for (j=0; j < BUCKETSIZE; j++)
|
||||
table[i].value[j].value = -1;
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
int hash_destroy(HASH *table)
|
||||
{
|
||||
free(table);
|
||||
table = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
insert(HASH *hashtable, ISTRING istring, void *str)
|
||||
{
|
||||
int hashval;
|
||||
void *str_exists;
|
||||
HASH *new_bucket;
|
||||
int i,j;
|
||||
HASH *entry;
|
||||
|
||||
if (istring == NULL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ISTR: can't create empty string\n");
|
||||
return NULL;
|
||||
}
|
||||
hashval = hashing(istring);
|
||||
if ((str_exists = hash_lookup(hashtable, istring )) == NULL)
|
||||
/* new entry */
|
||||
{
|
||||
entry = &hashtable[hashval];
|
||||
for (i=0; i< BUCKETSIZE; i++)
|
||||
{
|
||||
if (entry->value[i].value == -1)
|
||||
{
|
||||
entry->value[i].value = istring;
|
||||
entry->value[i].entry = str;
|
||||
hash_count++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
while(entry->next != NULL) /* check next bucket */
|
||||
{
|
||||
entry = entry->next;
|
||||
for (i=0; i< BUCKETSIZE; i++)
|
||||
{
|
||||
if (entry->value[i].value == -1)
|
||||
{
|
||||
entry->value[i].value = istring;
|
||||
entry->value[i].entry = str;
|
||||
hash_count++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* if get this far, then no space is available in existing bucket,
|
||||
add new bucket */
|
||||
new_bucket = (HASH *)malloc (sizeof(HASH));
|
||||
if (new_bucket == NULL)
|
||||
{
|
||||
fprintf(stderr,"Error in allocating memory\n");
|
||||
return NULL ;
|
||||
}
|
||||
for(i=1;i<BUCKETSIZE; i++)
|
||||
new_bucket->value[i].value = -1;
|
||||
new_bucket->next = NULL;
|
||||
new_bucket->value[0].value = istring;
|
||||
new_bucket->value[0].entry = str;
|
||||
hash_count++;
|
||||
entry->next = new_bucket;
|
||||
return 1;
|
||||
}
|
||||
else /* duplicate entry */
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
delete(HASH *hashtable, ISTRING istring)
|
||||
{
|
||||
int val; /* hashing value */
|
||||
int i;
|
||||
HASH *entry;
|
||||
|
||||
if(istring == 0)
|
||||
{
|
||||
fprintf(stderr,"the reference string %p doesn't exist\n",
|
||||
istring);
|
||||
return 0;
|
||||
}
|
||||
val = hashing(istring);
|
||||
entry = &hashtable[val];
|
||||
for (i =0; i< BUCKETSIZE; i++)
|
||||
{
|
||||
if (entry->value[i].value == istring)
|
||||
{
|
||||
entry->value[i].value = -1;
|
||||
entry->value[i].entry = NULL;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
while(entry->next != NULL)
|
||||
{
|
||||
entry = entry->next;
|
||||
for (i =0; i< BUCKETSIZE; i++)
|
||||
{
|
||||
if (entry->value[i].value == istring)
|
||||
{
|
||||
entry->value[i].value = -1;
|
||||
entry->value[i].entry = NULL;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* PRIVATE FUNCTIONS */
|
||||
/******************************************************************************/
|
||||
|
||||
/* hash function */
|
||||
unsigned
|
||||
static hashing(ISTRING val)
|
||||
{
|
||||
val %= HASHSIZE;
|
||||
return val;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
*hash_lookup(HASH *hashtable, ISTRING istr)
|
||||
{ /* search hash table for existing strings */
|
||||
HASH entry;
|
||||
int i;
|
||||
unsigned val;
|
||||
|
||||
val = hashing(istr);
|
||||
entry = hashtable[val];
|
||||
for (i =0; i< BUCKETSIZE; i++)
|
||||
{
|
||||
if (entry.value[i].value != -1)
|
||||
{
|
||||
if (entry.value[i].value == istr)
|
||||
{
|
||||
return entry.value[i].entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(entry.next != NULL)
|
||||
{
|
||||
entry = *entry.next;
|
||||
for (i =0; i< BUCKETSIZE; i++)
|
||||
{
|
||||
if (entry.value[i].value != -1)
|
||||
{
|
||||
if (entry.value[i].value == istr)
|
||||
return entry.value[i].entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
int a,b,c,d;
|
||||
int *x,*y,*z;
|
||||
int i,j;
|
||||
int *w;
|
||||
HASH entry;
|
||||
HASH *table, *tb;
|
||||
printf("\n\n\n");
|
||||
table = hash_create();
|
||||
x = (int *)malloc(sizeof(int));
|
||||
y = (int *)malloc(sizeof(int));
|
||||
z = (int *)malloc(sizeof(int));
|
||||
*x = 10;
|
||||
*y = 20;
|
||||
*z = 30;
|
||||
printf("%d x value \n",*x);
|
||||
a = insert(table,5,x);
|
||||
printf("%d return value\n",a);
|
||||
a = insert(table,5,x);
|
||||
printf("%d return value\n",a);
|
||||
for (i=0; i<HASHSIZE; i++)
|
||||
{
|
||||
entry = table[i];
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
while(entry.next != NULL)
|
||||
{
|
||||
entry = *entry.next;
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
}
|
||||
}
|
||||
printf("\n\n\n");
|
||||
b= insert(table,2,y);
|
||||
printf("%d return value\n",b);
|
||||
for (i=0; i<HASHSIZE; i++)
|
||||
{
|
||||
entry = table[i];
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
while(entry.next != NULL)
|
||||
{
|
||||
entry = *entry.next;
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\n\n");
|
||||
d = delete(table,5);
|
||||
printf("%d return value\n",d);
|
||||
d = delete(table,1);
|
||||
printf("%d return value\n",d);
|
||||
for (i=0; i<HASHSIZE; i++)
|
||||
{
|
||||
entry = table[i];
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
while(entry.next != NULL)
|
||||
{
|
||||
entry = *entry.next;
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
}
|
||||
}
|
||||
printf("\n\n\n");
|
||||
|
||||
b= insert(table,7,z);
|
||||
printf("%d return value\n",b);
|
||||
b= insert(table,3,x);
|
||||
printf("%d return value\n",b);
|
||||
b= insert(table,9,y);
|
||||
printf("%d return value\n",b);
|
||||
b= insert(table,11,y);
|
||||
printf("%d return value\n",b);
|
||||
for (i=0; i<HASHSIZE; i++)
|
||||
{
|
||||
entry = table[i];
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
while(entry.next != NULL)
|
||||
{
|
||||
entry = *entry.next;
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
}
|
||||
}
|
||||
printf("\n\n\n");
|
||||
w= hash_lookup(table,3);
|
||||
printf("%p return value\n",w);
|
||||
printf("\n\n\n");
|
||||
|
||||
d = delete(table,3);
|
||||
printf("%d return value\n",d);
|
||||
for (i=0; i<HASHSIZE; i++)
|
||||
{
|
||||
entry = table[i];
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
while(entry.next != NULL)
|
||||
{
|
||||
entry = *entry.next;
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
}
|
||||
}
|
||||
printf("\n\n\n");
|
||||
b= insert(table,4,y);
|
||||
printf("%d return value\n",b);
|
||||
|
||||
for (i=0; i<HASHSIZE; i++)
|
||||
{
|
||||
entry = table[i];
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
while(entry.next != NULL)
|
||||
{
|
||||
entry = *entry.next;
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
}
|
||||
}
|
||||
tb = hash_create();
|
||||
b= insert(tb,4,z);
|
||||
printf("%d return value\n",b);
|
||||
b= insert(tb,9,x);
|
||||
printf("%d return value\n",b);
|
||||
b= insert(tb,2,y);
|
||||
printf("%d return value\n",b);
|
||||
b= insert(tb,22,y);
|
||||
printf("%d return value\n",b);
|
||||
for (i=0; i<HASHSIZE; i++)
|
||||
{
|
||||
entry = tb[i];
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
while(entry.next != NULL)
|
||||
{
|
||||
entry = *entry.next;
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
}
|
||||
}
|
||||
printf("\n\n\n");
|
||||
for (i=0; i<HASHSIZE; i++)
|
||||
{
|
||||
entry = table[i];
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
while(entry.next != NULL)
|
||||
{
|
||||
entry = *entry.next;
|
||||
for (j=0; j<BUCKETSIZE; j++)
|
||||
if (entry.value[j].value != -1)
|
||||
printf("%p value %p ptr \n",entry.value[j].value,
|
||||
entry.value[j].entry);
|
||||
}
|
||||
}
|
||||
hash_destroy(table);
|
||||
}
|
||||
56
cde/programs/dtappbuilder/src/libAButil/istr_hash.h
Normal file
56
cde/programs/dtappbuilder/src/libAButil/istr_hash.h
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: istr_hash.h /main/4 1995/11/06 18:51:18 rswiston $
|
||||
*
|
||||
* @(#)istr_hash.h 1.5 01 Feb 1994
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _HASH_H
|
||||
#define _HASH_H
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <ab/ABTypes.h>
|
||||
#include <libAButils/istr.h>
|
||||
|
||||
#define HASHSIZE 211
|
||||
#define BUCKETSIZE 10
|
||||
|
||||
typedef struct ENTRY
|
||||
{
|
||||
ISTRING value;
|
||||
void *entry;
|
||||
}ENTRY;
|
||||
|
||||
typedef struct HASH
|
||||
{
|
||||
struct HASH *next;
|
||||
ENTRY value[BUCKETSIZE];
|
||||
}HASH;
|
||||
|
||||
extern HASH *hash_create();
|
||||
|
||||
extern int hash_destroy(HASH *table);
|
||||
|
||||
extern int insert(HASH *table, ISTRING istring, void *ptr);
|
||||
|
||||
extern int delete(HASH *table, ISTRING istring);
|
||||
|
||||
extern void *hash_lookup(HASH *hashtable, ISTRING istr);
|
||||
|
||||
#endif
|
||||
299
cde/programs/dtappbuilder/src/libAButil/istr_test.c
Normal file
299
cde/programs/dtappbuilder/src/libAButil/istr_test.c
Normal file
@@ -0,0 +1,299 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: istr_test.c /main/5 1996/10/02 17:03:17 drk $
|
||||
*
|
||||
* @(#)istr_test.c 1.8 11 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special restrictions in a
|
||||
* confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
|
||||
* Univel. Do not distribute this document outside HP, IBM, Sun, USL, SCO,
|
||||
* or Univel without Sun's specific written approval. This document and all
|
||||
* copies and derivative works thereof must be returned or destroyed at Sun's
|
||||
* request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* istr_test.c string allocator test case
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ab_private/istr.h>
|
||||
|
||||
|
||||
|
||||
int
|
||||
print_array(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
print_str(ISTRING istr)
|
||||
{
|
||||
printf("'%s' ", util_strsafe(istr_string(istr)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
ISTRING a,
|
||||
b,
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
f,
|
||||
g,
|
||||
h,
|
||||
l,
|
||||
m,
|
||||
n,
|
||||
o,
|
||||
p;
|
||||
int i,
|
||||
j,
|
||||
k;
|
||||
char *x,
|
||||
*y,
|
||||
*z;
|
||||
BOOL q;
|
||||
|
||||
printf("\n\n\n\n\n");
|
||||
x = NULL;
|
||||
f = istr_create_alloced(x);
|
||||
printf("%p value of NULL\n", f);
|
||||
x = strdup("one");
|
||||
f = istr_create_alloced(x);
|
||||
printf("%p value of one\n", f);
|
||||
printf("%s %p *******string after one\n", x, x);
|
||||
y = strdup("one");
|
||||
printf("%s %p *******string before one --y\n", y, y);
|
||||
g = istr_create_alloced(y);
|
||||
printf("%p value of one\n", g);
|
||||
printf("%p *******string after one --y\n", y);
|
||||
z = strdup("two");
|
||||
h = istr_create_alloced(z);
|
||||
printf("%s %p *******string after two --x\n", x, x);
|
||||
printf("%p *******string after two --y\n", y);
|
||||
printf("%s %p *******string after two --z\n", z, z);
|
||||
printf("%p value of one\n", h);
|
||||
print_array();
|
||||
x = strdup("create");
|
||||
p = istr_create_alloced(x);
|
||||
printf("%p value of create\n", p);
|
||||
x = strdup("ffffff");
|
||||
o = istr_create_alloced(x);
|
||||
printf("%p value of ffffff\n", o);
|
||||
i = istr_destroy(p);
|
||||
printf("%d returned %p value\n", i, p);
|
||||
print_array();
|
||||
x = strdup("hhhhhh");
|
||||
o = istr_create_alloced(x);
|
||||
printf("%p value of hhhh\n", o);
|
||||
print_array();
|
||||
|
||||
printf("\n\n\n\n\n");
|
||||
a = istr_create("first");
|
||||
printf("%p value of first\n", a);
|
||||
b = istr_create("second");
|
||||
printf("%p value of second\n", b);
|
||||
c = istr_create("third");
|
||||
printf("%p value of third\n", c);
|
||||
d = istr_create("fourth");
|
||||
printf("%p value of fourth\n", d);
|
||||
e = istr_create("first");
|
||||
printf("%p value of first\n", e);
|
||||
x = strdup("hiiii");
|
||||
f = istr_create_alloced(x);
|
||||
printf("%p value of hiiii\n", f);
|
||||
x = strdup("hiiii");
|
||||
g = istr_create_const(x);
|
||||
printf("%p value of hiiii\n", g);
|
||||
h = istr_create("third");
|
||||
printf("%p value of third\n", h);
|
||||
l = istr_create("fourth");
|
||||
printf("%p value of fourth\n", l);
|
||||
m = istr_create_const("fourth");
|
||||
printf("%p value of fourth\n", m);
|
||||
n = istr_create_const("fifth");
|
||||
printf("%p value of fifth\n", n);
|
||||
o = istr_create("fifth");
|
||||
printf("%p value of fifth\n", o);
|
||||
print_array();
|
||||
printf("###################\n");
|
||||
i = istr_destroy(a);
|
||||
printf("%d returned %p value\n", i, a);
|
||||
i = istr_destroy(b);
|
||||
printf("%d returned %p value\n", i, b);
|
||||
i = istr_destroy(c);
|
||||
printf("%d returned %p value\n", i, c);
|
||||
i = istr_destroy(d);
|
||||
printf("%d returned %p value\n", i, d);
|
||||
i = istr_destroy(e);
|
||||
printf("%d returned %p value\n", i, e);
|
||||
i = istr_destroy(h);
|
||||
printf("%d returned %p value\n", i, h);
|
||||
i = istr_destroy(l);
|
||||
printf("%d returned %p value\n", i, l);
|
||||
i = istr_destroy(m);
|
||||
printf("%d returned %p value\n", i, m);
|
||||
i = istr_destroy(p);
|
||||
i = istr_destroy(f);
|
||||
printf("%d returned %p value\n", i, f);
|
||||
i = istr_destroy(g);
|
||||
printf("%d returned %p value\n", i, g);
|
||||
print_array();
|
||||
|
||||
printf("$$$$$$$$$$$$$$$$$$$\n");
|
||||
/* e = istr_dup(5); */
|
||||
a = istr_create("fifth");
|
||||
printf("%p value of fifth\n", a);
|
||||
b = istr_create("sixth");
|
||||
printf("%p value of sixth\n", b);
|
||||
c = istr_create("sixth");
|
||||
printf("%p value of sixth\n", c);
|
||||
d = istr_create("seventh");
|
||||
printf("%p value of seventh\n", d);
|
||||
e = istr_create("eigth");
|
||||
printf("%p value of eighth\n", e);
|
||||
f = istr_create("nineth");
|
||||
printf("%p value of nieth\n", f);
|
||||
g = istr_create("tenth");
|
||||
printf("%p value of tenth\n", g);
|
||||
h = istr_create("eleventh");
|
||||
printf("%p value of eleventh\n", h);
|
||||
l = istr_create("twelvth");
|
||||
printf("%p value of twelvth\n", l);
|
||||
m = istr_create("thirteenth");
|
||||
printf("%p value of thirteenth\n", m);
|
||||
i = istr_destroy(b);
|
||||
printf("%d returned %p value\n", i, b);
|
||||
i = istr_destroy(b);
|
||||
printf("%d returned %p value\n", i, b);
|
||||
b = istr_create("fourteenth");
|
||||
printf("%p value of fourteenth\n", b);
|
||||
p = istr_create("fifthteenth");
|
||||
printf("%p value of fifthteenth\n", p);
|
||||
print_array();
|
||||
printf("$$$$$$$$$$$$$$$$$$$\n");
|
||||
|
||||
|
||||
e = istr_dup(a);
|
||||
printf("%p value dupped ", e);
|
||||
print_str(e);
|
||||
printf(" string\n");
|
||||
e = istr_dup(d);
|
||||
printf("%p value dupped ", e);
|
||||
print_str(e);
|
||||
printf(" string\n");
|
||||
/* e = istr_dup(8); */
|
||||
printf("%p value dupped ", e);
|
||||
print_str(e);
|
||||
printf(" string\n");
|
||||
/* e = istr_dup(9); */
|
||||
printf("%p value dupped ", e);
|
||||
print_str(e);
|
||||
printf(" string\n");
|
||||
/* e = istr_dup(6); */
|
||||
printf("%p value dupped ", e);
|
||||
print_str(e);
|
||||
printf(" string\n");
|
||||
print_array();
|
||||
/* x = istr_string(9); */
|
||||
printf("%d value %s string\n", 9, x);
|
||||
x = istr_string(a);
|
||||
printf("%p value %s string\n", a, x);
|
||||
x = istr_string(b);
|
||||
printf("%p value %s string\n", b, x);
|
||||
x = istr_string(c);
|
||||
printf("%p value %s string\n", c, x);
|
||||
x = istr_string(d);
|
||||
printf("%p value %s string\n", d, x);
|
||||
/* x = istr_string(6); */
|
||||
printf("%d value %s string\n", 6, x);
|
||||
/* x = istr_string(8); */
|
||||
printf("8 value %s string\n", x);
|
||||
/* x = istr_string(0); */
|
||||
print_array();
|
||||
|
||||
|
||||
|
||||
printf("\n\n\n\n\n");
|
||||
a = istr_dup_existing("tenth");
|
||||
printf("%p value tenth\n", a);
|
||||
a = istr_dup_existing("not");
|
||||
printf("%p value not\n", a);
|
||||
a = istr_dup_existing(NULL);
|
||||
printf("%p value NULL\n", a);
|
||||
print_array();
|
||||
a = (ISTRING)5;
|
||||
i = istr_move(c, a);
|
||||
printf("%p from %p to %d\n", a, c, i);
|
||||
|
||||
i = istr_len(0);
|
||||
printf("%d length %d value\n", i, 4);
|
||||
i = istr_len((ISTRING)4);
|
||||
printf("%d length %d value\n", i, 4);
|
||||
|
||||
printf("istr_cmp\n");
|
||||
i = istr_cmp((ISTRING)2, (ISTRING)2);
|
||||
printf("%d value ", i);
|
||||
print_str((ISTRING)2);
|
||||
print_str((ISTRING)2);
|
||||
printf("\n");
|
||||
i = istr_cmp((ISTRING)1, (ISTRING)2);
|
||||
printf("%d value ", i);
|
||||
print_str((ISTRING)1);
|
||||
print_str((ISTRING)2);
|
||||
printf("\n");
|
||||
i = istr_cmp((ISTRING)2, (ISTRING)1);
|
||||
printf("%d value ", i);
|
||||
print_str((ISTRING)2);
|
||||
print_str((ISTRING)1);
|
||||
printf("\n");
|
||||
i = istr_cmp((ISTRING)2, NULL);
|
||||
printf("%d value ", i);
|
||||
print_str((ISTRING)2);
|
||||
printf("%d\n", NULL);
|
||||
|
||||
printf("istr_equal\n");
|
||||
q = istr_equal((ISTRING)2, (ISTRING)2);
|
||||
printf("%d value %d %d\n", q, 2, 2);
|
||||
q = istr_equal((ISTRING)1, (ISTRING)2);
|
||||
printf("%d value %d %d\n", q, 1, 2);
|
||||
q = istr_equal((ISTRING)2, (ISTRING)1);
|
||||
printf("%d value %d %d\n", q, 2, 1);
|
||||
q = istr_equal(2, NULL);
|
||||
printf("%d value %d %d\n", q, 2, NULL);
|
||||
|
||||
printf("istr_cmpstr\n");
|
||||
i = istr_cmpstr((ISTRING)2, "two");
|
||||
printf("%d value %d %d\n", i, 2, 2);
|
||||
i = istr_cmpstr((ISTRING)1, "two");
|
||||
printf("%d value %d %d\n", i, 1, 2);
|
||||
i = istr_cmpstr((ISTRING)2, "one");
|
||||
printf("%d value %d %d\n", i, 2, 1);
|
||||
i = istr_cmpstr((ISTRING)2, NULL);
|
||||
printf("%d value %d %d\n", i, 2, NULL);
|
||||
|
||||
printf("istr_equalstr\n");
|
||||
q = istr_equalstr((ISTRING)2, "two");
|
||||
printf("%d value %d %d\n", q, 2, 2);
|
||||
q = istr_equalstr((ISTRING)1, "two");
|
||||
printf("%d value %d %d\n", q, 1, 2);
|
||||
q = istr_equalstr((ISTRING)2, "one");
|
||||
printf("%d value %d %d\n", q, 2, 1);
|
||||
q = istr_equalstr((ISTRING)2, NULL);
|
||||
printf("%d value %d %d\n", q, 2, NULL);
|
||||
|
||||
print_array();
|
||||
|
||||
}
|
||||
45
cde/programs/dtappbuilder/src/libAButil/libAButil.msg
Normal file
45
cde/programs/dtappbuilder/src/libAButil/libAButil.msg
Normal file
@@ -0,0 +1,45 @@
|
||||
$ $XConsortium: libAButil.msg /main/3 1995/11/06 18:51:40 rswiston $
|
||||
$ ========================================================================
|
||||
$ = Message source text file for App Builder's libAButil utility library.
|
||||
$ = @(#)libAButil.msg 1.5 02 Apr 1995 dtappbuilder/src/libAButil
|
||||
$ ========================================================================
|
||||
|
||||
$quote "
|
||||
|
||||
$ The set number set below must be syncronized with the #define in utilP.h
|
||||
$set 202
|
||||
1 "ISTR: error in allocating to int array\n"
|
||||
2 "ISTR: error in allocating space for string\n"
|
||||
3 "ISTR: error in allocating memory"
|
||||
4 "Internal error"
|
||||
5 "Recursive function calls"
|
||||
6 "Permission denied"
|
||||
7 "Couldn't open"
|
||||
8 "Data space is full"
|
||||
9 "Buffer is too small"
|
||||
10 "Functionality is not implemented"
|
||||
11 "Not initialized"
|
||||
12 "Client error"
|
||||
13 "Not found"
|
||||
14 "Duplicate key"
|
||||
15 "Bad parameter"
|
||||
16 "I/O error"
|
||||
17 "File not found"
|
||||
18 "Could not open file"
|
||||
19 "Could not write to file"
|
||||
20 "Could not read file"
|
||||
21 "End of file"
|
||||
22 "Bad file format"
|
||||
23 "Could not rename file"
|
||||
24 "Memory error"
|
||||
25 "No memory"
|
||||
26 "Memory is corrupt"
|
||||
27 "Multiple free of memory"
|
||||
28 "Read-only file"
|
||||
29 "Could not backup file"
|
||||
30 "Unrecognized file format"
|
||||
31 "The file %s does not appear to be in BIL\nformat. Either a BIL header (:bil-version) was\nnot found or the header is corrupt."
|
||||
32 "Incompatible BIL version"
|
||||
33 "The version of the BIL file %s (%3.2f)\nis not supported in this version of App Builder."
|
||||
34 "No help text available"
|
||||
35 "NoName"
|
||||
708
cde/programs/dtappbuilder/src/libAButil/strlist.c
Normal file
708
cde/programs/dtappbuilder/src/libAButil/strlist.c
Normal file
@@ -0,0 +1,708 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: strlist.c /main/5 1996/10/02 16:53:22 drk $
|
||||
*
|
||||
* @(#)strlist.c 1.8 14 Oct 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* File: strlist.c
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <ab_private/AB.h>
|
||||
#include <ab_private/istr.h>
|
||||
#include <ab_private/strlist.h>
|
||||
|
||||
/*****************************************************************
|
||||
** **
|
||||
** STRING LIST **
|
||||
** **
|
||||
*****************************************************************/
|
||||
|
||||
static int strlistP_grow_array(StringList list, int sizeDiff);
|
||||
static int strlistP_shrink_array(StringList list, int sizeDiff);
|
||||
static int strlistP_build_user_data_array(
|
||||
StringList list,
|
||||
int index,
|
||||
void *data
|
||||
);
|
||||
|
||||
|
||||
#define strlistP_add_user_data(_list,_index,_data) \
|
||||
((((_list)->user_datas == NULL) && ((_data) != NULL))? \
|
||||
strlistP_build_user_data_array(_list, _index, _data) \
|
||||
: \
|
||||
((int)((_list)->user_datas[(_index)] = (_data))) \
|
||||
)
|
||||
|
||||
|
||||
StringList
|
||||
strlist_create(void)
|
||||
{
|
||||
StringList list = (StringList) util_malloc(sizeof(StringListRec));
|
||||
if (list == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
strlist_construct(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_construct(StringList list)
|
||||
{
|
||||
list->num_strings = 0;
|
||||
list->strings_size = 0;
|
||||
list->strings = NULL;
|
||||
list->user_datas = NULL;
|
||||
list->unique = TRUE;
|
||||
list->sort_order = STRLIST_SORT_CLIENT_DEF;
|
||||
list->indexes_dirty = TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Frees the string list and all it's associated memory.
|
||||
*/
|
||||
int
|
||||
strlist_destroy(StringList list)
|
||||
{
|
||||
strlist_destruct(list);
|
||||
free(list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_destruct(StringList list)
|
||||
{
|
||||
return strlist_make_empty(list);
|
||||
}
|
||||
|
||||
|
||||
STRLIST_SORT_ORDER
|
||||
strlist_get_sort_order(StringList list)
|
||||
{
|
||||
return list->sort_order;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_set_sort_order(StringList list, STRLIST_SORT_ORDER new_order)
|
||||
{
|
||||
int return_value = 0;
|
||||
|
||||
if (list->sort_order != new_order)
|
||||
{
|
||||
list->indexes_dirty = TRUE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_make_empty(StringList list)
|
||||
{
|
||||
int return_value = 0;
|
||||
|
||||
if (list->strings != NULL)
|
||||
{
|
||||
return_value = strlistP_shrink_array(list, list->strings_size);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_is_empty(StringList list)
|
||||
{
|
||||
return (list->num_strings < 1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_set_is_unique(StringList list, BOOL unique)
|
||||
{
|
||||
list->unique = unique;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
strlist_get_is_unique(StringList list)
|
||||
{
|
||||
return list->unique;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Searches the string list for a match.
|
||||
*
|
||||
* returns: true, if the string exists. false, if the string doesn't
|
||||
* exist.
|
||||
*/
|
||||
BOOL
|
||||
strlist_istr_exists(StringList list, ISTRING istring)
|
||||
{
|
||||
return (strlist_get_istr_index(list, istring) >= 0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_set_istr_data(StringList list, ISTRING istring, void *data)
|
||||
{
|
||||
int index = strlist_get_istr_index(list, istring);
|
||||
if (index < 0)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
strlistP_add_user_data(list,index,data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
strlist_get_istr_data(StringList list, ISTRING istring)
|
||||
{
|
||||
int index = strlist_get_istr_index(list, istring);
|
||||
return (index < 0)? NULL:list->user_datas[index];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns the index of the given string, or -1 if it doesn't exist
|
||||
*/
|
||||
int
|
||||
strlist_get_istr_index(StringList list, ISTRING string)
|
||||
{
|
||||
int index = -1;
|
||||
int i = 0;
|
||||
int num_strings = list->num_strings;
|
||||
|
||||
for (i = 0; i < num_strings; ++i)
|
||||
{
|
||||
if (istr_equal(list->strings[i], string))
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
epilogue:
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add a string to a string list.
|
||||
*
|
||||
* Duplicates the string
|
||||
*
|
||||
* returns: 0 if item added successfully ERR_DUPLICATE_KEY if item is
|
||||
* already in list
|
||||
*/
|
||||
int
|
||||
strlist_add_istr(StringList list, ISTRING istring, void *clientData)
|
||||
{
|
||||
int return_value = 0;
|
||||
int rc = 0;
|
||||
|
||||
/*
|
||||
* look for it
|
||||
*/
|
||||
if (list->unique)
|
||||
{
|
||||
int index = strlist_get_istr_index(list, istring);
|
||||
if (index >= 0)
|
||||
{
|
||||
strlistP_add_user_data(list, index, clientData);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate more space
|
||||
*/
|
||||
if (list->num_strings >= list->strings_size)
|
||||
{
|
||||
/* grow the array by 50% (the "opposite" of a binary search) */
|
||||
int new_size = (list->strings_size * 3)/2;
|
||||
int size_inc = new_size - list->strings_size;
|
||||
size_inc = util_max(5,size_inc);
|
||||
rc = strlistP_grow_array(list, size_inc);
|
||||
if (rc < 0)
|
||||
{
|
||||
return_value = rc;
|
||||
goto epilogue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* save the string (and data)
|
||||
*/
|
||||
list->strings[list->num_strings] = istr_dup(istring);
|
||||
strlistP_add_user_data(list, list->num_strings, clientData);
|
||||
++(list->num_strings);
|
||||
|
||||
epilogue:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_remove_istr(StringList list, ISTRING istring)
|
||||
{
|
||||
int index = strlist_get_istr_index(list, istring);
|
||||
if (index < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return strlist_remove_index(list, index);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_remove_index(StringList list, int doomedIndex)
|
||||
{
|
||||
#define num_strings (list->num_strings)
|
||||
ISTRING *strings = list->strings;
|
||||
void **user_datas = list->user_datas;
|
||||
int index = 0;
|
||||
int numToMove = 0;
|
||||
|
||||
if ((doomedIndex < 0) || (doomedIndex >= num_strings))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
numToMove = (num_strings - doomedIndex - 1);
|
||||
|
||||
/*
|
||||
* Destroy this string and collapse the list
|
||||
*/
|
||||
istr_destroy(strings[doomedIndex]);
|
||||
if (numToMove > 0)
|
||||
{
|
||||
memmove((void *)(&(strings[doomedIndex])),
|
||||
(void *)&(strings[doomedIndex+1]),
|
||||
sizeof(ISTRING) * numToMove);
|
||||
strings[num_strings-1] = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy user data and collapse list
|
||||
*/
|
||||
if (user_datas != NULL)
|
||||
{
|
||||
user_datas[doomedIndex] = NULL;
|
||||
if (numToMove > 0)
|
||||
{
|
||||
memmove((void *)(&(user_datas[doomedIndex])),
|
||||
(void *)&(user_datas[doomedIndex+1]),
|
||||
sizeof(void*) * numToMove);
|
||||
user_datas[num_strings-1] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Actually shorten list
|
||||
*/
|
||||
--num_strings;
|
||||
|
||||
return 0;
|
||||
#undef num_strings
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_get_num_strs(StringList list)
|
||||
{
|
||||
if (list == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return list->num_strings;
|
||||
}
|
||||
|
||||
|
||||
ISTRING
|
||||
strlist_get_istr(StringList list, int whichString, void **clientDataOut)
|
||||
{
|
||||
if ((list == NULL) || (whichString >= list->num_strings) ||
|
||||
(whichString < 0))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (clientDataOut != NULL)
|
||||
{
|
||||
*clientDataOut =
|
||||
(list->user_datas == NULL? NULL:list->user_datas[whichString]);
|
||||
}
|
||||
return list->strings[whichString];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Only "soft" limit is supported, now
|
||||
*/
|
||||
BOOL
|
||||
strlist_max_size_is_soft(StringList list)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_set_max_size_soft(StringList list, int maxSize)
|
||||
{
|
||||
int return_value = 0;
|
||||
int sizeDiff = (maxSize - list->strings_size);
|
||||
|
||||
if (sizeDiff < 0)
|
||||
{
|
||||
return_value = strlistP_shrink_array(list, -1 * sizeDiff);
|
||||
}
|
||||
else if (sizeDiff > 0)
|
||||
{
|
||||
return_value = strlistP_grow_array(list, sizeDiff);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_get_max_size(StringList list)
|
||||
{
|
||||
return list->strings_size;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Frees any extra memory that may not be needed (multiple strings are
|
||||
* allocated at once, to reduce the number of realloc calls).
|
||||
*/
|
||||
int
|
||||
strlist_shrink_mem_to_fit(StringList list)
|
||||
{
|
||||
int return_value = 0;
|
||||
int diff = list->strings_size - list->num_strings;
|
||||
|
||||
if (diff > 0)
|
||||
{
|
||||
return_value = strlistP_shrink_array(list, diff);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** STRING interface **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
int
|
||||
strlist_add_str(StringList list, STRING string, void *clientData)
|
||||
{
|
||||
int return_value = 0;
|
||||
ISTRING istring = istr_create(string);
|
||||
return_value = strlist_add_istr(list, istring, clientData);
|
||||
istr_destroy(istring);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
#ifdef UNIMPLEMENTED
|
||||
int
|
||||
strlist_add_index_str(StringList list, int index, STRING string, void *clientData)
|
||||
{
|
||||
int return_value = 0;
|
||||
ISTRING istring = istr_create(string);
|
||||
return_value = strlist_add_index_istr(list, index, istring, clientData);
|
||||
istr_destroy(istring);
|
||||
return return_value;
|
||||
}
|
||||
#endif /* UNIMPLEMENTED */
|
||||
|
||||
|
||||
BOOL
|
||||
strlist_str_exists(StringList list, STRING string)
|
||||
{
|
||||
BOOL doesIt = FALSE;
|
||||
ISTRING istring = istr_dup_existing(string);
|
||||
if (istring != NULL)
|
||||
{
|
||||
doesIt = strlist_istr_exists(list, istring);
|
||||
istr_destroy(istring);
|
||||
}
|
||||
return doesIt;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_get_str_index(StringList list, STRING string)
|
||||
{
|
||||
int index = -1;
|
||||
ISTRING istring = istr_create(string);
|
||||
if (istring != NULL)
|
||||
{
|
||||
index = strlist_get_istr_index(list, istring);
|
||||
istr_destroy(istring);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
STRING
|
||||
strlist_get_str(StringList list, int whichString, void **clientDataOut)
|
||||
{
|
||||
return istr_string(strlist_get_istr(list, whichString, clientDataOut));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_remove_str(StringList list, STRING string)
|
||||
{
|
||||
int return_value = 0;
|
||||
ISTRING istring = istr_dup_existing(string);
|
||||
if (istring != NULL)
|
||||
{
|
||||
return_value = strlist_remove_istr(list, istring);
|
||||
istr_destroy(istring);
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strlist_set_str_data(StringList list, STRING string, void *data)
|
||||
{
|
||||
int return_value = 0;
|
||||
ISTRING istring = istr_dup_existing(string);
|
||||
if (istring != NULL)
|
||||
{
|
||||
return_value = strlist_set_istr_data(list, istring, data);
|
||||
istr_destroy(istring);
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
strlist_get_str_data(StringList list, STRING string)
|
||||
{
|
||||
void *clientData = NULL;
|
||||
ISTRING istring = istr_dup_existing(string);
|
||||
if (istring != NULL)
|
||||
{
|
||||
clientData = strlist_get_istr_data(list, istring);
|
||||
istr_destroy(istring);
|
||||
}
|
||||
return clientData;
|
||||
}
|
||||
|
||||
StringList
|
||||
strlist_dup(StringList list)
|
||||
{
|
||||
int i;
|
||||
StringList new_list = NULL;
|
||||
|
||||
new_list = strlist_create();
|
||||
new_list->unique = list->unique;
|
||||
new_list->sort_order = list->sort_order;
|
||||
new_list->indexes_dirty = list->indexes_dirty;
|
||||
for (i=0; i<list->num_strings; i++)
|
||||
{
|
||||
strlist_add_istr(new_list, list->strings[i], list->user_datas[i]);
|
||||
}
|
||||
return(new_list);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** PRIVATE FUNCTIONS **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
strlistP_shrink_array(StringList list, int sizeDiff)
|
||||
{
|
||||
int return_value = 0;
|
||||
int new_strings_size = util_max(0, list->strings_size - sizeDiff);
|
||||
ISTRING *new_strings = NULL;
|
||||
void **new_user_datas = NULL;
|
||||
int i = 0;
|
||||
|
||||
for (i= new_strings_size; i < list->strings_size; ++i)
|
||||
{
|
||||
if (list->strings[i] != NULL)
|
||||
{
|
||||
istr_destroy(list->strings[i]);
|
||||
}
|
||||
list->user_datas[i] = NULL;
|
||||
}
|
||||
|
||||
if (new_strings_size > 0)
|
||||
{
|
||||
new_strings = (ISTRING *) realloc(
|
||||
list->strings, new_strings_size * sizeof(ISTRING));
|
||||
new_user_datas = (void **) realloc(
|
||||
list->user_datas, new_strings_size * sizeof(void*));
|
||||
}
|
||||
else
|
||||
{
|
||||
util_free(list->strings); list->strings = NULL;
|
||||
util_free(list->user_datas); list->user_datas= NULL;
|
||||
}
|
||||
|
||||
if ( (new_strings_size > 0)
|
||||
&& ((new_strings == NULL) || (new_user_datas == NULL)) )
|
||||
{
|
||||
return_value = -1;
|
||||
goto epilogue;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->strings = new_strings;
|
||||
list->user_datas = new_user_datas;
|
||||
list->strings_size = new_strings_size;
|
||||
if (list->num_strings > list->strings_size)
|
||||
{
|
||||
list->num_strings = util_max(0, list->strings_size);
|
||||
}
|
||||
}
|
||||
|
||||
epilogue:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
strlistP_grow_array(StringList list, int sizeDiff)
|
||||
{
|
||||
int return_value = 0;
|
||||
int old_strings_size = list->strings_size;
|
||||
int new_strings_size = list->strings_size + sizeDiff;
|
||||
ISTRING *new_strings = NULL;
|
||||
void **new_user_datas = NULL;
|
||||
int i = 0;
|
||||
|
||||
new_strings = (ISTRING *)realloc(
|
||||
list->strings, new_strings_size * sizeof(ISTRING));
|
||||
new_user_datas = (void **)realloc(
|
||||
list->user_datas, new_strings_size * sizeof(void *));
|
||||
if ((new_strings == NULL) || (new_user_datas == NULL))
|
||||
{
|
||||
return_value = -1;
|
||||
goto epilogue;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->strings = new_strings;
|
||||
list->user_datas = new_user_datas;
|
||||
list->strings_size = new_strings_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Init the new entries to NULL;
|
||||
*/
|
||||
for (i = old_strings_size; i < new_strings_size; ++i)
|
||||
{
|
||||
list->strings[i] = NULL;
|
||||
list->user_datas[i] = NULL;
|
||||
}
|
||||
|
||||
epilogue:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
strlistP_build_user_data_array(StringList list, int index, void *data)
|
||||
{
|
||||
if (list->user_datas != NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
list->user_datas = (void **)calloc(sizeof(void*), list->strings_size);
|
||||
if (list->user_datas == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
list->user_datas[index] = data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* debugging output
|
||||
*/
|
||||
int
|
||||
strlist_dump(StringList list)
|
||||
{
|
||||
int i = 0;
|
||||
ISTRING istring = NULL;
|
||||
STRING string = NULL;
|
||||
|
||||
if (list == NULL)
|
||||
{
|
||||
util_printf(0, "NULL string list\n");
|
||||
return 0;
|
||||
}
|
||||
if (list->strings_size == 0)
|
||||
{
|
||||
util_dprintf(0, "empty string list\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i= 0; i < list->strings_size; ++i)
|
||||
{
|
||||
istring= list->strings[i];
|
||||
if (istr_verify(istring) < 0)
|
||||
{
|
||||
string = "** Invalid ISTRING **";
|
||||
}
|
||||
else
|
||||
{
|
||||
string = util_strsafe(istr_string(istring));
|
||||
}
|
||||
|
||||
util_dprintf(0, "%d[%s]: '%s'",
|
||||
i,
|
||||
(i >= list->num_strings? " ":"X"),
|
||||
string);
|
||||
|
||||
if (list->user_datas != NULL)
|
||||
{
|
||||
util_dprintf(0, " 0x%08lx", list->user_datas[i]);
|
||||
}
|
||||
util_dprintf(0, "\n");
|
||||
}
|
||||
util_dprintf(0, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
111
cde/programs/dtappbuilder/src/libAButil/strlist.h
Normal file
111
cde/programs/dtappbuilder/src/libAButil/strlist.h
Normal file
@@ -0,0 +1,111 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: strlist.h /main/4 1995/11/06 18:52:03 rswiston $
|
||||
*
|
||||
* @(#)template.h 1.6 11 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ABUTIL_STRLIST_H_
|
||||
#define _ABUTIL_STRLIST_H_
|
||||
/*
|
||||
* strlist.h - string list manipulation
|
||||
*/
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <ab_private/AB.h> /* everybody must include this first! */
|
||||
#include <ab_private/istr.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STRLIST_SORT_UNDEF = 0,
|
||||
STRLIST_SORT_ALPHANUMERIC,
|
||||
STRLIST_SORT_BEST,
|
||||
STRLIST_SORT_CLIENT_DEF,
|
||||
STRLIST_SORT_ORDER_NUM_VALUES /* must be last */
|
||||
} STRLIST_SORT_ORDER;
|
||||
|
||||
/*
|
||||
* string list structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int num_strings;
|
||||
int strings_size;
|
||||
ISTRING *strings;
|
||||
void **user_datas;
|
||||
BOOL unique;
|
||||
STRLIST_SORT_ORDER sort_order;
|
||||
BOOL indexes_dirty;
|
||||
} StringListRec, *StringList;
|
||||
|
||||
|
||||
/*
|
||||
* StringList
|
||||
*/
|
||||
StringList strlist_create(void);
|
||||
int strlist_destroy(StringList);
|
||||
int strlist_set_sort_order(StringList, STRLIST_SORT_ORDER);
|
||||
STRLIST_SORT_ORDER strlist_get_sort_order(StringList);
|
||||
int strlist_construct(StringList);
|
||||
int strlist_destruct(StringList);
|
||||
int strlist_set_is_unique(StringList, BOOL unique);
|
||||
BOOL strlist_is_unique(StringList);
|
||||
int strlist_make_empty(StringList);
|
||||
int strlist_is_empty(StringList);
|
||||
int strlist_add_index(StringList,
|
||||
int index, STRING s, void *userData);
|
||||
int strlist_set_num_strs(StringList, int numStrings);
|
||||
int strlist_get_num_strs(StringList);
|
||||
int strlist_set_max_size_soft(StringList, int max_num_strs);
|
||||
int strlist_get_max_size(StringList);
|
||||
BOOL strlist_max_size_is_soft(StringList);
|
||||
int strlist_remove_index(StringList, int index);
|
||||
int strlist_shrink_mem_to_fit(StringList);
|
||||
int strlist_dump(StringList list);
|
||||
|
||||
/*
|
||||
* STRING interfaces
|
||||
*/
|
||||
int strlist_add_str(StringList, STRING s, void *userData);
|
||||
int strlist_remove_str(StringList, STRING s);
|
||||
BOOL strlist_str_exists(StringList list, STRING s);
|
||||
int strlist_get_str_index(StringList list, STRING s);
|
||||
STRING strlist_get_str(StringList,
|
||||
int whichString, void **userDataOut);
|
||||
int strlist_set_str_data(StringList, STRING string, void *data);
|
||||
void *strlist_get_str_data(StringList, STRING string);
|
||||
StringList strlist_dup(StringList);
|
||||
|
||||
|
||||
/*
|
||||
* ISTRING interfaces
|
||||
*
|
||||
* The STRINGs and ISTRING are kept in the same list, and behave identically
|
||||
*/
|
||||
int strlist_add_istr(StringList, ISTRING s, void *userData);
|
||||
int strlist_add_index_istr(StringList,
|
||||
int index, ISTRING s, void *userData);
|
||||
BOOL strlist_istr_exists(StringList list, ISTRING s);
|
||||
int strlist_get_istr_index(StringList list, ISTRING s);
|
||||
ISTRING strlist_get_istr(StringList,
|
||||
int whichString, void **userDataOut);
|
||||
int strlist_set_istr_data(StringList, ISTRING istring, void *data);
|
||||
void *strlist_get_istr_data(StringList, ISTRING istring);
|
||||
int strlist_remove_istr(StringList, ISTRING s);
|
||||
|
||||
#endif /* _ABUTIL_STRLIST_H_ */
|
||||
73
cde/programs/dtappbuilder/src/libAButil/template.c
Normal file
73
cde/programs/dtappbuilder/src/libAButil/template.c
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: template.c /main/4 1995/11/06 18:52:14 rswiston $
|
||||
*
|
||||
* %W% %G% cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* File:
|
||||
*/
|
||||
|
||||
#define FOO_DEFINES "here"
|
||||
|
||||
const char *foo_consts = "also here";
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Private Function Declarations **
|
||||
** **
|
||||
**************************************************************************/
|
||||
static int foo(
|
||||
int foo_int,
|
||||
char *foo_char,
|
||||
);
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Data **
|
||||
** **
|
||||
**************************************************************************/
|
||||
extern int extern_foo;
|
||||
|
||||
static int private_foo;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Function Definitions **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
int
|
||||
ab_foo(
|
||||
char *foo_char
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
foo(
|
||||
int foo_int,
|
||||
char *foo_char
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
33
cde/programs/dtappbuilder/src/libAButil/template.h
Normal file
33
cde/programs/dtappbuilder/src/libAButil/template.h
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: template.h /main/4 1995/11/06 18:52:24 rswiston $
|
||||
*
|
||||
* @(#)template.h 1.6 11 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ABUTIL_TEMPLATE_H_
|
||||
#define _ABUTIL_TEMPLATE_H_
|
||||
/*
|
||||
* Template.h - template header file
|
||||
*/
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <ab_private/AB.h> /* everybody must include this first! */
|
||||
|
||||
|
||||
#endif /* _ABUTIL_TEMPLATE_H_ */
|
||||
341
cde/programs/dtappbuilder/src/libAButil/util.c
Normal file
341
cde/programs/dtappbuilder/src/libAButil/util.c
Normal file
@@ -0,0 +1,341 @@
|
||||
|
||||
/*
|
||||
* $TOG: util.c /main/6 1998/04/06 13:13:09 mgreess $
|
||||
*
|
||||
* @(#)util.c 1.21 16 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, Fujitsu, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* File: util.c - general utilities
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <ab_private/AB.h> /* include first! */
|
||||
#include <ab_private/util.h>
|
||||
#include <ab_private/istr.h>
|
||||
#include "utilP.h"
|
||||
|
||||
static char *const util_verbosity_env_var_name= "AB_DEBUG_VERBOSITY";
|
||||
static char *const default_program_name= "AppBuilder";
|
||||
static ISTRING program_name= NULL;
|
||||
|
||||
const STRING Util_null_string= "(nil)";
|
||||
const STRING Util_empty_string= "";
|
||||
|
||||
const int Util_major_version = 1;
|
||||
const int Util_minor_version = 0;
|
||||
|
||||
int utilP_verbosity= 1;
|
||||
|
||||
|
||||
/*
|
||||
* argv0 may be NULL
|
||||
*/
|
||||
int
|
||||
util_init(int *argc_in_out, STRING **argv_in_out)
|
||||
{
|
||||
#define argc (*argc_in_out)
|
||||
#define argv (*argv_in_out)
|
||||
STRING argv0 = argv[0];
|
||||
char *verboseVar= NULL;
|
||||
int verboseVarValue= -1;
|
||||
int verbosity= 0;
|
||||
|
||||
verbosity = util_get_verbosity();
|
||||
|
||||
/*
|
||||
* If this is a debugging build, look for the debugging level env. var
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
verboseVar= getenv(util_verbosity_env_var_name);
|
||||
if (verboseVar != NULL)
|
||||
{
|
||||
verboseVarValue= atoi(verboseVar);
|
||||
verbosity= verboseVarValue;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
/*
|
||||
* When debugging, keeps the output order consistent. A little
|
||||
* slower, though.
|
||||
*/
|
||||
if (verbosity >= 3)
|
||||
{
|
||||
/* there's really no good reason to unbuffer stdin */
|
||||
util_unbuffer_file(stdout);
|
||||
util_unbuffer_file(stderr);
|
||||
}
|
||||
|
||||
if (argv0 != NULL)
|
||||
{
|
||||
util_set_program_name_from_argv0(argv0);
|
||||
}
|
||||
|
||||
if (verbosity >= 3)
|
||||
{
|
||||
util_puts("Debugging output enabled, because verbosity > 2.\n");
|
||||
}
|
||||
util_set_verbosity(verbosity);
|
||||
verbosity= util_get_verbosity();
|
||||
|
||||
return 0;
|
||||
#undef argc
|
||||
#undef argv
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
util_set_verbosity(int newVerbosity)
|
||||
{
|
||||
int oldVerbosity = utilP_verbosity;
|
||||
|
||||
utilP_verbosity= newVerbosity;
|
||||
|
||||
/*
|
||||
* If this is not a debugging build, do not allow verbosity to
|
||||
* go outside the range that is normal for an end-user.
|
||||
*/
|
||||
#ifndef DEBUG
|
||||
utilP_verbosity = util_max(0, utilP_verbosity);
|
||||
utilP_verbosity = util_min(2, utilP_verbosity);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Nifty message if we're debugging.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
if ( ((oldVerbosity >= 3) || (newVerbosity >= 3))
|
||||
&& (oldVerbosity != newVerbosity) )
|
||||
{
|
||||
int newDebugLevel = debug_level();
|
||||
utilP_verbosity = 3; /* make sure dprintf() prints something */
|
||||
util_dprintf(0, "Verbosity = %d", newVerbosity);
|
||||
if (newDebugLevel > 0)
|
||||
{
|
||||
util_dprintf(0," [ Debugging level %d ]", newDebugLevel);
|
||||
}
|
||||
util_dprintf(0,"\n");
|
||||
utilP_verbosity = newVerbosity;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
util_set_program_name(STRING new_program_name)
|
||||
{
|
||||
istr_destroy(program_name);
|
||||
if (new_program_name == NULL)
|
||||
{
|
||||
program_name= istr_const(default_program_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
program_name= istr_create(new_program_name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
util_set_program_name_from_argv0(STRING argv0)
|
||||
{
|
||||
char progName[MAXPATHLEN];
|
||||
util_get_file_name_from_path(argv0, progName, MAXPATHLEN);
|
||||
if (strlen(progName) > (size_t)0)
|
||||
{
|
||||
util_set_program_name(progName);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
STRING
|
||||
util_get_program_name(void)
|
||||
{
|
||||
return (program_name == NULL?
|
||||
default_program_name
|
||||
:istr_string(program_name));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Performs a lighter-weight fork that does not immediately copy
|
||||
* all the pages of the application. This is ideal for doing a
|
||||
* a fork and immediately execing another application.
|
||||
*
|
||||
* Not all UNIX implementations support a lightweight fork. For
|
||||
* the ones that don't we'll do a normal fork.
|
||||
*/
|
||||
pid_t
|
||||
util_vfork()
|
||||
{
|
||||
return fork();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* putenv() is non-POSIX, so the parameter types can vary a bit...
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if defined(__uxp__) || defined(__hpux) || (defined(sun) && OSMAJORVERSION >= 5 && OSMINORVERSION >= 4) || defined(linux)
|
||||
extern int putenv(const char *string);
|
||||
#elif !(defined(__osf__) || defined(__aix))
|
||||
extern int putenv(char *string);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
int
|
||||
util_putenv(STRING string)
|
||||
{
|
||||
return putenv(string);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
AB_OS_TYPE
|
||||
util_get_os_type(void)
|
||||
{
|
||||
static AB_OS_TYPE osType = AB_OS_UNDEF;
|
||||
static BOOL osTypeDefined = FALSE;
|
||||
int rc = 0; /* return code */
|
||||
struct utsname sysInfo;
|
||||
int aixIndex = -1;
|
||||
int hpIndex = -1;
|
||||
int uxpIndex = -1;
|
||||
int osf1Index = -1;
|
||||
|
||||
#ifdef USL
|
||||
/*
|
||||
* These changes were made ifdef USL due to time constraint.
|
||||
* ifdefs should be removed in next release
|
||||
*/
|
||||
int unixwareIndex = -1;
|
||||
#endif
|
||||
|
||||
int sunIndex = -1;
|
||||
|
||||
if (osTypeDefined)
|
||||
{
|
||||
goto epilogue;
|
||||
}
|
||||
if ((rc = uname(&sysInfo)) < 0)
|
||||
{
|
||||
goto epilogue;
|
||||
}
|
||||
|
||||
aixIndex = util_strcasestr(sysInfo.sysname, "aix");
|
||||
hpIndex = util_strcasestr(sysInfo.sysname, "hp");
|
||||
sunIndex = util_strcasestr(sysInfo.sysname, "sun");
|
||||
uxpIndex = util_strcasestr(sysInfo.sysname, "UNIX_System_V");
|
||||
osf1Index = util_strcasestr(sysInfo.sysname, "osf1");
|
||||
|
||||
#ifdef USL
|
||||
/*
|
||||
* These changes were made ifdef USL due to time constraint.
|
||||
* ifdefs should be removed in next release
|
||||
*/
|
||||
unixwareIndex = util_strcasestr(sysInfo.sysname, "UNIX_SV");
|
||||
#endif
|
||||
|
||||
if (aixIndex < 0) aixIndex = INT_MAX;
|
||||
if (hpIndex < 0) hpIndex = INT_MAX;
|
||||
if (sunIndex < 0) sunIndex = INT_MAX;
|
||||
if (uxpIndex < 0) uxpIndex = INT_MAX;
|
||||
if (osf1Index < 0) osf1Index = INT_MAX;
|
||||
|
||||
#ifdef USL
|
||||
/*
|
||||
* These changes were made ifdef USL due to time constraint.
|
||||
* ifdefs should be removed in next release
|
||||
*/
|
||||
if (unixwareIndex < 0) unixwareIndex = INT_MAX;
|
||||
#endif
|
||||
|
||||
#ifndef USL
|
||||
|
||||
#define IS_MATCH(a,b,c,d,e) \
|
||||
(((a) < (b)) && ((a) < (c)) && ((a) < (d))&& ((a) < (e)))
|
||||
|
||||
if (IS_MATCH(aixIndex, hpIndex, sunIndex, osf1Index, uxpIndex))
|
||||
{
|
||||
return AB_OS_AIX;
|
||||
}
|
||||
if (IS_MATCH(hpIndex, aixIndex, sunIndex, osf1Index, uxpIndex))
|
||||
{
|
||||
return AB_OS_HPUX;
|
||||
}
|
||||
if (IS_MATCH(sunIndex, aixIndex, hpIndex, osf1Index, uxpIndex))
|
||||
{
|
||||
return AB_OS_SUNOS;
|
||||
}
|
||||
if (IS_MATCH(osf1Index, aixIndex, hpIndex, sunIndex, uxpIndex))
|
||||
{
|
||||
return AB_OS_OSF1;
|
||||
}
|
||||
if (IS_MATCH(uxpIndex, aixIndex, hpIndex, sunIndex, osf1Index))
|
||||
{
|
||||
return AB_OS_UXP;
|
||||
}
|
||||
|
||||
#else
|
||||
#define IS_MATCH(a,b,c,d,e,f) \
|
||||
(((a) < (b)) && ((a) < (c)) && ((a) < (d)) && ((a) < (e)) && ((a) < (f)))
|
||||
|
||||
if (IS_MATCH(aixIndex, hpIndex, sunIndex, osf1Index, unixwareIndex, uxpIndex))
|
||||
{
|
||||
return AB_OS_AIX;
|
||||
}
|
||||
if (IS_MATCH(hpIndex, aixIndex, sunIndex, osf1Index, unixwareIndex, uxpIndex))
|
||||
{
|
||||
return AB_OS_HPUX;
|
||||
}
|
||||
if (IS_MATCH(sunIndex, aixIndex, hpIndex, osf1Index, unixwareIndex, uxpIndex))
|
||||
{
|
||||
return AB_OS_SUNOS;
|
||||
}
|
||||
if (IS_MATCH(osf1Index, aixIndex, hpIndex, sunIndex, unixwareIndex, uxpIndex))
|
||||
{
|
||||
return AB_OS_OSF1;
|
||||
}
|
||||
if (IS_MATCH(uxpIndex, aixIndex, hpIndex, sunIndex, unixwareIndex, osf1Index))
|
||||
{
|
||||
return AB_OS_UXP;
|
||||
}
|
||||
if (IS_MATCH(unixwareIndex, aixIndex, hpIndex, sunIndex, osf1Index, uxpIndex))
|
||||
{
|
||||
return AB_OS_UNIXWARE;
|
||||
}
|
||||
#endif /**USL**/
|
||||
osTypeDefined = TRUE;
|
||||
|
||||
epilogue:
|
||||
return osType;
|
||||
}
|
||||
|
||||
|
||||
329
cde/programs/dtappbuilder/src/libAButil/util.h
Normal file
329
cde/programs/dtappbuilder/src/libAButil/util.h
Normal file
@@ -0,0 +1,329 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: util.h /main/4 1995/11/06 18:52:47 rswiston $
|
||||
*
|
||||
* @(#)util.h 1.39 14 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* util.h - general utilities
|
||||
*/
|
||||
#ifndef _AB_ABUTIL_H_
|
||||
#define _AB_ABUTIL_H_
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ab_private/AB.h>
|
||||
#include <ab/util_types.h>
|
||||
#include <ab_private/util_err.h>
|
||||
|
||||
/*
|
||||
* <string.h> seems to have a problem cc -Xc is continually complaining
|
||||
* about strdup().
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char *strdup(const char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AB_OS_UNDEF = 0,
|
||||
AB_OS_HPUX,
|
||||
AB_OS_AIX,
|
||||
AB_OS_SUNOS,
|
||||
AB_OS_OSF1,
|
||||
#ifdef USL
|
||||
AB_OS_UNIXWARE,
|
||||
#endif
|
||||
AB_OS_UXP,
|
||||
AB_OS_TYPE_NUM_VALUES /* must be last */
|
||||
} AB_OS_TYPE;
|
||||
|
||||
|
||||
typedef int UTIL_OUTPUT_HANDLER(STRING error_message);
|
||||
typedef UTIL_OUTPUT_HANDLER *UtilOutputHandler;
|
||||
|
||||
extern const STRING Util_null_string; /* "(nil)" */
|
||||
extern const STRING Util_empty_string; /* "" */
|
||||
extern int utilP_verbosityPriv3602759317; /* private! */
|
||||
|
||||
/*
|
||||
* Initialization
|
||||
*/
|
||||
int util_init(int *argc_in_out, STRING **argv_in_out);
|
||||
|
||||
/*
|
||||
* Memory management
|
||||
*/
|
||||
#define util_free(ptr) {if ((ptr) != NULL) {free(ptr); (ptr)= NULL;}}
|
||||
#define util_malloc(size) (malloc(size))
|
||||
|
||||
|
||||
/*
|
||||
* General
|
||||
*/
|
||||
int util_putenv(STRING string);
|
||||
#define util_min(a,b) (((a) < (b))? (a):(b))
|
||||
#define util_max(a,b) (((a) > (b))? (a):(b))
|
||||
#define util_xor(a,b) ( (((a)?1:0) + ((b)?1:0)) == 1 ) /* logical xor */
|
||||
int util_set_program_name(STRING this_prog_name);
|
||||
STRING util_get_program_name(void);
|
||||
int util_set_program_name_from_argv0(STRING argv0);
|
||||
AB_OS_TYPE util_get_os_type(void);
|
||||
STRING util_os_type_to_string(AB_OS_TYPE);
|
||||
STRING util_os_type_to_ident(AB_OS_TYPE);
|
||||
|
||||
|
||||
/*
|
||||
* Verbosity
|
||||
*
|
||||
* If verbosity is >= 3, debugging is turned on.
|
||||
* verbosity < 3 => debugging level 0
|
||||
* verbosity 3 => debugging level 1
|
||||
* verbosity 4 => debugging level 2
|
||||
* et cetera...
|
||||
*/
|
||||
int util_set_verbosity(int verbosity);
|
||||
int util_get_verbosity(void);
|
||||
BOOL util_be_silent(void);
|
||||
BOOL util_be_verbose(void);
|
||||
int util_get_debug_level(void);
|
||||
int debug_level(void); /* these are special-case shortcuts that */
|
||||
BOOL debugging(); /* don't conform to the naming convention */
|
||||
|
||||
|
||||
/*
|
||||
* Input/Output
|
||||
*
|
||||
* util_puts_err() and util_printf_err() should be used for messages
|
||||
* that absolutely must be seen by the user (this should cause a popup
|
||||
* to appear, when ab is running).
|
||||
*
|
||||
* util_puts() and util_printf() should be used for informative messages,
|
||||
* and may or may not actually be presented to the user.
|
||||
*
|
||||
* util_dputs() and util_dprintf() should be used for debugging messages.
|
||||
* Their first parameter is the debugging level at which the message should
|
||||
* be printed. (verbosity 3 = debug level 1). If debugging is disabled
|
||||
* (e.g., verbosity < 3), these functions never generate output.
|
||||
*
|
||||
* To redirect the error output, use util_set_err_output_handler. ALL error
|
||||
* output will then be sent to that error handler. A value of NULL sends
|
||||
* error messages to stderr (which is the startup default). This is normally
|
||||
* used to add an error handler that will pop up an error dialog when
|
||||
* running in a windowed application.
|
||||
*
|
||||
* util_set_output_handler() works similarly to the error handler.
|
||||
*/
|
||||
int util_set_err_output_handler(UtilOutputHandler);
|
||||
int util_set_output_handler(UtilOutputHandler);
|
||||
int util_puts(STRING msg);
|
||||
int util_puts_err(STRING msg);
|
||||
int util_printf(STRING fmt, ...);
|
||||
int util_printf_err(STRING fmt, ...);
|
||||
void util_set_help_data(STRING help, STRING vol, STRING locID);
|
||||
int util_get_help_data(STRING *help, STRING *vol, STRING *locID);
|
||||
|
||||
/* print output if debugging level >= specified */
|
||||
int util_dputs(int debug_level, STRING msg);
|
||||
int util_dprintf(int debug_level, STRING fmt, ...);
|
||||
|
||||
/*
|
||||
* files
|
||||
*/
|
||||
#define util_fopen fopen /* for consistency */
|
||||
int util_unbuffer_file(FILE *fp); /* for debugging - removes all */
|
||||
/* buffer from the stream */
|
||||
BOOL util_file_is_regular_file(STRING filename);
|
||||
BOOL util_file_is_directory(STRING filename);
|
||||
BOOL util_directory_exists(STRING dirName);
|
||||
BOOL util_file_exists(STRING fileName);
|
||||
long util_file_size(STRING fileName); /* error if file don't exist */
|
||||
BOOL util_paths_are_same_file(STRING path1, STRING path2);
|
||||
int util_fdtruncate(int fildes, off_t length); /* truncate open file*/
|
||||
int util_ftruncate(FILE *file, off_t length, const char *accessType);
|
||||
int util_flock(
|
||||
FILE *file,
|
||||
BOOL wait,
|
||||
int lockType,
|
||||
off_t offset,
|
||||
off_t length
|
||||
);
|
||||
int util_funlock(
|
||||
FILE *file,
|
||||
off_t offset,
|
||||
off_t length
|
||||
);
|
||||
FILE *util_fopen_locked(const char *filename, const char *type);
|
||||
|
||||
BOOL util_file_name_has_extension(STRING file_name, STRING ext);
|
||||
BOOL util_file_name_has_ab_extension(STRING file_name);
|
||||
BOOL util_file_name_is_bil_encapsulated(STRING file_name);
|
||||
BOOL util_file_name_is_bil_module(STRING file_name);
|
||||
BOOL util_file_name_is_bil_proj(STRING file_name);
|
||||
FILE* util_create_tmp_file(char *data);
|
||||
|
||||
int util_cvt_path_to_relative( /* NULL from = cwd */
|
||||
STRING path,
|
||||
STRING from,
|
||||
char *buf,
|
||||
int buf_size);
|
||||
|
||||
/*
|
||||
* strings
|
||||
*
|
||||
* THE UTIL STRING FUNCTIONS *ALWAYS* NULL-TERMINATE ANY RETURNED STRINGS!
|
||||
*
|
||||
* Note: len = length of string withOUT terminating 0
|
||||
* size = size of string including terminating 0 ( = len+1 )
|
||||
*/
|
||||
BOOL util_streq(STRING s1, STRING s2); /* True if strings = */
|
||||
BOOL util_strcmp(STRING s1, STRING s2); /* allows NULL strings */
|
||||
STRING util_strsafe(STRING s); /*returns "(nil)" for NULL strs*/
|
||||
BOOL util_strempty(STRING s); /* looks for NULL AND "" */
|
||||
int util_strncpy(STRING to, STRING from, int to_size);
|
||||
int util_strcvt_to_lower(STRING to, STRING from, int to_size);
|
||||
int util_strcasestr(STRING str, STRING substr);
|
||||
int util_strncasecmp(STRING s1, STRING s2, int max_chars);
|
||||
STRING util_strip_white_space(STRING string);
|
||||
|
||||
|
||||
STRING util_get_file_name_from_path(
|
||||
STRING path,
|
||||
STRING fileNameBuf,
|
||||
int fileNameBufSize
|
||||
);
|
||||
|
||||
STRING util_get_dir_name_from_path(
|
||||
STRING path,
|
||||
STRING dirNameBuf,
|
||||
int dirNameBufSize
|
||||
);
|
||||
|
||||
int util_mkdir_hier(
|
||||
STRING path
|
||||
);
|
||||
|
||||
BOOL util_path_is_absolute(
|
||||
STRING dir
|
||||
);
|
||||
|
||||
int util_derive_name_from_path(
|
||||
char *fullpath,
|
||||
char *objname
|
||||
);
|
||||
|
||||
int util_check_name(
|
||||
STRING name,
|
||||
STRING new_name
|
||||
);
|
||||
|
||||
/*
|
||||
* Process control
|
||||
*/
|
||||
pid_t util_vfork(void); /* lightweight fork() */
|
||||
|
||||
|
||||
/*
|
||||
* conversions
|
||||
*/
|
||||
STRING util_cvt_bool_to_string(BOOL bool_value, STRING buf, int buf_size);
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Inline implementation **
|
||||
** **
|
||||
*************************************************************************/
|
||||
|
||||
/* check 1st chars before calling strcmp - avoids a lot of calls */
|
||||
#define util_streq(s1,s2) \
|
||||
( ((s1) == (s2)) \
|
||||
|| (((s1) != NULL) && ((s2) != NULL) && (((s1)[0] == (s2)[0]) && (strcmp(s1,s2) == 0))) \
|
||||
)
|
||||
|
||||
/*
|
||||
* allows compare of null strings (NULL < "")
|
||||
*/
|
||||
#define util_strcmp(s1,s2) \
|
||||
(((s1) == (s2))? \
|
||||
0 \
|
||||
: \
|
||||
((s1 == NULL)? \
|
||||
(-1) \
|
||||
: \
|
||||
((s2) == NULL? \
|
||||
(1) \
|
||||
: \
|
||||
strcmp((s1),(s2)) \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
#define util_strlen(s) ((s) == NULL? 0:strlen(s))
|
||||
|
||||
#define util_strsafe(s) ((s) == NULL? Util_null_string:(s))
|
||||
|
||||
#define util_strempty(s) (s == NULL || (strcmp(s, "") == 0))
|
||||
|
||||
/*
|
||||
* Verbosity
|
||||
*/
|
||||
#define util_get_verbosity() (utilP_verbosityPriv3602759317)
|
||||
#define util_be_silent() (util_get_verbosity() < 1)
|
||||
#define util_be_verbose() (util_get_verbosity() > 1)
|
||||
#define util_get_debug_level() (util_max(0, util_get_verbosity() - 2))
|
||||
#define debug_level() ((int)(util_get_debug_level()))
|
||||
#define debugging() ((BOOL)(debug_level() > 0))
|
||||
|
||||
/*
|
||||
* We key on DEBUG here, so that if DEBUG is turned off, these macros
|
||||
* evaluate to constants. That should allow the compiler to remove
|
||||
* sections of code that are executed conditionally based on these
|
||||
* macros.
|
||||
*/
|
||||
#ifndef DEBUG
|
||||
#undef util_get_debug_level
|
||||
#define util_get_debug_level() (0)
|
||||
#undef debug_level
|
||||
#define debug_level() (0)
|
||||
#undef debugging
|
||||
#define debugging() (FALSE)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#define util_fclose(fp) ((fp) == NULL? 0:(util_funlock(fp, 0, 0), fclose(fp), (fp)= NULL, 0))
|
||||
|
||||
/*
|
||||
* These functions are obsolete. Here for backwards compatibility
|
||||
*/
|
||||
#define util_error(s) util_puts_err(s)
|
||||
|
||||
#endif /* _AB_ABUTIL_H_ */
|
||||
|
||||
49
cde/programs/dtappbuilder/src/libAButil/utilP.h
Normal file
49
cde/programs/dtappbuilder/src/libAButil/utilP.h
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: utilP.h /main/4 1995/11/06 18:52:58 rswiston $
|
||||
*
|
||||
* @(#)utilP.h 1.7 01 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ABUTIL_UTILP_H_
|
||||
#define _ABUTIL_UTILP_H_
|
||||
/*
|
||||
* utilP.h - private file for utility subsystem
|
||||
*/
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <nl_types.h>
|
||||
#include <ab_private/util.h>
|
||||
|
||||
/*
|
||||
* Convert mangled private identifiers to something more meaningful
|
||||
*/
|
||||
#define utilP_verbosity utilP_verbosityPriv3602759317
|
||||
|
||||
/*
|
||||
** Internationalization defines. UTIL_MESSAGE_CATD must be defined to match
|
||||
** the catalog variable declared and exported in wherever the main() routine lives
|
||||
** (e.g. dtbuilder, a code generator). UTIL_MESSAGE_SET must match what's
|
||||
** defined in libAButil.msg
|
||||
*/
|
||||
#define UTIL_MESSAGE_CATD Dtb_project_catd
|
||||
#define UTIL_MESSAGE_SET 202
|
||||
extern nl_catd UTIL_MESSAGE_CATD;
|
||||
|
||||
#endif /* _ABUTIL_UTILP_H_ */
|
||||
870
cde/programs/dtappbuilder/src/libAButil/util_convert.c
Normal file
870
cde/programs/dtappbuilder/src/libAButil/util_convert.c
Normal file
@@ -0,0 +1,870 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: util_convert.c /main/4 1995/11/06 18:53:08 rswiston $
|
||||
*
|
||||
* @(#)util_convert.c 1.25 23 Oct 1994 cde_app_builder/src/
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* util_convert.c - general utilities for converting to/from AB types
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
#include <ab_private/util.h>
|
||||
#include <ab/util_types.h>
|
||||
#include <ab_private/istr.h>
|
||||
|
||||
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Type/String Conversion **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
static STRING
|
||||
convert_int_to_string(int value,
|
||||
ISTRING *table, int num_values, ISTRING default_value)
|
||||
{
|
||||
if ((value < 0) || (value >= num_values))
|
||||
{
|
||||
return istr_string(default_value);
|
||||
}
|
||||
return istr_string(table[value]);
|
||||
}
|
||||
|
||||
static int
|
||||
convert_string_to_int(STRING s_value,
|
||||
ISTRING *table, int num_values, int default_value)
|
||||
{
|
||||
int i;
|
||||
int int_value= default_value;
|
||||
ISTRING is_value= istr_create(s_value);
|
||||
if (s_value == NULL)
|
||||
{
|
||||
istr_destroy(is_value);
|
||||
return int_value;
|
||||
}
|
||||
for (i= 0; i < num_values; ++i)
|
||||
{
|
||||
if (istr_equal(table[i], is_value))
|
||||
{
|
||||
int_value= i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
istr_destroy(is_value);
|
||||
return int_value;
|
||||
}
|
||||
|
||||
static int
|
||||
convert_fill_table(ISTRING *table, int num_values, ISTRING value)
|
||||
{
|
||||
int i;
|
||||
for (i= 0; i < num_values; ++i)
|
||||
{
|
||||
table[i]= value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** AB_BUILTIN_ACTION **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
static BOOL builtin_action_table_inited= FALSE;
|
||||
static ISTRING builtin_action_table[AB_BUILTIN_ACTION_NUM_VALUES]= {NULL};
|
||||
|
||||
#define check_builtin_action_table_init() \
|
||||
(builtin_action_table_inited? 0:builtin_action_table_init())
|
||||
|
||||
static int
|
||||
builtin_action_table_init()
|
||||
{
|
||||
#define bat builtin_action_table
|
||||
builtin_action_table_inited= TRUE;
|
||||
convert_fill_table(builtin_action_table,
|
||||
AB_BUILTIN_ACTION_NUM_VALUES,
|
||||
istr_const("?when?"));
|
||||
|
||||
bat[AB_STDACT_UNDEF]= istr_const("Undef");
|
||||
bat[AB_STDACT_DISABLE]= istr_const("Disable");
|
||||
bat[AB_STDACT_ENABLE]= istr_const("Enable");
|
||||
bat[AB_STDACT_HIDE]= istr_const("Hide");
|
||||
bat[AB_STDACT_SET_LABEL]= istr_const("SetLabel");
|
||||
bat[AB_STDACT_SET_TEXT]= istr_const("SetText");
|
||||
bat[AB_STDACT_SET_VALUE]= istr_const("SetValue");
|
||||
bat[AB_STDACT_SHOW]= istr_const("Show");
|
||||
|
||||
return 0;
|
||||
#undef bat
|
||||
}
|
||||
|
||||
|
||||
AB_BUILTIN_ACTION
|
||||
util_string_to_builtin_action(STRING action)
|
||||
{
|
||||
return (AB_BUILTIN_ACTION)convert_string_to_int(action,
|
||||
builtin_action_table, AB_BUILTIN_ACTION_NUM_VALUES,
|
||||
AB_STDACT_UNDEF);
|
||||
}
|
||||
|
||||
|
||||
STRING
|
||||
util_builtin_action_to_string(AB_BUILTIN_ACTION action)
|
||||
{
|
||||
check_builtin_action_table_init();
|
||||
return convert_int_to_string(action,
|
||||
builtin_action_table, AB_BUILTIN_ACTION_NUM_VALUES,
|
||||
istr_const("?action?"));
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** AB_OBJECT_TYPE **
|
||||
** **
|
||||
**************************************************************************/
|
||||
/*
|
||||
* REMIND: move type conversion stuff to guide
|
||||
*/
|
||||
static BOOL obj_type_table_inited= FALSE;
|
||||
static ISTRING obj_type_table[AB_OBJECT_TYPE_NUM_VALUES+1]= {NULL};
|
||||
|
||||
#define check_obj_type_table_init() \
|
||||
(obj_type_table_inited? 0:obj_type_table_init())
|
||||
|
||||
static int
|
||||
obj_type_table_init()
|
||||
{
|
||||
#define ott obj_type_table
|
||||
obj_type_table_inited= TRUE;
|
||||
convert_fill_table(obj_type_table,
|
||||
AB_OBJECT_TYPE_NUM_VALUES, istr_const("?type?"));
|
||||
|
||||
ott[AB_TYPE_ACTION]= istr_const(":action");
|
||||
ott[AB_TYPE_ACTION_LIST]= istr_const(":action-list");
|
||||
ott[AB_TYPE_BASE_WINDOW]= istr_const(":base-window");
|
||||
ott[AB_TYPE_BUTTON]= istr_const(":button");
|
||||
ott[AB_TYPE_CHOICE]= istr_const(":choice");
|
||||
ott[AB_TYPE_COMBO_BOX]= istr_const(":combobox");
|
||||
ott[AB_TYPE_FILE_CHOOSER]= istr_const(":file-chooser");
|
||||
ott[AB_TYPE_MESSAGE]= istr_const(":message");
|
||||
ott[AB_TYPE_CONTAINER]= istr_const(":container");
|
||||
ott[AB_TYPE_DIALOG]= istr_const(":dialog");
|
||||
ott[AB_TYPE_DRAWING_AREA]= istr_const(":drawing-area");
|
||||
ott[AB_TYPE_FILE]= istr_const(":file");
|
||||
ott[AB_TYPE_MODULE]= istr_const(":module");
|
||||
ott[AB_TYPE_ITEM]= istr_const(":item");
|
||||
ott[AB_TYPE_LABEL]= istr_const(":label");
|
||||
ott[AB_TYPE_LAYERS]= istr_const(":layers");
|
||||
ott[AB_TYPE_LIST]= istr_const(":list");
|
||||
ott[AB_TYPE_MENU]= istr_const(":menu");
|
||||
ott[AB_TYPE_PROJECT]= istr_const(":project");
|
||||
ott[AB_TYPE_SEPARATOR]= istr_const(":separator");
|
||||
ott[AB_TYPE_SPIN_BOX]= istr_const(":spinbox");
|
||||
ott[AB_TYPE_SCALE]= istr_const(":scale");
|
||||
ott[AB_TYPE_TERM_PANE]= istr_const(":term-pane");
|
||||
ott[AB_TYPE_TEXT_FIELD]= istr_const(":text-field");
|
||||
ott[AB_TYPE_TEXT_PANE]= istr_const(":text-pane");
|
||||
ott[AB_TYPE_UNKNOWN]= istr_const(":unknown-type");
|
||||
|
||||
return 0;
|
||||
#undef ott
|
||||
}
|
||||
|
||||
AB_OBJECT_TYPE
|
||||
util_string_to_object_type(STRING string_type)
|
||||
{
|
||||
check_obj_type_table_init();
|
||||
return (AB_OBJECT_TYPE)convert_string_to_int(
|
||||
string_type,
|
||||
obj_type_table, AB_OBJECT_TYPE_NUM_VALUES, AB_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
STRING
|
||||
util_object_type_to_string(AB_OBJECT_TYPE type)
|
||||
{
|
||||
check_obj_type_table_init();
|
||||
return convert_int_to_string(type,
|
||||
obj_type_table, AB_OBJECT_TYPE_NUM_VALUES,
|
||||
istr_const("?type?"));
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
** **
|
||||
** AB_OBJECT_TYPE - for browser **
|
||||
** **
|
||||
******************************************************************/
|
||||
/*
|
||||
* REMIND: move type conversion stuff to guide
|
||||
*/
|
||||
static BOOL browser_obj_type_table_inited= FALSE;
|
||||
static ISTRING browser_obj_type_table[AB_OBJECT_TYPE_NUM_VALUES+1]= {NULL};
|
||||
|
||||
#define check_browser_obj_type_table_init() \
|
||||
(browser_obj_type_table_inited? 0:browser_obj_type_table_init())
|
||||
|
||||
static int
|
||||
browser_obj_type_table_init()
|
||||
{
|
||||
#define bott browser_obj_type_table
|
||||
browser_obj_type_table_inited= TRUE;
|
||||
convert_fill_table(browser_obj_type_table,
|
||||
AB_OBJECT_TYPE_NUM_VALUES, istr_const("?type?"));
|
||||
|
||||
bott[AB_TYPE_ACTION]= istr_const("ACTION");
|
||||
bott[AB_TYPE_ACTION_LIST]= istr_const("ACTION-LIST");
|
||||
bott[AB_TYPE_BASE_WINDOW]= istr_const("BASE-WINDOW");
|
||||
bott[AB_TYPE_BUTTON]= istr_const("BUTTON");
|
||||
bott[AB_TYPE_CHOICE]= istr_const("CHOICE");
|
||||
bott[AB_TYPE_COMBO_BOX]= istr_const("COMBO-BOX");
|
||||
bott[AB_TYPE_FILE_CHOOSER]= istr_const("file-chooser");
|
||||
bott[AB_TYPE_MESSAGE]= istr_const("message");
|
||||
bott[AB_TYPE_CONTAINER]= istr_const("CONTAINER");
|
||||
bott[AB_TYPE_DIALOG]= istr_const("DIALOG");
|
||||
bott[AB_TYPE_DRAWING_AREA]= istr_const("DRAWING-AREA");
|
||||
bott[AB_TYPE_MODULE]= istr_const("MODULE");
|
||||
bott[AB_TYPE_ITEM]= istr_const("ITEM");
|
||||
bott[AB_TYPE_LABEL]= istr_const("LABEL");
|
||||
bott[AB_TYPE_LAYERS]= istr_const("LAYERS");
|
||||
bott[AB_TYPE_LIST]= istr_const("LIST");
|
||||
bott[AB_TYPE_MENU]= istr_const("MENU");
|
||||
bott[AB_TYPE_PROJECT]= istr_const("PROJECT");
|
||||
bott[AB_TYPE_SEPARATOR]= istr_const("SEPARATOR");
|
||||
bott[AB_TYPE_SPIN_BOX]= istr_const("SPIN-BOX");
|
||||
bott[AB_TYPE_SCALE]= istr_const("SCALE");
|
||||
bott[AB_TYPE_TERM_PANE]= istr_const("TERM-PANE");
|
||||
bott[AB_TYPE_TEXT_FIELD]= istr_const("TEXT-FIELD");
|
||||
bott[AB_TYPE_TEXT_PANE]= istr_const("TEXT-PANE");
|
||||
bott[AB_TYPE_UNKNOWN]= istr_const("UNKNOWN-TYPE");
|
||||
|
||||
return 0;
|
||||
#undef bott
|
||||
}
|
||||
|
||||
AB_OBJECT_TYPE
|
||||
util_browser_string_to_object_type(STRING string_type)
|
||||
{
|
||||
check_browser_obj_type_table_init();
|
||||
return (AB_OBJECT_TYPE)convert_string_to_int(
|
||||
string_type,
|
||||
browser_obj_type_table, AB_OBJECT_TYPE_NUM_VALUES, AB_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
STRING
|
||||
util_object_type_to_browser_string(AB_OBJECT_TYPE type)
|
||||
{
|
||||
check_browser_obj_type_table_init();
|
||||
return convert_int_to_string(type,
|
||||
browser_obj_type_table, AB_OBJECT_TYPE_NUM_VALUES,
|
||||
istr_const("?type?"));
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** AB_WHEN **
|
||||
** **
|
||||
**************************************************************************/
|
||||
/*
|
||||
* REMIND: move when stuff to libguide
|
||||
*/
|
||||
static ISTRING when_table[AB_WHEN_NUM_VALUES];
|
||||
static BOOL when_table_inited= FALSE;
|
||||
|
||||
static int
|
||||
when_table_init()
|
||||
{
|
||||
#define wt when_table
|
||||
int i= 0;
|
||||
|
||||
when_table_inited= TRUE;
|
||||
convert_fill_table(when_table, AB_WHEN_NUM_VALUES,
|
||||
istr_const("?when?"));
|
||||
|
||||
wt[AB_WHEN_ACTION1]= istr_const("Action1Activated");
|
||||
wt[AB_WHEN_ACTION2]= istr_const("Action2Activated");
|
||||
wt[AB_WHEN_ACTION3]= istr_const("Action3Activated");
|
||||
wt[AB_WHEN_ACTIVATED]= istr_const("Activate");
|
||||
wt[AB_WHEN_AFTER_CREATED]= istr_const("AfterCreate");
|
||||
wt[AB_WHEN_AFTER_RESIZED]= istr_const("AfterResize");
|
||||
wt[AB_WHEN_BEFORE_POST_MENU]= istr_const("BeforePostMenu");
|
||||
wt[AB_WHEN_BEFORE_TEXT_CHANGED]=istr_const("BeforeTextChanged");
|
||||
wt[AB_WHEN_CANCEL]= istr_const("CancelActivated");
|
||||
wt[AB_WHEN_DESTROYED]= istr_const("Destroy");
|
||||
wt[AB_WHEN_DRAGGED]= istr_const("Dragged");
|
||||
wt[AB_WHEN_DRAGGED_FROM]= istr_const("DraggedFrom");
|
||||
wt[AB_WHEN_DOUBLE_CLICKED_ON]= istr_const("DoubleClick");
|
||||
wt[AB_WHEN_DROPPED_ON]= istr_const("DroppedOn");
|
||||
wt[AB_WHEN_HIDDEN]= istr_const("Hidden");
|
||||
wt[AB_WHEN_ITEM_SELECTED]= istr_const("ItemSelected");
|
||||
wt[AB_WHEN_OK]= istr_const("OkActivated");
|
||||
wt[AB_WHEN_REPAINT_NEEDED]= istr_const("NeedRepaint");
|
||||
wt[AB_WHEN_POPPED_DOWN]= istr_const("Popdown");
|
||||
wt[AB_WHEN_POPPED_UP]= istr_const("Popup");
|
||||
wt[AB_WHEN_SESSION_RESTORE]= istr_const("SessionRestore");
|
||||
wt[AB_WHEN_SESSION_SAVE]= istr_const("SessionSave");
|
||||
wt[AB_WHEN_SHOWN]= istr_const("Shown");
|
||||
wt[AB_WHEN_TEXT_CHANGED]= istr_const("TextChanged");
|
||||
wt[AB_WHEN_TOOLTALK_DO_COMMAND]=istr_const("ToolTalkDoCommand");
|
||||
wt[AB_WHEN_TOOLTALK_GET_STATUS]=istr_const("ToolTalkGetStatus");
|
||||
wt[AB_WHEN_TOOLTALK_PAUSE_RESUME]=istr_const("ToolTalkPauseResume");
|
||||
wt[AB_WHEN_TOOLTALK_QUIT]=istr_const("ToolTalkQuit");
|
||||
wt[AB_WHEN_VALUE_CHANGED]=istr_const("ValueChanged");
|
||||
wt[AB_WHEN_UNDEF]= istr_const("Undef");
|
||||
|
||||
return 0;
|
||||
#undef wt
|
||||
}
|
||||
|
||||
#define check_when_table_init() \
|
||||
if (!when_table_inited) {when_table_init();}
|
||||
|
||||
|
||||
AB_WHEN
|
||||
util_string_to_when(STRING when_string)
|
||||
{
|
||||
check_when_table_init();
|
||||
return (AB_WHEN)convert_string_to_int(
|
||||
when_string,
|
||||
when_table, AB_WHEN_NUM_VALUES, AB_WHEN_UNDEF);
|
||||
}
|
||||
|
||||
|
||||
STRING
|
||||
util_when_to_string(AB_WHEN when)
|
||||
{
|
||||
check_when_table_init();
|
||||
return convert_int_to_string(when,
|
||||
when_table, AB_WHEN_NUM_VALUES, istr_const("?when?"));
|
||||
}
|
||||
|
||||
/******************* AB_ALIGNMENT **************************************/
|
||||
|
||||
static ISTRING align_tab[AB_ALIGNMENT_NUM_VALUES];
|
||||
static BOOL align_tab_inited= FALSE;
|
||||
#define align_tab_check_init() (align_tab_inited? 0:align_tab_init())
|
||||
|
||||
static int
|
||||
align_tab_init()
|
||||
{
|
||||
#define at align_tab
|
||||
align_tab_inited= TRUE;
|
||||
convert_fill_table(at, ARRAY_SIZE(at), istr_const(NULL));
|
||||
|
||||
at[AB_ALIGN_TOP]= istr_const(":top");
|
||||
at[AB_ALIGN_LEFT]= istr_const(":left");
|
||||
at[AB_ALIGN_RIGHT]= istr_const(":right");
|
||||
at[AB_ALIGN_BOTTOM]= istr_const(":bottom");
|
||||
at[AB_ALIGN_CENTER]= istr_const(":centers");
|
||||
at[AB_ALIGN_LABELS]= istr_const(":labels");
|
||||
|
||||
return 0;
|
||||
#undef at
|
||||
}
|
||||
|
||||
AB_ALIGNMENT
|
||||
util_string_to_alignment(STRING align_string)
|
||||
{
|
||||
align_tab_check_init();
|
||||
return (AB_ALIGNMENT)convert_string_to_int(align_string,
|
||||
align_tab, ARRAY_SIZE(align_tab), -1);
|
||||
}
|
||||
|
||||
STRING
|
||||
util_alignment_to_string(AB_ALIGNMENT align)
|
||||
{
|
||||
align_tab_check_init();
|
||||
return convert_int_to_string(align,
|
||||
align_tab, ARRAY_SIZE(align_tab), istr_const(NULL));
|
||||
}
|
||||
|
||||
/******************* AB_LABEL_TYPE **************************************/
|
||||
static ISTRING label_type_tab[AB_LABEL_TYPE_NUM_VALUES];
|
||||
static BOOL label_type_tab_inited= FALSE;
|
||||
#define label_type_tab_check_init() \
|
||||
(label_type_tab_inited? 0:label_type_tab_init())
|
||||
|
||||
static int
|
||||
label_type_tab_init()
|
||||
{
|
||||
#define ltt label_type_tab
|
||||
label_type_tab_inited= TRUE;
|
||||
|
||||
ltt[AB_LABEL_ARROW_DOWN]= istr_const(":arrow-down");
|
||||
ltt[AB_LABEL_ARROW_LEFT]= istr_const(":arrow-left");
|
||||
ltt[AB_LABEL_ARROW_RIGHT]= istr_const(":arrow-right");
|
||||
ltt[AB_LABEL_ARROW_UP]= istr_const(":arrow_up");
|
||||
ltt[AB_LABEL_DRAWN]= istr_const(":drawn");
|
||||
ltt[AB_LABEL_GLYPH]= istr_const(":glyph");
|
||||
ltt[AB_LABEL_STRING]= istr_const(":string");
|
||||
|
||||
return 0;
|
||||
#undef ltt
|
||||
}
|
||||
|
||||
AB_LABEL_TYPE
|
||||
util_string_to_label_type(STRING type_string)
|
||||
{
|
||||
label_type_tab_check_init();
|
||||
return (AB_LABEL_TYPE)convert_string_to_int(type_string,
|
||||
label_type_tab, ARRAY_SIZE(label_type_tab), -1);
|
||||
}
|
||||
|
||||
STRING
|
||||
util_label_type_to_string(AB_LABEL_TYPE label_type)
|
||||
{
|
||||
label_type_tab_check_init();
|
||||
return convert_int_to_string(label_type,
|
||||
label_type_tab, ARRAY_SIZE(label_type_tab), NULL);
|
||||
}
|
||||
|
||||
/******************* AB_BUTTON_TYPE **************************************/
|
||||
static ISTRING button_type_tab[AB_BUTTON_TYPE_NUM_VALUES];
|
||||
static BOOL button_type_tab_inited= FALSE;
|
||||
#define button_type_tab_check_init() \
|
||||
(button_type_tab_inited? 0:button_type_tab_init())
|
||||
|
||||
static int
|
||||
button_type_tab_init()
|
||||
{
|
||||
#define btt button_type_tab
|
||||
button_type_tab_inited= TRUE;
|
||||
|
||||
btt[AB_BUT_PUSH]= istr_const(":normal");
|
||||
|
||||
return 0;
|
||||
#undef btt
|
||||
}
|
||||
|
||||
AB_BUTTON_TYPE
|
||||
util_string_to_button_type(STRING type_string)
|
||||
{
|
||||
button_type_tab_check_init();
|
||||
return (AB_BUTTON_TYPE)convert_string_to_int(type_string,
|
||||
button_type_tab, ARRAY_SIZE(button_type_tab), -1);
|
||||
}
|
||||
|
||||
STRING
|
||||
util_button_type_to_string(AB_BUTTON_TYPE type)
|
||||
{
|
||||
button_type_tab_check_init();
|
||||
return convert_int_to_string(type,
|
||||
button_type_tab, ARRAY_SIZE(button_type_tab), NULL);
|
||||
}
|
||||
|
||||
|
||||
/******************* AB_ARG_CLASS **************************************/
|
||||
static ISTRING arg_class_tab[AB_ARG_CLASS_NUM_VALUES];
|
||||
static BOOL arg_class_tab_inited= FALSE;
|
||||
#define arg_class_tab_check_init() \
|
||||
(arg_class_tab_inited? 0:arg_class_tab_init())
|
||||
|
||||
static int
|
||||
arg_class_tab_init()
|
||||
{
|
||||
#define att arg_class_tab
|
||||
arg_class_tab_inited= TRUE;
|
||||
|
||||
att[AB_ARG_CLASS_UNDEF]= istr_const(":undef");
|
||||
att[AB_ARG_CLASS_ACCELERATOR]= istr_const(":attachment");
|
||||
att[AB_ARG_CLASS_COLOR]= istr_const(":color");
|
||||
att[AB_ARG_CLASS_GEOMETRY]= istr_const(":geometry");
|
||||
att[AB_ARG_CLASS_GLYPH]= istr_const(":value");
|
||||
att[AB_ARG_CLASS_NON_GLYPH_LABEL]= istr_const(":label-alignment");
|
||||
att[AB_ARG_CLASS_OTHER_STRING]= istr_const(":label-glyph");
|
||||
att[AB_ARG_CLASS_OTHER]= istr_const(":other");
|
||||
att[AB_ARG_CLASS_OTHER]= istr_const(":other");
|
||||
|
||||
return 0;
|
||||
#undef att
|
||||
}
|
||||
|
||||
AB_ARG_CLASS
|
||||
util_string_to_arg_class(STRING arg_class_string)
|
||||
{
|
||||
arg_class_tab_check_init();
|
||||
return (AB_ARG_CLASS)convert_string_to_int(arg_class_string,
|
||||
arg_class_tab, ARRAY_SIZE(arg_class_tab), -1);
|
||||
}
|
||||
|
||||
STRING
|
||||
util_arg_class_to_string(AB_ARG_CLASS arg_class)
|
||||
{
|
||||
arg_class_tab_check_init();
|
||||
return convert_int_to_string(arg_class,
|
||||
arg_class_tab, ARRAY_SIZE(arg_class_tab), NULL);
|
||||
}
|
||||
|
||||
|
||||
AB_ARG_CLASS_FLAGS
|
||||
util_arg_class_to_flag(AB_ARG_CLASS arg_class)
|
||||
{
|
||||
AB_ARG_CLASS_FLAGS class_flag = AB_ARG_CLASS_FLAGS_NONE;
|
||||
|
||||
if ((arg_class < 1) || (arg_class > AB_ARG_CLASS_NUM_VALUES))
|
||||
{
|
||||
return (AB_ARG_CLASS_FLAGS)0;
|
||||
}
|
||||
class_flag = (AB_ARG_CLASS_FLAGS)(0x01<<(((unsigned)arg_class)-1));
|
||||
|
||||
assert(arg_class == util_flag_to_arg_class(class_flag));
|
||||
return class_flag;
|
||||
}
|
||||
|
||||
|
||||
AB_ARG_CLASS
|
||||
util_flag_to_arg_class(AB_ARG_CLASS_FLAGS arg_class_flag)
|
||||
{
|
||||
int i = 0;
|
||||
AB_ARG_CLASS arg_class = AB_ARG_CLASS_UNDEF;
|
||||
|
||||
for (i = 1; i < AB_ARG_CLASS_NUM_VALUES; ++i)
|
||||
{
|
||||
if ((arg_class_flag & 0x01) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
arg_class_flag >>= 1;
|
||||
}
|
||||
if (i < AB_ARG_CLASS_NUM_VALUES)
|
||||
{
|
||||
arg_class = (AB_ARG_CLASS)i;
|
||||
}
|
||||
|
||||
return arg_class;
|
||||
}
|
||||
|
||||
|
||||
/******************* AB_ARG_TYPE **************************************/
|
||||
static ISTRING arg_type_tab[AB_ARG_TYPE_NUM_VALUES];
|
||||
static BOOL arg_type_tab_inited= FALSE;
|
||||
#define arg_type_tab_check_init() (arg_type_tab_inited? 0:arg_type_tab_init())
|
||||
|
||||
static int
|
||||
arg_type_tab_init()
|
||||
{
|
||||
#define att arg_type_tab
|
||||
arg_type_tab_inited= TRUE;
|
||||
|
||||
att[AB_ARG_BOOLEAN]= istr_const(":boolean");
|
||||
att[AB_ARG_CALLBACK]= istr_const(":callback");
|
||||
att[AB_ARG_FLOAT]= istr_const(":float");
|
||||
att[AB_ARG_INT]= istr_const(":integer");
|
||||
att[AB_ARG_LITERAL]= istr_const(":literal");
|
||||
att[AB_ARG_STRING]= istr_const(":string");
|
||||
att[AB_ARG_VOID_PTR]= istr_const(":void");
|
||||
|
||||
return 0;
|
||||
#undef att
|
||||
}
|
||||
|
||||
AB_ARG_TYPE
|
||||
util_string_to_arg_type(STRING arg_type_string)
|
||||
{
|
||||
arg_type_tab_check_init();
|
||||
return (AB_ARG_TYPE)convert_string_to_int(arg_type_string,
|
||||
arg_type_tab, ARRAY_SIZE(arg_type_tab), -1);
|
||||
}
|
||||
|
||||
STRING
|
||||
util_arg_type_to_string(AB_ARG_TYPE arg_type)
|
||||
{
|
||||
arg_type_tab_check_init();
|
||||
return convert_int_to_string(arg_type,
|
||||
arg_type_tab, ARRAY_SIZE(arg_type_tab), NULL);
|
||||
}
|
||||
|
||||
/******************* AB_TEXT_TYPE **************************************/
|
||||
AB_TEXT_TYPE
|
||||
util_string_to_text_type(STRING s_text_type)
|
||||
{
|
||||
return AB_TEXT_ALPHANUMERIC;
|
||||
}
|
||||
|
||||
STRING
|
||||
util_text_type_to_string(AB_TEXT_TYPE tt)
|
||||
{
|
||||
return "text-type-not-implemented";
|
||||
}
|
||||
|
||||
/******************* AB_CHOICE_TYPE **************************************/
|
||||
AB_CHOICE_TYPE
|
||||
util_string_to_choice_type(STRING s_choice_type)
|
||||
{
|
||||
return AB_CHOICE_EXCLUSIVE;
|
||||
}
|
||||
|
||||
STRING
|
||||
util_choice_type_to_string(AB_CHOICE_TYPE choice_type)
|
||||
{
|
||||
return ":choice-type-not-implemented";
|
||||
}
|
||||
|
||||
/******************* AB_ORIENTATION **************************************/
|
||||
AB_ORIENTATION
|
||||
util_string_to_orientation(STRING s_orient)
|
||||
{
|
||||
return AB_ORIENT_HORIZONTAL;
|
||||
}
|
||||
|
||||
STRING
|
||||
util_orientation_to_string(AB_ORIENTATION orient)
|
||||
{
|
||||
return "orientation-not-implemented";
|
||||
}
|
||||
|
||||
/******************* AB_MENU_TYPE **************************************/
|
||||
AB_MENU_TYPE
|
||||
util_string_to_menu_type(STRING s_menu_type)
|
||||
{
|
||||
return AB_MENU_PULLDOWN;
|
||||
}
|
||||
|
||||
STRING
|
||||
util_menu_type_to_string(AB_MENU_TYPE type)
|
||||
{
|
||||
return "menu-type-not-implemented";
|
||||
}
|
||||
|
||||
/******************* AB_GROUP_TYPE **************************************/
|
||||
AB_GROUP_TYPE
|
||||
util_string_to_group_type(STRING s_group)
|
||||
{
|
||||
return AB_GROUP_IGNORE;
|
||||
}
|
||||
|
||||
STRING
|
||||
util_group_type_to_string(AB_GROUP_TYPE group)
|
||||
{
|
||||
return "group-type-not-implemented";
|
||||
}
|
||||
|
||||
/******************* AB_OBJECT_STATE **************************************/
|
||||
AB_OBJECT_STATE
|
||||
util_string_to_object_state(STRING s_state)
|
||||
{
|
||||
return AB_STATE_ACTIVE;
|
||||
}
|
||||
|
||||
STRING
|
||||
util_object_state_to_string(AB_OBJECT_STATE state)
|
||||
{
|
||||
return "object-state-not-implemented";
|
||||
}
|
||||
|
||||
/******************* AB_CONTAINER_TYPE **************************************/
|
||||
|
||||
static ISTRING container_tab[AB_CONTAINER_TYPE_NUM_VALUES];
|
||||
static BOOL container_tab_inited= FALSE;
|
||||
#define container_tab_check_init() (container_tab_inited? 0:container_tab_init())
|
||||
|
||||
static int
|
||||
container_tab_init()
|
||||
{
|
||||
#define cont container_tab
|
||||
container_tab_inited= TRUE;
|
||||
convert_fill_table(cont, ARRAY_SIZE(cont), istr_const(NULL));
|
||||
|
||||
cont[AB_CONT_ABSOLUTE]= istr_const(":absolute");
|
||||
cont[AB_CONT_GROUP]= istr_const(":group");
|
||||
cont[AB_CONT_MAIN_WINDOW]= istr_const(":main_window");
|
||||
cont[AB_CONT_MENU_BAR]= istr_const(":menu_bar");
|
||||
cont[AB_CONT_PANED]= istr_const(":paned");
|
||||
cont[AB_CONT_RELATIVE]= istr_const(":relative");
|
||||
cont[AB_CONT_SCROLLED_WINDOW]= istr_const(":scrolled_window");
|
||||
cont[AB_CONT_ROW_COLUMN]= istr_const(":row_column");
|
||||
return 0;
|
||||
#undef cont
|
||||
}
|
||||
|
||||
AB_CONTAINER_TYPE
|
||||
util_string_to_container_type(STRING container_string)
|
||||
{
|
||||
container_tab_check_init();
|
||||
return
|
||||
(AB_CONTAINER_TYPE)convert_string_to_int(container_string,
|
||||
container_tab, ARRAY_SIZE(container_tab),
|
||||
-1);
|
||||
}
|
||||
|
||||
STRING
|
||||
util_container_type_to_string(AB_CONTAINER_TYPE type)
|
||||
{
|
||||
container_tab_check_init();
|
||||
return convert_int_to_string(type,
|
||||
container_tab, ARRAY_SIZE(container_tab), istr_const(NULL));
|
||||
}
|
||||
|
||||
|
||||
/******************* AB_ITEM_TYPE **************************************/
|
||||
|
||||
static ISTRING item_tab[AB_ITEM_TYPE_NUM_VALUES];
|
||||
static BOOL item_tab_inited= FALSE;
|
||||
#define item_tab_check_init() (item_tab_inited? 0:item_tab_init())
|
||||
|
||||
static int
|
||||
item_tab_init()
|
||||
{
|
||||
#define it item_tab
|
||||
item_tab_inited= TRUE;
|
||||
convert_fill_table(it, ARRAY_SIZE(it), istr_const(NULL));
|
||||
|
||||
it[AB_ITEM_FOR_CHOICE]= istr_const(":choice_item");
|
||||
it[AB_ITEM_FOR_LIST]= istr_const(":list_item");
|
||||
it[AB_ITEM_FOR_MENU]= istr_const(":menu_item");
|
||||
return 0;
|
||||
#undef it
|
||||
}
|
||||
|
||||
AB_ITEM_TYPE
|
||||
util_string_to_item_type(STRING item_string)
|
||||
{
|
||||
item_tab_check_init();
|
||||
return
|
||||
(AB_ITEM_TYPE)convert_string_to_int(item_string,
|
||||
item_tab, ARRAY_SIZE(item_tab), -1);
|
||||
}
|
||||
|
||||
STRING
|
||||
util_item_type_to_string(AB_ITEM_TYPE type)
|
||||
{
|
||||
item_tab_check_init();
|
||||
return convert_int_to_string(type,
|
||||
item_tab, ARRAY_SIZE(item_tab), istr_const(NULL));
|
||||
}
|
||||
|
||||
/******************* AB_LABEL_ALIGN_TYPE **************************************/
|
||||
|
||||
/*
|
||||
static ISTRING lalign_tab[AB_LABEL_ALIGN_TYPE_NUM_VALUES];
|
||||
static BOOL lalign_tab_inited= FALSE;
|
||||
#define lalign_tab_check_init() (lalign_tab_inited? 0:lalign_tab_init())
|
||||
|
||||
static int
|
||||
lalign_tab_init()
|
||||
{
|
||||
#define lat lalign_tab
|
||||
lalign_tab_inited= TRUE;
|
||||
convert_fill_table(lat, ARRAY_SIZE(lat), istr_const(NULL));
|
||||
|
||||
lat[AB_LABEL_ALIGN_RIGHT]= istr_const(":right");
|
||||
lat[AB_LABEL_ALIGN_CENTER]= istr_const(":center");
|
||||
lat[AB_LABEL_ALIGN_LEFT]= istr_const(":left");
|
||||
return 0;
|
||||
#undef lat
|
||||
}
|
||||
|
||||
AB_LABEL_ALIGN_TYPE
|
||||
ab_string_to_label_align_type(STRING lalign_string)
|
||||
{
|
||||
lalign_tab_check_init();
|
||||
return
|
||||
(AB_LABEL_ALIGN_TYPE)convert_string_to_int(lalign_string,
|
||||
lalign_tab, ARRAY_SIZE(lalign_tab), -1);
|
||||
}
|
||||
|
||||
STRING
|
||||
ab_label_align_type_to_string(AB_LABEL_ALIGN_TYPE type)
|
||||
{
|
||||
lalign_tab_check_init();
|
||||
return convert_int_to_string(type,
|
||||
lalign_tab, ARRAY_SIZE(lalign_tab), istr_const(NULL));
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
STRING
|
||||
util_cvt_bool_to_string(BOOL bool_value, STRING buf, int buf_size)
|
||||
{
|
||||
if (buf_size < 1)
|
||||
{
|
||||
goto epilogue;
|
||||
}
|
||||
|
||||
if (bool_value)
|
||||
{
|
||||
strncpy(buf, "True", buf_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(buf, "False", buf_size);
|
||||
}
|
||||
buf[buf_size-1]= 0;
|
||||
|
||||
epilogue:
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* returns identifier-legal string that can be used for file names,
|
||||
* et cetera.
|
||||
*/
|
||||
STRING
|
||||
util_os_type_to_ident(AB_OS_TYPE osType)
|
||||
{
|
||||
STRING typeString = NULL;
|
||||
|
||||
switch (osType)
|
||||
{
|
||||
case AB_OS_AIX: typeString = "aix"; break;
|
||||
case AB_OS_HPUX: typeString = "hpux"; break;
|
||||
case AB_OS_SUNOS: typeString = "sunos"; break;
|
||||
case AB_OS_UXP: typeString = "uxp"; break;
|
||||
case AB_OS_OSF1: typeString = "osf1"; break;
|
||||
|
||||
#ifdef USL
|
||||
/*
|
||||
* The USL specific changes were made ifdef USL due to time constraint
|
||||
* They should be removed in the next release
|
||||
*/
|
||||
case AB_OS_UNIXWARE: typeString = "unixware"; break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return typeString;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns a nicely formatted OS name (even on not-so-nice OSes!)
|
||||
*/
|
||||
STRING
|
||||
util_os_type_to_string(AB_OS_TYPE osType)
|
||||
{
|
||||
STRING nameString = NULL;
|
||||
|
||||
switch (osType)
|
||||
{
|
||||
case AB_OS_AIX: nameString = "AIX"; break;
|
||||
case AB_OS_HPUX: nameString = "HP-UX"; break;
|
||||
case AB_OS_SUNOS: nameString = "SunOS"; break;
|
||||
case AB_OS_UXP: nameString = "UXP"; break;
|
||||
case AB_OS_OSF1: nameString = "OSF/1"; break;
|
||||
}
|
||||
|
||||
return nameString;
|
||||
}
|
||||
|
||||
135
cde/programs/dtappbuilder/src/libAButil/util_ds.c
Normal file
135
cde/programs/dtappbuilder/src/libAButil/util_ds.c
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* $XConsortium: util_ds.c /main/4 1995/11/06 18:53:21 rswiston $
|
||||
*
|
||||
* @(#)util_ds.c 1.3 23 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <ab_private/util_ds.h>
|
||||
|
||||
/***************************************************
|
||||
* Linked List and Active Set ADT implementations
|
||||
***************************************************/
|
||||
|
||||
struct _LListStruct {
|
||||
void *value;
|
||||
struct _LListStruct *next;
|
||||
};
|
||||
|
||||
static void llist_delete_next(
|
||||
LList llist
|
||||
);
|
||||
|
||||
extern LList
|
||||
util_llist_create(
|
||||
void
|
||||
)
|
||||
{
|
||||
LList tmp = (LList) XtMalloc(sizeof(struct _LListStruct));
|
||||
|
||||
tmp->next = NULL;
|
||||
return(tmp);
|
||||
}
|
||||
|
||||
extern void
|
||||
util_llist_destroy(
|
||||
LList llist
|
||||
)
|
||||
{
|
||||
while (llist != NULL)
|
||||
{
|
||||
LList tmp = llist;
|
||||
|
||||
llist = llist->next;
|
||||
XtFree((char *)tmp);
|
||||
}
|
||||
}
|
||||
|
||||
extern void
|
||||
util_llist_insert_after(
|
||||
LList llist,
|
||||
void *cl_data
|
||||
)
|
||||
{
|
||||
LList tmp = util_llist_create();
|
||||
|
||||
tmp->value = cl_data;
|
||||
tmp->next = llist->next;
|
||||
llist->next = tmp;
|
||||
}
|
||||
|
||||
extern LList
|
||||
util_llist_find(
|
||||
LList llist,
|
||||
void *cl_data
|
||||
)
|
||||
{
|
||||
ASet prev;
|
||||
ASet trav;
|
||||
|
||||
for (prev = llist, trav = llist->next; trav != NULL;
|
||||
prev = trav, trav = trav->next)
|
||||
if (trav->value == cl_data)
|
||||
return(prev);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
extern void
|
||||
util_llist_delete(
|
||||
LList llist,
|
||||
void *cl_data
|
||||
)
|
||||
{
|
||||
LList tmp = util_llist_find(llist, cl_data);
|
||||
|
||||
if (tmp != NULL)
|
||||
llist_delete_next(tmp);
|
||||
}
|
||||
|
||||
static void
|
||||
llist_delete_next(
|
||||
LList llist
|
||||
)
|
||||
{
|
||||
LList tmp = llist->next;
|
||||
|
||||
if (tmp != NULL)
|
||||
{
|
||||
llist->next = tmp->next;
|
||||
XtFree((char *)tmp);
|
||||
}
|
||||
}
|
||||
|
||||
extern void
|
||||
util_llist_iterate(
|
||||
LList llist,
|
||||
LListIterFn fn
|
||||
)
|
||||
{
|
||||
for (llist = llist->next; llist != NULL; llist = llist->next)
|
||||
(*fn)(llist->value);
|
||||
}
|
||||
|
||||
extern void
|
||||
util_aset_add(
|
||||
ASet aset,
|
||||
void *cl_data
|
||||
)
|
||||
{
|
||||
if (util_llist_find(aset, cl_data) == NULL)
|
||||
util_llist_insert_after(aset, cl_data);
|
||||
}
|
||||
72
cde/programs/dtappbuilder/src/libAButil/util_ds.h
Normal file
72
cde/programs/dtappbuilder/src/libAButil/util_ds.h
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: util_ds.h /main/4 1995/11/06 18:53:31 rswiston $
|
||||
*
|
||||
* @(#)util_ds.h 1.1 19 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _UTIL_DS_H_
|
||||
#define _UTIL_DS_H_
|
||||
/*
|
||||
* util_ds.h - LList and ASet ADTs
|
||||
*/
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
typedef struct _LListStruct *LList;
|
||||
typedef void (*LListIterFn)(void *cl_data);
|
||||
|
||||
#define ASet LList
|
||||
#define ASetIterFn LListIterFn
|
||||
|
||||
|
||||
/*******************************
|
||||
* LList and ASet ADT operations
|
||||
*******************************/
|
||||
|
||||
extern LList util_llist_create(
|
||||
void
|
||||
);
|
||||
extern void util_llist_destroy(
|
||||
LList llist
|
||||
);
|
||||
extern void util_llist_insert_after(
|
||||
LList llist,
|
||||
void *cl_data
|
||||
);
|
||||
extern LList util_llist_find(
|
||||
LList llist,
|
||||
void *cl_data
|
||||
);
|
||||
extern void util_llist_delete(
|
||||
LList llist,
|
||||
void *cl_data
|
||||
);
|
||||
extern void util_llist_iterate(
|
||||
LList llist,
|
||||
LListIterFn fn
|
||||
);
|
||||
|
||||
#define util_aset_create util_llist_create
|
||||
#define util_aset_destroy util_llist_destroy
|
||||
#define util_aset_iterate util_llist_iterate
|
||||
#define util_aset_remove util_llist_delete
|
||||
|
||||
extern void util_aset_add(
|
||||
ASet aset,
|
||||
void *cl_data
|
||||
);
|
||||
|
||||
#endif /* _UTIL_DS_H_ */
|
||||
154
cde/programs/dtappbuilder/src/libAButil/util_err.c
Normal file
154
cde/programs/dtappbuilder/src/libAButil/util_err.c
Normal file
@@ -0,0 +1,154 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: util_err.c /main/4 1995/11/06 18:53:42 rswiston $
|
||||
*
|
||||
* @(#)util_err.c 1.7 09 Jan 1995 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* File: util_err.c
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <ab_private/util_err.h>
|
||||
#include "utilP.h"
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Private Function Declarations **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Data **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Function Definitions **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
STRING
|
||||
util_err_string(int errCode)
|
||||
{
|
||||
STRING err = NULL;
|
||||
|
||||
switch (errCode)
|
||||
{
|
||||
case ERR_INTERNAL:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 4, "Internal error");
|
||||
break;
|
||||
case ERR_RECURSION:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 5, "Recursive function calls");
|
||||
break;
|
||||
case ERR_NOT_ALLOWED:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 6, "Permission denied");
|
||||
break;
|
||||
case ERR_DATA_SPACE_FULL:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 8, "Data space is full");
|
||||
break;
|
||||
case ERR_BUFFER_TOO_SMALL:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 9, "Buffer is too small");
|
||||
break;
|
||||
case ERR_NOT_IMPLEMENTED:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 10, "Functionality is not implemented");
|
||||
break;
|
||||
case ERR_NOT_INITIALIZED:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 11, "Not initialized");
|
||||
break;
|
||||
case ERR_CLIENT:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 12, "Client error");
|
||||
break;
|
||||
case ERR_NOT_FOUND:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 13, "Not found");
|
||||
break;
|
||||
case ERR_DUPLICATE_KEY:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 14, "Duplicate key");
|
||||
break;
|
||||
case ERR_BAD_PARAM:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 15, "Bad parameter");
|
||||
break;
|
||||
case ERR_IO:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 16, "I/O error");
|
||||
break;
|
||||
case ERR_FILE_NOT_FOUND:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 17, "File not found");
|
||||
break;
|
||||
case ERR_OPEN:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 18, "Could not open file");
|
||||
break;
|
||||
case ERR_WRITE:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 19, "Could not write to file");
|
||||
break;
|
||||
case ERR_READ:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 20, "Could not read file");
|
||||
break;
|
||||
case ERR_EOF:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 21, "End of file");
|
||||
break;
|
||||
case ERR_BAD_FILE_FORMAT:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 22, "Bad file format");
|
||||
break;
|
||||
case ERR_RENAME:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 23, "Could not rename file");
|
||||
break;
|
||||
case ERR_MEMORY:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 24, "Memory error");
|
||||
break;
|
||||
case ERR_NO_MEMORY:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 25, "No memory");
|
||||
break;
|
||||
case ERR_MEMORY_CORRUPT:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 26, "Memory is corrupt");
|
||||
break;
|
||||
case ERR_MULTIPLE_FREE:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 27, "Multiple free of memory");
|
||||
break;
|
||||
case ERR_READ_ONLY:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 28, "Read-only file");
|
||||
break;
|
||||
case ERR_BACKUP:
|
||||
err= catgets(UTIL_MESSAGE_CATD, UTIL_MESSAGE_SET, 29, "Could not backup file");
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* An error has already occurred. Don't return NULL and cause a
|
||||
* core dump!
|
||||
*/
|
||||
return err == NULL?"":err;
|
||||
}
|
||||
|
||||
int
|
||||
util_print_error(
|
||||
int errCode,
|
||||
STRING string
|
||||
)
|
||||
{
|
||||
STRING errmsg = NULL;
|
||||
|
||||
errmsg = util_err_string(errCode);
|
||||
if (string)
|
||||
util_printf_err("%s: %s\n", string, errmsg);
|
||||
else
|
||||
util_printf_err("%s\n", errmsg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
88
cde/programs/dtappbuilder/src/libAButil/util_err.h
Normal file
88
cde/programs/dtappbuilder/src/libAButil/util_err.h
Normal file
@@ -0,0 +1,88 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: util_err.h /main/4 1995/11/06 18:53:55 rswiston $
|
||||
*
|
||||
* @(#)util_err.h 1.14 11 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ABUTIL_UTIL_ERR_H_
|
||||
#define _ABUTIL_UTIL_ERR_H_
|
||||
/*
|
||||
* util_err.h - error codes
|
||||
*
|
||||
* All error codes are negative. They are numbered in
|
||||
* groups (general, file i/o, memory, ...).
|
||||
*
|
||||
* When returning an error, use the most specific error code.
|
||||
*/
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#include <ab_private/AB.h>
|
||||
#include <ab/util_types.h>
|
||||
|
||||
#define OK (0) /* smooth sailing */
|
||||
#define ERR (-1) /* generic error */
|
||||
|
||||
#define ERR_INTERNAL (-100) /* internal errors */
|
||||
#define ERR_RECURSION (-101) /* recursion not allowed! */
|
||||
#define ERR_DATA_SPACE_FULL (-102)
|
||||
#define ERR_BUFFER_TOO_SMALL (-103)
|
||||
#define ERR_NOT_IMPLEMENTED (-104)
|
||||
#define ERR_NOT_INITIALIZED (-105)
|
||||
|
||||
#define ERR_CLIENT (-200) /* errors on the part of the caller */
|
||||
#define ERR_NOT_ALLOWED (-201)
|
||||
#define ERR_NOT_FOUND (-202) /* search failed */
|
||||
#define ERR_DUPLICATE_KEY (-203) /* insert of duplicate key */
|
||||
#define ERR_BAD_PARAM (-220) /* bad parameter */
|
||||
#define ERR_BAD_PARAM1 (-221) /* parameter #1 bad */
|
||||
#define ERR_BAD_PARAM2 (-222)
|
||||
#define ERR_BAD_PARAM3 (-223)
|
||||
#define ERR_BAD_PARAM4 (-224)
|
||||
#define ERR_BAD_PARAM5 (-225)
|
||||
#define ERR_BAD_PARAM6 (-226)
|
||||
#define ERR_BAD_PARAM7 (-227)
|
||||
#define ERR_BAD_PARAM8 (-228)
|
||||
#define ERR_BAD_PARAM9 (-229)
|
||||
|
||||
#define ERR_IO (-300) /* I/O errors */
|
||||
#define ERR_FILE_NOT_FOUND (-301)
|
||||
#define ERR_OPEN (-302)
|
||||
#define ERR_WRITE (-303)
|
||||
#define ERR_READ (-304)
|
||||
#define ERR_EOF (-305)
|
||||
#define ERR_BAD_FILE_FORMAT (-306)
|
||||
#define ERR_RENAME (-307)
|
||||
#define ERR_READ_ONLY (-308)
|
||||
#define ERR_BACKUP (-309)
|
||||
|
||||
#define ERR_MEMORY (-400) /* memory errors */
|
||||
#define ERR_NO_MEMORY (-401)
|
||||
#define ERR_MEMORY_CORRUPT (-402)
|
||||
#define ERR_MULTIPLE_FREE (-403) /* multiple frees of same object/buf */
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Functions **
|
||||
** **
|
||||
*************************************************************************/
|
||||
|
||||
STRING util_error_string(int errCode);
|
||||
int util_print_error(int errCode, STRING string); /* NULL OK for string*/
|
||||
|
||||
#endif /* _ABUTIL_UTIL_ERR_H_ */
|
||||
790
cde/programs/dtappbuilder/src/libAButil/util_file.c
Normal file
790
cde/programs/dtappbuilder/src/libAButil/util_file.c
Normal file
@@ -0,0 +1,790 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: util_file.c /main/4 1995/11/06 18:54:05 rswiston $
|
||||
*
|
||||
* @(#)util_file.c 1.24 19 Apr 1995 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* File: util_file.c
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <ab_private/abio.h>
|
||||
#include "utilP.h"
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Private Function Declarations **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Data **
|
||||
** **
|
||||
**************************************************************************/
|
||||
#define AB_EXT_LENGTH 3
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Function Definitions **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* removes all buffering from a file. This is useful for debugging
|
||||
* to avoid losing data, and to keep stdout and stderr messages from
|
||||
* getting jumbled (ordered is basically guaranteed if both streams
|
||||
* are unbuffered).
|
||||
*
|
||||
* This *is* a performance hit, so don't use this except when debugging.
|
||||
* Note that stderr is always unbuffered.
|
||||
*/
|
||||
int
|
||||
util_unbuffer_file(FILE *fp)
|
||||
{
|
||||
int iReturn= 0;
|
||||
int iRC= 0; /* return code */
|
||||
int fileMode= 0;
|
||||
|
||||
setbuf(fp, NULL);
|
||||
/* this is too much - actually waits for sync to disk, and runs
|
||||
* RIDICULOUSLY SLOW.
|
||||
*/
|
||||
/*
|
||||
if ((iRC= fileMode= fcntl(fileno(fp), F_GETFL)) >= 0)
|
||||
{
|
||||
fileMode |= O_DSYNC;
|
||||
iRC= fcntl(fileno(fp), F_SETFL, fileMode);
|
||||
}
|
||||
*/
|
||||
iReturn= iRC;
|
||||
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
util_file_exists(STRING fileName)
|
||||
{
|
||||
struct stat fileInfo;
|
||||
return (stat(fileName, &fileInfo) == 0);
|
||||
}
|
||||
|
||||
|
||||
/* Returns the file size, or ERR_ value (<0) on error
|
||||
*
|
||||
*/
|
||||
long
|
||||
util_file_size(STRING fileName)
|
||||
{
|
||||
struct stat fileInfo;
|
||||
if (stat(fileName, &fileInfo) != 0)
|
||||
{
|
||||
return ERR_FILE_NOT_FOUND;
|
||||
}
|
||||
return (long)fileInfo.st_size;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Extension should not contain it's leading "."
|
||||
*
|
||||
* if extension is NULL or the empty string, returns TRUE if the name
|
||||
* has no extension
|
||||
*/
|
||||
BOOL
|
||||
util_file_name_has_extension(STRING fileName, STRING extension)
|
||||
{
|
||||
BOOL hasExtension= FALSE;
|
||||
|
||||
if (extension == NULL)
|
||||
{
|
||||
hasExtension = ( (fileName == NULL) || (strlen(fileName) == 0) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fileName == NULL)
|
||||
{
|
||||
hasExtension= FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *dotPtr= strrchr(fileName, '.');
|
||||
if (dotPtr == NULL)
|
||||
{
|
||||
hasExtension= FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
hasExtension= util_streq(dotPtr+1, extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasExtension;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
util_file_name_has_ab_extension(STRING fileName)
|
||||
{
|
||||
BOOL hasExtension= FALSE;
|
||||
char *dotPtr= strrchr(fileName, '.');
|
||||
|
||||
if (dotPtr != NULL)
|
||||
{
|
||||
hasExtension= (strncmp(dotPtr, ".bi", 3) == 0);
|
||||
}
|
||||
return hasExtension;
|
||||
}
|
||||
|
||||
|
||||
STRING
|
||||
util_get_file_name_from_path(
|
||||
STRING path,
|
||||
STRING fileNameBuf,
|
||||
int fileNameBufSize
|
||||
)
|
||||
{
|
||||
char *slashPtr= strrchr(path, '/');
|
||||
if (slashPtr == NULL)
|
||||
{
|
||||
strncpy(fileNameBuf, path, fileNameBufSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(fileNameBuf, slashPtr+1, fileNameBufSize);
|
||||
}
|
||||
fileNameBuf[fileNameBufSize-1]= 0;
|
||||
return fileNameBuf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If path is not absolute, directory is "."
|
||||
*
|
||||
* The directory name returned does NOT have a trailing '/'. (The
|
||||
* only exception being the directory "/" .
|
||||
*/
|
||||
STRING
|
||||
util_get_dir_name_from_path(
|
||||
STRING path,
|
||||
STRING dirNameBuf,
|
||||
int dirNameBufSize
|
||||
)
|
||||
{
|
||||
char *slashPtr= strrchr(path, '/');
|
||||
assert(dirNameBufSize > 1);
|
||||
if (slashPtr == NULL)
|
||||
{
|
||||
/* no directory name */
|
||||
strcpy(dirNameBuf, ".");
|
||||
}
|
||||
else if (slashPtr == path)
|
||||
{
|
||||
/* file in / */
|
||||
strcpy(dirNameBuf, "/");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* directory and file name */
|
||||
int copyCount=
|
||||
util_min(dirNameBufSize, (((int)(slashPtr - path))+1));
|
||||
strncpy(dirNameBuf, path, copyCount);
|
||||
dirNameBuf[dirNameBufSize-1]= 0;
|
||||
while ((copyCount > 1) && (dirNameBuf[copyCount-1] == '/'))
|
||||
{
|
||||
--copyCount;
|
||||
}
|
||||
dirNameBuf[copyCount]= 0;
|
||||
}
|
||||
|
||||
return dirNameBuf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Truncates the open file to length bytes.
|
||||
*
|
||||
* ftruncate() is not defined in POSIX, so the header files don't define
|
||||
* it when _POSIX_SOURCE is not defined. We're going to use it, anyway,
|
||||
* and this prototype is identical in the header files for all the
|
||||
* platforms (Sun/HP/IBM).
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern ftruncate(int filedes, off_t length);
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
int
|
||||
util_fdtruncate(int filedes, off_t length)
|
||||
{
|
||||
return ftruncate(filedes, length);
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
util_directory_exists(STRING dir_name)
|
||||
{
|
||||
BOOL exists = FALSE;
|
||||
struct stat dir_info;
|
||||
|
||||
if (stat(dir_name, &dir_info) != 0)
|
||||
{
|
||||
goto epilogue;
|
||||
}
|
||||
if (S_ISDIR(dir_info.st_mode))
|
||||
{
|
||||
exists = TRUE;
|
||||
}
|
||||
|
||||
epilogue:
|
||||
return exists;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
util_paths_are_same_file(STRING path1, STRING path2)
|
||||
{
|
||||
BOOL same_file = FALSE;
|
||||
struct stat file_info1;
|
||||
struct stat file_info2;
|
||||
|
||||
if (stat(path1, &file_info1) != 0)
|
||||
{
|
||||
goto epilogue;
|
||||
}
|
||||
if (stat(path2, &file_info2) != 0)
|
||||
{
|
||||
goto epilogue;
|
||||
}
|
||||
|
||||
same_file = ( (file_info1.st_dev == file_info2.st_dev)
|
||||
&& (file_info1.st_ino == file_info2.st_ino) );
|
||||
|
||||
epilogue:
|
||||
return same_file;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Converts the path to a relative path from from_dir.
|
||||
*
|
||||
* for path and from_dir, NULL, "", or "." = current directory
|
||||
*
|
||||
* Returns "." if path and from_dir reference the same directory
|
||||
*/
|
||||
int
|
||||
util_cvt_path_to_relative(
|
||||
STRING path_in,
|
||||
STRING from_dir,
|
||||
char *buf,
|
||||
int buf_size
|
||||
)
|
||||
{
|
||||
#define path_is_dot(arg_path) \
|
||||
(util_strempty(arg_path) || util_streq(arg_path, "."))
|
||||
|
||||
int return_value = 0;
|
||||
BOOL found_relative= FALSE;
|
||||
STRING path = NULL;
|
||||
BOOL more_path = TRUE;
|
||||
char cwd[MAXPATHLEN]= "";
|
||||
STRING from= NULL;
|
||||
char *rightmost_slash= NULL;
|
||||
char *last_rightmost_slash= NULL;
|
||||
|
||||
if ( (path_is_dot(from_dir) && path_is_dot(path_in))
|
||||
|| (util_streq(from_dir, path_in))
|
||||
)
|
||||
{
|
||||
/* the strings are equivalent! */
|
||||
strcpy(buf, ".");
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine "from" dir.
|
||||
*/
|
||||
if (path_is_dot(from_dir))
|
||||
{
|
||||
from = ".";
|
||||
}
|
||||
else
|
||||
{
|
||||
from = from_dir;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the directory we are trying to convert.
|
||||
*/
|
||||
if (path_is_dot(path_in))
|
||||
{
|
||||
if (getcwd(cwd, MAXPATHLEN) == NULL)
|
||||
{
|
||||
return_value = ERR;
|
||||
goto epilogue;
|
||||
}
|
||||
path = cwd;
|
||||
}
|
||||
else
|
||||
{
|
||||
path = path_in;
|
||||
}
|
||||
|
||||
if (!util_directory_exists(from))
|
||||
{
|
||||
return_value = ERR;
|
||||
goto epilogue;
|
||||
}
|
||||
|
||||
rightmost_slash = NULL;
|
||||
last_rightmost_slash = NULL;
|
||||
more_path = TRUE;
|
||||
while ((!found_relative) && more_path)
|
||||
{
|
||||
if (util_paths_are_same_file(from, path))
|
||||
{
|
||||
found_relative = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the name of the next dir up
|
||||
*/
|
||||
rightmost_slash= strrchr(path, '/');
|
||||
if (last_rightmost_slash != NULL)
|
||||
{
|
||||
*last_rightmost_slash = '/';
|
||||
}
|
||||
last_rightmost_slash= rightmost_slash;
|
||||
|
||||
/*
|
||||
* Put in a NULL, so that util_paths_are_same_file is happy
|
||||
*/
|
||||
if (rightmost_slash == NULL)
|
||||
{
|
||||
more_path = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*rightmost_slash) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (rightmost_slash != NULL)
|
||||
{
|
||||
*rightmost_slash = '/';
|
||||
}
|
||||
|
||||
if (found_relative)
|
||||
{
|
||||
if (rightmost_slash == NULL)
|
||||
{
|
||||
/* they are the same damn file (directory)! */
|
||||
strncpy(buf, ".", buf_size);
|
||||
buf[buf_size-1]= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((*rightmost_slash == '/') && (*rightmost_slash != NULL))
|
||||
{
|
||||
++rightmost_slash;
|
||||
}
|
||||
strncpy(buf, rightmost_slash, buf_size);
|
||||
buf[buf_size-1]= 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(buf, path, buf_size);
|
||||
buf[buf_size-1]= 0;
|
||||
}
|
||||
|
||||
epilogue:
|
||||
return return_value;
|
||||
#undef path_is_dot
|
||||
}
|
||||
|
||||
/* This routine will create a directory hierarchy in the
|
||||
* current working directory if the hierarchy does not
|
||||
* already exist. If mkdir fails, errno will be set and
|
||||
* a negative value will be returned.
|
||||
*/
|
||||
int
|
||||
util_mkdir_hier(
|
||||
STRING path
|
||||
)
|
||||
{
|
||||
STRING slash_ptr = NULL;
|
||||
int ret = 0;
|
||||
|
||||
/* As an example: path -> "x/y/z", so slash_ptr points
|
||||
* to the same string.
|
||||
*/
|
||||
slash_ptr = path;
|
||||
while (slash_ptr != NULL)
|
||||
{
|
||||
/* 1) x/y/z 2) x/y/z 3) x/y/z
|
||||
* ^ ^ ^
|
||||
* | | |
|
||||
* slash_ptr slash_ptr slash_ptr == NULL
|
||||
*/
|
||||
slash_ptr = strchr(slash_ptr, '/');
|
||||
|
||||
/* 1) x NULL y/z 2) x/y NULL z
|
||||
* ^ ^
|
||||
* | |
|
||||
* slash_ptr slash_ptr
|
||||
*/
|
||||
if (slash_ptr != NULL)
|
||||
{
|
||||
*slash_ptr = 0;
|
||||
}
|
||||
|
||||
/* Make the directory named:
|
||||
* 1) "x" 2) "x/y" 3) "x/y/z"
|
||||
* in the cwd
|
||||
*/
|
||||
ret = mkdir(path, 0777);
|
||||
|
||||
/* If there was an error return -1 */
|
||||
if ( ret != 0 && errno != EEXIST )
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ( slash_ptr != NULL )
|
||||
{
|
||||
/* 1) x/y/z 2) x/y/z 3) slash_ptr == NULL
|
||||
* ^ ^
|
||||
* | |
|
||||
* slash_ptr slash_ptr
|
||||
*/
|
||||
*slash_ptr = '/';
|
||||
|
||||
/* If there are multiple slashes, skip them.
|
||||
* 1) x/y/z 2) x/y/z
|
||||
* ^ ^
|
||||
* | |
|
||||
* slash_ptr slash_ptr
|
||||
*/
|
||||
while (*slash_ptr == '/')
|
||||
{
|
||||
++slash_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
util_path_is_absolute(
|
||||
STRING dir
|
||||
)
|
||||
{
|
||||
BOOL val = FALSE;
|
||||
|
||||
if ( dir[0] == '/' )
|
||||
val = TRUE;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/* This routine is passed in an absolute path name (from the file
|
||||
* chooser) and derives the module or project name for the ABObj
|
||||
* struct. The obj name is passed back in the objname parameter.
|
||||
* This routine assumes that objname already has allocated space.
|
||||
*/
|
||||
int
|
||||
util_derive_name_from_path(
|
||||
char *fullpath,
|
||||
char *objname
|
||||
)
|
||||
{
|
||||
char *filename, *name;
|
||||
int len = 0;
|
||||
|
||||
if ( util_file_name_has_ab_extension(fullpath) )
|
||||
{
|
||||
/*
|
||||
* Check return value of strrchr before adding 1 to it
|
||||
*/
|
||||
if (filename = strrchr(fullpath, '/'))
|
||||
name = (STRING)strdup(filename + 1);
|
||||
else
|
||||
name = (STRING)strdup(fullpath);
|
||||
|
||||
len = strlen(name) - (AB_EXT_LENGTH + 1);
|
||||
strncpy(objname, name, len);
|
||||
objname[len] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Check return value of strrchr before adding 1 to it
|
||||
*/
|
||||
if (filename = strrchr(fullpath, '/'))
|
||||
strcpy(objname, filename + 1);
|
||||
else
|
||||
strcpy(objname, fullpath);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This routine is passed in a name (from the project or module
|
||||
* name dialog). It checks the name for the ".bil" or ".bip"
|
||||
* extension and strips it off if the name has it. The project
|
||||
* or module name is passed back in the new_name parameter. This
|
||||
* routine assumes that new_name already has allocated space.
|
||||
*/
|
||||
int
|
||||
util_check_name(
|
||||
STRING name,
|
||||
STRING new_name
|
||||
)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
if ( util_file_name_has_ab_extension(name) )
|
||||
{
|
||||
len = strlen(name) - (AB_EXT_LENGTH + 1);
|
||||
strncpy(new_name, name, len);
|
||||
new_name[len] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(new_name, name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
util_file_is_regular_file(STRING filename)
|
||||
{
|
||||
BOOL IsRegFile = FALSE;
|
||||
struct stat file_info;
|
||||
|
||||
if (stat(filename, &file_info) != 0)
|
||||
{
|
||||
goto epilogue;
|
||||
}
|
||||
if (S_ISREG(file_info.st_mode))
|
||||
{
|
||||
IsRegFile = TRUE;
|
||||
}
|
||||
|
||||
epilogue:
|
||||
return IsRegFile;
|
||||
}
|
||||
|
||||
BOOL
|
||||
util_file_is_directory(STRING filename)
|
||||
{
|
||||
BOOL IsDir = FALSE;
|
||||
struct stat file_info;
|
||||
|
||||
if (stat(filename, &file_info) != 0)
|
||||
{
|
||||
goto epilogue;
|
||||
}
|
||||
if (S_ISDIR(file_info.st_mode))
|
||||
{
|
||||
IsDir = TRUE;
|
||||
}
|
||||
|
||||
epilogue:
|
||||
return IsDir;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* from fopen() man page: legal types are:
|
||||
*
|
||||
* r, rb, w, wb, a, ab,
|
||||
* r+, r+b, rb+, w+, w+b, wb+, a+, a+b, ab+
|
||||
*
|
||||
* The 'b' option is ignored.
|
||||
*
|
||||
*/
|
||||
FILE *
|
||||
util_fopen_locked(const char *filename, const char *accessType)
|
||||
{
|
||||
FILE *file = NULL;
|
||||
char char1 = accessType[0];
|
||||
BOOL charPlus =
|
||||
( (accessType[1] != 0)
|
||||
&& ((accessType[1] == '+') || (accessType[2] == '+')));
|
||||
BOOL truncateFile = FALSE;
|
||||
int lockType = -1;
|
||||
|
||||
/*
|
||||
* Open the file
|
||||
* If a truncated open, open the existing file, first. That way, we
|
||||
* can get a write lock before actually doing the truncate.
|
||||
*/
|
||||
switch (accessType[0])
|
||||
{
|
||||
case 'r':
|
||||
file = fopen(filename, accessType);
|
||||
if (charPlus)
|
||||
{
|
||||
lockType = F_WRLCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
lockType = F_RDLCK;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
errno = 0;
|
||||
file = fopen(filename, "r+"); /* use existing, first! */
|
||||
if ((file == NULL) && (errno == ENOENT))
|
||||
{
|
||||
file = fopen(filename, accessType);
|
||||
}
|
||||
lockType = F_WRLCK;
|
||||
truncateFile = TRUE;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
file = fopen(filename, accessType);
|
||||
lockType = F_WRLCK;
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = 0; /* file is NULL */
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the appropriate lock on the file.
|
||||
* Truncate the file, if necessary.
|
||||
*/
|
||||
if ((file != NULL) && (lockType != -1))
|
||||
{
|
||||
if ( (util_flock(file, TRUE, lockType, 0, 0) >= 0)
|
||||
&& truncateFile)
|
||||
{
|
||||
util_ftruncate(file, 0, accessType);
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
util_flock(FILE *file, BOOL wait, int lockType, off_t offset, off_t length)
|
||||
{
|
||||
struct flock lock;
|
||||
int fcntlParam = (wait? F_SETLKW:F_SETLK);
|
||||
|
||||
lock.l_type = lockType;
|
||||
lock.l_whence = SEEK_SET;
|
||||
lock.l_start = offset;
|
||||
lock.l_len = length;
|
||||
lock.l_pid = (pid_t)-1;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debugging() && wait)
|
||||
{
|
||||
if (fcntl(fileno(file), F_SETLK, (void*)&lock) == 0)
|
||||
{
|
||||
/* got the lock */
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* didn't get the lock - we're going to block */
|
||||
util_dprintf(1, "Waiting for lock [%s]...\n",
|
||||
(fcntlParam == F_RDLCK? "READ":
|
||||
(fcntlParam == F_WRLCK? "WRITE":
|
||||
"BAD TYPE"))
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
if (fcntl(fileno(file), fcntlParam, (void*)&lock) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
util_funlock(FILE *file, off_t offset, off_t length)
|
||||
{
|
||||
struct flock lock;
|
||||
|
||||
lock.l_type = F_UNLCK;
|
||||
lock.l_whence = SEEK_SET;
|
||||
lock.l_start = offset;
|
||||
lock.l_len = length;
|
||||
lock.l_pid = (pid_t)-1;
|
||||
|
||||
if (fcntl(fileno(file), F_SETLKW, (void*)&lock) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
util_ftruncate(FILE *file, off_t length, const char *accessType)
|
||||
{
|
||||
int fd = fileno(file);
|
||||
off_t offset = ftell(file);
|
||||
|
||||
util_fdtruncate(fd, length);
|
||||
|
||||
/*
|
||||
* Associate the stream with the file descriptor fildes.
|
||||
*/
|
||||
fdopen(fd, accessType);
|
||||
|
||||
/*
|
||||
* Perform a seek on the stream, just to make sure it's in sync.
|
||||
*/
|
||||
if (offset > length)
|
||||
{
|
||||
fseek(file, 0, SEEK_END);
|
||||
}
|
||||
else
|
||||
{
|
||||
fseek(file, offset, SEEK_SET);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
181
cde/programs/dtappbuilder/src/libAButil/util_string.c
Normal file
181
cde/programs/dtappbuilder/src/libAButil/util_string.c
Normal file
@@ -0,0 +1,181 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: util_string.c /main/4 1995/11/06 18:54:19 rswiston $
|
||||
*
|
||||
* @(#)util_string.c 1.7 24 Aug 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* File: util_string.c
|
||||
*/
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "utilP.h"
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Private Function Declarations **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Data **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Function Definitions **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
int
|
||||
util_strncpy(STRING to, STRING from, int toSize)
|
||||
{
|
||||
if (toSize < 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(to, from, toSize);
|
||||
to[toSize-1]= 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Finds the substring in string, case-insensitive
|
||||
*
|
||||
* Returns index of substring, or -1 if not found
|
||||
*/
|
||||
int
|
||||
util_strcasestr(STRING str, STRING substr)
|
||||
{
|
||||
int substr_len = strlen(substr);
|
||||
int str_max = strlen(str) - substr_len;
|
||||
int i;
|
||||
int substr_start = -1;
|
||||
|
||||
if (str_max < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i <= str_max; ++i)
|
||||
{
|
||||
if (util_strncasecmp(&(str[i]), substr, substr_len) == 0)
|
||||
{
|
||||
substr_start = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return substr_start;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Case-insensitive compares the first n bytes of the string
|
||||
* (or up to NULL),
|
||||
*/
|
||||
int
|
||||
util_strncasecmp(STRING s1, STRING s2, int max_chars)
|
||||
{
|
||||
int diff = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; (i < max_chars) && (s1[i] != 0) && (s2[i] != 0); ++i)
|
||||
{
|
||||
if ((diff = (((int)tolower(s1[i])) - ((int)tolower(s2[i])))) != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* REMIND: this function needs a better name (it converts more than case)
|
||||
*/
|
||||
int
|
||||
util_strcvt_to_lower(
|
||||
STRING lc_string,
|
||||
STRING string,
|
||||
int lc_string_size
|
||||
)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
for (i=0; i < lc_string_size; i++)
|
||||
{
|
||||
c = string[i];
|
||||
|
||||
if (c != '\0' && (isspace(c) || !isalnum(c)))
|
||||
lc_string[i] = '-';
|
||||
else if (c == '\0')
|
||||
{
|
||||
lc_string[i] = c;
|
||||
break;
|
||||
}
|
||||
else if (islower(c))
|
||||
lc_string[i] = c;
|
||||
else
|
||||
lc_string[i] = tolower(c);
|
||||
}
|
||||
lc_string[lc_string_size-1] = 0; /* make sure */
|
||||
return 0;
|
||||
}
|
||||
|
||||
STRING
|
||||
util_strip_white_space(
|
||||
STRING string
|
||||
)
|
||||
{
|
||||
STRING newString = NULL,
|
||||
index = NULL;
|
||||
|
||||
index = string;
|
||||
/* Strip off any beginning blanks */
|
||||
while ((index != NULL) && isspace(*index))
|
||||
{
|
||||
index++;
|
||||
}
|
||||
|
||||
if (index != NULL)
|
||||
{
|
||||
newString = strdup(index);
|
||||
index = newString;
|
||||
while ((index != NULL) && !(isspace(*index)))
|
||||
{
|
||||
index++;
|
||||
}
|
||||
/* Strip off any ending blanks */
|
||||
if (index != NULL)
|
||||
*index = '\0';
|
||||
}
|
||||
return (newString);
|
||||
}
|
||||
|
||||
178
cde/programs/dtappbuilder/src/libAButil/util_test.c
Normal file
178
cde/programs/dtappbuilder/src/libAButil/util_test.c
Normal file
@@ -0,0 +1,178 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: util_test.c /main/4 1995/11/06 18:54:31 rswiston $
|
||||
*
|
||||
* @(#)util_test.c 1.7 14 Feb 1994
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "util.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h> /* mkdir */
|
||||
#include <sys/param.h>
|
||||
|
||||
static int test_verbosity(void);
|
||||
static int test_output(void);
|
||||
static int test_get_dir_name(void);
|
||||
static int test_cvt_path_to_relative(void);
|
||||
static int get_it(char *dirname);
|
||||
static int cvt_it(STRING path, STRING dir);
|
||||
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
util_init(argv[0]);
|
||||
test_verbosity();
|
||||
test_output();
|
||||
/* test_get_dir_name(); */
|
||||
/* test_cvt_path_to_relative(); */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_verbosity(void)
|
||||
{
|
||||
#define set_lvl(l) ((lvl = (l)), (dlvl = util_max(0, lvl - 2)))
|
||||
int lvl = 0;
|
||||
int dlvl = 0;
|
||||
int lvl_from_get_verbosity = 0;
|
||||
int dlvl_from_util_get_debug_level = 0;
|
||||
int dlvl_from_debug_level = 0;
|
||||
|
||||
util_printf("***** TESTING VERBOSITY *****\n");
|
||||
set_lvl(3);
|
||||
printf("setting verbosity to %d\n", lvl);
|
||||
util_set_verbosity(lvl);
|
||||
lvl_from_get_verbosity = util_get_verbosity();
|
||||
printf("util_get_verbosity -> %d\n", lvl_from_get_verbosity);
|
||||
if (lvl != lvl_from_get_verbosity)
|
||||
{
|
||||
printf("ERROR - bad verbosity %s:%d\n", __FILE__, __LINE__);
|
||||
}
|
||||
dlvl_from_util_get_debug_level = util_get_debug_level();
|
||||
printf("util_get_debug_level() -> %d\n", dlvl_from_util_get_debug_level);
|
||||
if (dlvl != dlvl_from_util_get_debug_level)
|
||||
{
|
||||
printf("ERROR - bad debug level %s:%d\n", __FILE__, __LINE__);
|
||||
}
|
||||
dlvl_from_debug_level = debug_level();
|
||||
printf("debug_level() -> %d\n", dlvl_from_debug_level);
|
||||
if (dlvl != dlvl_from_debug_level)
|
||||
{
|
||||
printf("ERROR - bad debug level %s%d\n", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
printf("debugging: %d\n", debugging());
|
||||
if (!debugging())
|
||||
{
|
||||
printf("ERROR - bad debugging %s:%d\n", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_output(void)
|
||||
{
|
||||
util_printf("***** TESTING OUTPUT\n");
|
||||
|
||||
util_puts("string to util_puts\n");
|
||||
util_puts_err("string to util_puts_err\n");
|
||||
util_dputs(0, "string to util_dputs\n");
|
||||
util_printf("string to util_printf at %s:%d\n", __FILE__, __LINE__);
|
||||
util_printf_err("string to util_printf_err at %s:%d\n", __FILE__, __LINE__);
|
||||
util_dprintf(0, "string to util_dprintf at %s:%d\n", __FILE__, __LINE__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_cvt_path_to_relative(void)
|
||||
{
|
||||
mkdir("TEST", 0777);
|
||||
cvt_it("/local/home/dunn/tmp", "/local/home/dunn");
|
||||
cvt_it("/local/home/dunn/tmp", "/net/fuggit/local/home/dunn");
|
||||
cvt_it( "/net/fuggit/local/home/dunn", "/local/home/dunn/tmp");
|
||||
cvt_it("///usr//dt", "/usr///dt/include");
|
||||
cvt_it("/usr///dt/include", "///usr//dt");
|
||||
cvt_it("TEST", NULL);
|
||||
cvt_it("../libAButil/TEST", NULL);
|
||||
cvt_it("/home/marth", "/home/marth");
|
||||
rmdir("TEST");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cvt_it(STRING path, STRING from)
|
||||
{
|
||||
STRING s1= NULL;
|
||||
STRING s2= NULL;
|
||||
if (path != NULL)
|
||||
{
|
||||
s1= strdup(path);
|
||||
}
|
||||
if (from != NULL)
|
||||
{
|
||||
s2= strdup(from);
|
||||
}
|
||||
|
||||
char buf[MAXPATHLEN]= "";
|
||||
int ret;
|
||||
|
||||
ret= util_cvt_path_to_relative(path, from, buf, MAXPATHLEN);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("cvt(%s,%s) -> %d\n",
|
||||
util_strsafe(s1), util_strsafe(s2), ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("cvt(%s,%s) -> '%s'\n",
|
||||
util_strsafe(s1), util_strsafe(s2), util_strsafe(buf));
|
||||
}
|
||||
|
||||
util_free(s1);
|
||||
util_free(s2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
test_get_dir_name(void)
|
||||
{
|
||||
get_it("");
|
||||
get_it("abc/xyz");
|
||||
get_it("../");
|
||||
get_it("x");
|
||||
get_it("/");
|
||||
get_it("/abc/def/ghi");
|
||||
get_it("/abc/");
|
||||
get_it("/abc///");
|
||||
get_it("///abc");
|
||||
get_it("//");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
get_it(char *path)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
printf("'%s' => '%s'\n",
|
||||
path,
|
||||
util_get_dir_name_from_path(path, buf, 256));
|
||||
return 0;
|
||||
}
|
||||
|
||||
790
cde/programs/dtappbuilder/src/libAButil/util_types.h
Normal file
790
cde/programs/dtappbuilder/src/libAButil/util_types.h
Normal file
@@ -0,0 +1,790 @@
|
||||
|
||||
/*
|
||||
* $XConsortium: util_types.h /main/4 1995/11/06 18:54:42 rswiston $
|
||||
*
|
||||
* @(#)util_types.h 3.69 15 Feb 1994 cde_app_builder/src/libAButil
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AB_UTIL_TYPES_H
|
||||
#define _AB_UTIL_TYPES_H
|
||||
/*
|
||||
* util_types.h - defines all scalar types used in the CDE app builder
|
||||
*/
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
|
||||
#endif
|
||||
|
||||
#define AB_VERSION_PREFIX ":bil-version"
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
**************************************************************************
|
||||
** **
|
||||
** GENERAL/MISCELLANEOUS TYPES **
|
||||
** **
|
||||
**************************************************************************
|
||||
**************************************************************************/
|
||||
|
||||
#define OK (0)
|
||||
#define ERROR (-1)
|
||||
|
||||
#define AB_NO_SUBTYPE -1
|
||||
|
||||
extern const int Util_major_version;
|
||||
extern const int Util_minor_version;
|
||||
|
||||
#include <X11/Xmd.h> /* For BOOL and BYTE typedefs */
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned int UINT;
|
||||
typedef unsigned long ULONG;
|
||||
typedef char * STRING;
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE ((BOOL)(0x00))
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE ((BOOL)(0x01))
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
**************************************************************************
|
||||
** **
|
||||
** APP-BUILDER-SPECIFIC TYPES **
|
||||
** **
|
||||
**************************************************************************
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Argument type used in the resfile.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_ARG_UNDEF = 0,
|
||||
AB_ARG_BOOLEAN,
|
||||
AB_ARG_CALLBACK,
|
||||
AB_ARG_FLOAT,
|
||||
AB_ARG_INT,
|
||||
AB_ARG_LITERAL, /* e.g., #define values, written out "as is" */
|
||||
AB_ARG_NONE, /* no argument */
|
||||
AB_ARG_STRING,
|
||||
AB_ARG_XMSTRING,
|
||||
AB_ARG_XMSTRING_TBL,
|
||||
AB_ARG_PIXEL,
|
||||
AB_ARG_PIXMAP,
|
||||
AB_ARG_FONT,
|
||||
AB_ARG_WIDGET,
|
||||
AB_ARG_VOID_PTR,
|
||||
AB_ARG_VARIABLE,
|
||||
AB_ARG_MNEMONIC,
|
||||
AB_ARG_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_ARG_TYPE;
|
||||
|
||||
/*
|
||||
* Resource "classes"
|
||||
*
|
||||
* The classes are mutually exclusive.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_ARG_CLASS_UNDEF = 0,
|
||||
AB_ARG_CLASS_ACCELERATOR, /* items */
|
||||
AB_ARG_CLASS_COLOR, /* any color-related arg */
|
||||
AB_ARG_CLASS_GEOMETRY, /* includes layout, attachments */
|
||||
AB_ARG_CLASS_GLYPH, /* any glyph (including icons) */
|
||||
AB_ARG_CLASS_NON_GLYPH_LABEL, /* any label not of type glyph */
|
||||
AB_ARG_CLASS_OTHER_STRING, /* any string of no other class */
|
||||
AB_ARG_CLASS_OTHER, /* any of no other class */
|
||||
AB_ARG_CLASS_VALUE, /* e.g., text field, scale, scrollbar*/
|
||||
AB_ARG_CLASS_NUM_VALUES /* must be last */
|
||||
} AB_ARG_CLASS;
|
||||
|
||||
typedef unsigned char AB_ARG_CLASS_FLAGS; /* bitmap of arg classes */
|
||||
#define AB_ARG_CLASS_FLAGS_NONE ((AB_ARG_CLASS_FLAGS)0x0000)
|
||||
#define AB_ARG_CLASS_FLAGS_ALL ((AB_ARG_CLASS_FLAGS)~0x0000)
|
||||
|
||||
|
||||
/*
|
||||
* Function type used in the resfile
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_FUNC_UNDEF = 0,
|
||||
AB_FUNC_BUILTIN, /* ab-defined action (e.g., setvalue) */
|
||||
AB_FUNC_USER_DEF, /* function name (user-defined function) */
|
||||
AB_FUNC_CODE_FRAG, /* actual code entered by user */
|
||||
AB_FUNC_ON_ITEM_HELP, /* dtb_do_on_item_help() */
|
||||
AB_FUNC_HELP_VOLUME, /* dtb_show_help_volume_info() */
|
||||
AB_FUNC_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_FUNC_TYPE;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Orientation scalar
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_ORIENT_UNDEF = 0,
|
||||
AB_ORIENT_HORIZONTAL,
|
||||
AB_ORIENT_VERTICAL,
|
||||
AB_ORIENTATION_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_ORIENTATION;
|
||||
|
||||
/*
|
||||
* Types for the AB_GROUP_TYPE attribute.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_GROUP_UNDEF = 0,
|
||||
AB_GROUP_IGNORE,
|
||||
AB_GROUP_COLUMNS,
|
||||
AB_GROUP_ROWS,
|
||||
AB_GROUP_ROWSCOLUMNS,
|
||||
AB_GROUP_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_GROUP_TYPE;
|
||||
|
||||
/*
|
||||
* Types for AB_LINE_TYPE (Used for Separator Object &
|
||||
* framing objects)
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_LINE_UNDEF = 0,
|
||||
AB_LINE_NONE,
|
||||
AB_LINE_SHADOW_IN,
|
||||
AB_LINE_SHADOW_OUT,
|
||||
AB_LINE_ETCHED_IN,
|
||||
AB_LINE_ETCHED_OUT,
|
||||
AB_LINE_ETCHED_IN_DASH,
|
||||
AB_LINE_ETCHED_OUT_DASH,
|
||||
AB_LINE_SINGLE_LINE,
|
||||
AB_LINE_DOUBLE_LINE,
|
||||
AB_LINE_SINGLE_DASHED_LINE,
|
||||
AB_LINE_DOUBLE_DASHED_LINE,
|
||||
AB_LINE_TYPE_NUM_VALUES
|
||||
} AB_LINE_TYPE;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_ALIGN_UNDEF = 0,
|
||||
AB_ALIGN_TOP,
|
||||
AB_ALIGN_RIGHT,
|
||||
AB_ALIGN_BOTTOM,
|
||||
AB_ALIGN_LEFT,
|
||||
AB_ALIGN_CENTER, /* center verticaly and horizontally */
|
||||
AB_ALIGN_VCENTER, /* center vertically */
|
||||
AB_ALIGN_HCENTER, /* center horizontally */
|
||||
AB_ALIGN_LABELS,
|
||||
AB_ALIGNMENT_NUM_VALUES /* must be last! */
|
||||
} AB_ALIGNMENT;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AB_DIR_UNDEF = 0,
|
||||
AB_DIR_LEFT_TO_RIGHT,
|
||||
AB_DIR_RIGHT_TO_LEFT,
|
||||
AB_DIR_TOP_TO_BOTTOM,
|
||||
AB_DIR_BOTTOM_TO_TOP,
|
||||
AB_DIR_NUM_VALUES /* must be last! */
|
||||
} AB_DIRECTION;
|
||||
|
||||
|
||||
/*
|
||||
* Types for the AB_{ANCHOR,REFERENCE}_POINT attributes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_CP_UNDEF = 0,
|
||||
AB_CP_NORTH,
|
||||
AB_CP_NORTHEAST,
|
||||
AB_CP_EAST,
|
||||
AB_CP_SOUTHEAST,
|
||||
AB_CP_SOUTH,
|
||||
AB_CP_SOUTHWEST,
|
||||
AB_CP_WEST,
|
||||
AB_CP_NORTHWEST,
|
||||
AB_CP_CENTER,
|
||||
AB_COMPASS_POINT_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_COMPASS_POINT;
|
||||
|
||||
|
||||
/*
|
||||
* Layout Attachment types
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_ATTACH_UNDEF = 0,
|
||||
AB_ATTACH_POINT,
|
||||
AB_ATTACH_OBJ,
|
||||
AB_ATTACH_ALIGN_OBJ_EDGE,
|
||||
AB_ATTACH_GRIDLINE,
|
||||
AB_ATTACH_CENTER_GRIDLINE,
|
||||
AB_ATTACH_NONE,
|
||||
AB_ATTACHMENT_NUM_VALUES
|
||||
} AB_ATTACH_TYPE;
|
||||
|
||||
/*
|
||||
* Intitial state types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_STATE_UNDEF = 0,
|
||||
AB_STATE_ACTIVE,
|
||||
AB_STATE_ICONIC,
|
||||
AB_STATE_INACTIVE,
|
||||
AB_STATE_INVISIBLE,
|
||||
AB_STATE_NOTSELECTED,
|
||||
AB_STATE_OPEN,
|
||||
AB_STATE_SELECTED,
|
||||
AB_STATE_VISIBLE,
|
||||
AB_OBJECT_STATE_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_OBJECT_STATE;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_PACK_UNDEF = 0,
|
||||
AB_PACK_NONE,
|
||||
AB_PACK_TIGHT,
|
||||
AB_PACK_EQUAL,
|
||||
AB_PACKING_NUM_VALUES
|
||||
} AB_PACKING;
|
||||
|
||||
/*
|
||||
* file types
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_FILE_UNDEF = 0,
|
||||
AB_FILE_BIL_COMPLETE,
|
||||
AB_FILE_BIL_PROJECT,
|
||||
AB_FILE_BIL_MODULE,
|
||||
AB_FILE_C,
|
||||
AB_FILE_GIL_INTERFACE,
|
||||
AB_FILE_GIL_PROJECT,
|
||||
AB_FILE_UIL,
|
||||
AB_FILE_TYPE_NUM_VALUES
|
||||
} AB_FILE_TYPE;
|
||||
|
||||
|
||||
/*
|
||||
* Action triggers ("when" values)
|
||||
*
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_WHEN_UNDEF = 0,
|
||||
AB_WHEN_ACTION1, /* MessageBox Ok Button */
|
||||
AB_WHEN_ACTION2, /* MessageBox Extra Button */
|
||||
AB_WHEN_ACTION3, /* MessageBox Extra Button */
|
||||
AB_WHEN_ACTIVATED,
|
||||
AB_WHEN_AFTER_CREATED, /* immediately after create */
|
||||
AB_WHEN_AFTER_RESIZED,
|
||||
AB_WHEN_BEFORE_POST_MENU,
|
||||
AB_WHEN_BEFORE_TEXT_CHANGED,
|
||||
AB_WHEN_CANCEL, /* MessageBox Cancel Button */
|
||||
AB_WHEN_DESTROYED,
|
||||
AB_WHEN_DOUBLE_CLICKED_ON,
|
||||
AB_WHEN_DRAGGED,
|
||||
AB_WHEN_DRAGGED_FROM,
|
||||
AB_WHEN_DROPPED_ON,
|
||||
AB_WHEN_HIDDEN,
|
||||
AB_WHEN_ITEM_SELECTED,
|
||||
AB_WHEN_OK,
|
||||
AB_WHEN_POPPED_DOWN,
|
||||
AB_WHEN_POPPED_UP,
|
||||
AB_WHEN_REPAINT_NEEDED,
|
||||
AB_WHEN_SESSION_RESTORE,
|
||||
AB_WHEN_SESSION_SAVE,
|
||||
AB_WHEN_SHOWN,
|
||||
AB_WHEN_TEXT_CHANGED,
|
||||
AB_WHEN_TOGGLED,
|
||||
AB_WHEN_TOOLTALK_DO_COMMAND,
|
||||
AB_WHEN_TOOLTALK_GET_STATUS,
|
||||
AB_WHEN_TOOLTALK_PAUSE_RESUME,
|
||||
AB_WHEN_TOOLTALK_QUIT,
|
||||
AB_WHEN_VALUE_CHANGED,
|
||||
AB_WHEN_NUM_VALUES
|
||||
} AB_WHEN;
|
||||
|
||||
/*
|
||||
* Builtin app builder actions
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_STDACT_UNDEF = 0,
|
||||
AB_STDACT_DISABLE,
|
||||
AB_STDACT_ENABLE,
|
||||
AB_STDACT_HIDE,
|
||||
AB_STDACT_SET_LABEL,
|
||||
AB_STDACT_SET_TEXT,
|
||||
AB_STDACT_SET_VALUE,
|
||||
AB_STDACT_SHOW,
|
||||
AB_BUILTIN_ACTION_NUM_VALUES
|
||||
} AB_BUILTIN_ACTION;
|
||||
|
||||
/*
|
||||
* Horizontal and vertical scrollbar settings
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_SCROLLBAR_UNDEF = 0,
|
||||
AB_SCROLLBAR_ALWAYS,
|
||||
AB_SCROLLBAR_NEVER,
|
||||
AB_SCROLLBAR_WHEN_NEEDED,
|
||||
AB_SCROLLBAR_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_SCROLLBAR_POLICY;
|
||||
|
||||
/*
|
||||
* Tooltalk Handling Level types
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_TOOLTALK_UNDEF,
|
||||
AB_TOOLTALK_NONE,
|
||||
AB_TOOLTALK_DESKTOP_BASIC,
|
||||
AB_TOOLTALK_DESKTOP_ADVANCED,
|
||||
AB_TOOLTALK_NUM_VALUES /* number of valid values - LAST */
|
||||
} AB_TOOLTALK_LEVEL;
|
||||
|
||||
/*
|
||||
* Sessioning method.
|
||||
* Used in Project ABObj.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_SESSIONING_UNDEF = 0,
|
||||
AB_SESSIONING_NONE,
|
||||
AB_SESSIONING_CMDLINE,
|
||||
AB_SESSIONING_FILE,
|
||||
AB_SESSIONING_CMDLINE_AND_FILE,
|
||||
AB_SESSIONING_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_SESSIONING_METHOD;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
**************************************************************************
|
||||
** **
|
||||
** OBJECT TYPES AND SUBTYPES **
|
||||
** **
|
||||
**************************************************************************
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Basic object types
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_TYPE_UNDEF = 0,
|
||||
AB_TYPE_ACTION,
|
||||
AB_TYPE_ACTION_LIST,
|
||||
AB_TYPE_BASE_WINDOW,
|
||||
AB_TYPE_BUTTON,
|
||||
AB_TYPE_CHOICE,
|
||||
AB_TYPE_COMBO_BOX,
|
||||
AB_TYPE_CONTAINER,
|
||||
AB_TYPE_DIALOG,
|
||||
AB_TYPE_DRAWING_AREA,
|
||||
AB_TYPE_FILE, /*generic file, usually, a file in a proj*/
|
||||
AB_TYPE_MODULE,
|
||||
AB_TYPE_ITEM, /* item in a list, menu, or choice */
|
||||
AB_TYPE_LABEL, /* static text */
|
||||
AB_TYPE_LAYERS,
|
||||
AB_TYPE_LIST,
|
||||
AB_TYPE_MENU,
|
||||
AB_TYPE_PROJECT,
|
||||
AB_TYPE_SEPARATOR,
|
||||
AB_TYPE_SPIN_BOX,
|
||||
AB_TYPE_SCALE,
|
||||
AB_TYPE_TERM_PANE,
|
||||
AB_TYPE_TEXT_FIELD,
|
||||
AB_TYPE_TEXT_PANE,
|
||||
AB_TYPE_UNKNOWN,
|
||||
AB_TYPE_FILE_CHOOSER,
|
||||
AB_TYPE_MESSAGE,
|
||||
AB_OBJECT_TYPE_NUM_VALUES /* number of valid values (MUST BE LAST!) */
|
||||
} AB_OBJECT_TYPE;
|
||||
#define AB_TYPE_INTERFACE AB_TYPE_MODULE /* INTERFACE WILL GO AWAY */
|
||||
|
||||
|
||||
/*
|
||||
* Compound object sub-types
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_COMP_UNDEF = 0,
|
||||
AB_COMP_FILE_CHOOSER,
|
||||
AB_COMP_MESSAGE,
|
||||
AB_COMPOUND_TYPE_NUM_VALUES /* must be last! */
|
||||
} AB_COMPOUND_TYPE;
|
||||
|
||||
|
||||
/*
|
||||
* Container subtypes
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_CONT_UNDEF = 0,
|
||||
AB_CONT_ABSOLUTE,
|
||||
AB_CONT_BUTTON_PANEL,
|
||||
AB_CONT_FOOTER,
|
||||
AB_CONT_GROUP,
|
||||
AB_CONT_MAIN_WINDOW,
|
||||
AB_CONT_MENU_BAR,
|
||||
AB_CONT_PANED,
|
||||
AB_CONT_RELATIVE,
|
||||
AB_CONT_SCROLLED_WINDOW,
|
||||
AB_CONT_ROW_COLUMN,
|
||||
AB_CONT_TOOL_BAR,
|
||||
AB_CONTAINER_TYPE_NUM_VALUES /* must be last! */
|
||||
} AB_CONTAINER_TYPE;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AB_DLG_UNDEF = 0,
|
||||
AB_DLG_BUILTIN,
|
||||
AB_DLG_CUSTOM,
|
||||
AB_DIALOG_TYPE_NUM_VALUES /* must be last! */
|
||||
} AB_DIALOG_TYPE;
|
||||
|
||||
|
||||
/*
|
||||
* Button subtypes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_BUT_UNDEF = 0,
|
||||
AB_BUT_PUSH,
|
||||
AB_BUT_DRAWN,
|
||||
AB_BUT_MENU,
|
||||
AB_BUTTON_TYPE_NUM_VALUES /* must be last! */
|
||||
} AB_BUTTON_TYPE;
|
||||
|
||||
|
||||
/*
|
||||
* subtype for: ITEM
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_ITEM_FOR_UNDEF = 0,
|
||||
AB_ITEM_FOR_CHOICE,
|
||||
AB_ITEM_FOR_COMBO_BOX,
|
||||
AB_ITEM_FOR_LIST,
|
||||
AB_ITEM_FOR_MENU,
|
||||
AB_ITEM_FOR_MENUBAR,
|
||||
AB_ITEM_FOR_SPIN_BOX,
|
||||
AB_ITEM_TYPE_NUM_VALUES /* must be last */
|
||||
} AB_ITEM_TYPE;
|
||||
|
||||
/*
|
||||
* Menu types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_MENU_UNDEF = 0,
|
||||
AB_MENU_PULLDOWN,
|
||||
AB_MENU_POPUP,
|
||||
AB_MENU_OPTION,
|
||||
AB_MENU_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_MENU_TYPE;
|
||||
|
||||
|
||||
/*
|
||||
* Setting types.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_CHOICE_UNDEF = 0,
|
||||
AB_CHOICE_EXCLUSIVE,
|
||||
AB_CHOICE_NONEXCLUSIVE,
|
||||
AB_CHOICE_OPTION_MENU,
|
||||
AB_CHOICE_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
/* ANSI: no comma after last enum item! */
|
||||
} AB_CHOICE_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AB_SELECT_UNDEF = 0,
|
||||
AB_SELECT_SINGLE,
|
||||
AB_SELECT_BROWSE,
|
||||
AB_SELECT_MULTIPLE,
|
||||
AB_SELECT_BROWSE_MULTIPLE,
|
||||
AB_SELECT_TYPE_NUM_VALUES
|
||||
/* ANSI: no comma after last enum item! */
|
||||
|
||||
} AB_SELECT_TYPE;
|
||||
|
||||
/*
|
||||
* subtype for: TEXT_FIELD, TEXT_PANE, SPIN_BOX
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_TEXT_UNDEF = 0,
|
||||
AB_TEXT_ALPHANUMERIC,
|
||||
AB_TEXT_NUMERIC,
|
||||
AB_TEXT_DEFINED_STRING,
|
||||
AB_TEXT_TYPE_NUM_VALUES /* must be last! */
|
||||
} AB_TEXT_TYPE;
|
||||
|
||||
|
||||
/*
|
||||
* Label subtypes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_LABEL_UNDEF = 0,
|
||||
AB_LABEL_ARROW_DOWN,
|
||||
AB_LABEL_ARROW_LEFT,
|
||||
AB_LABEL_ARROW_RIGHT,
|
||||
AB_LABEL_ARROW_UP,
|
||||
AB_LABEL_DRAWN,
|
||||
AB_LABEL_GLYPH,
|
||||
AB_LABEL_STRING,
|
||||
AB_LABEL_SEPARATOR,
|
||||
AB_LABEL_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
|
||||
} AB_LABEL_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AB_STYLE_UNDEF = 0,
|
||||
AB_STYLE_NORMAL,
|
||||
AB_STYLE_BOLD,
|
||||
AB_STYLE_3D,
|
||||
AB_LABEL_STYLE_NUM_VALUES /* must be last */
|
||||
} AB_LABEL_STYLE;
|
||||
|
||||
/*
|
||||
* Arrow styles for SpinBox
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_ARROW_UNDEF = 0,
|
||||
AB_ARROW_FLAT_BEGIN,
|
||||
AB_ARROW_FLAT_END,
|
||||
AB_ARROW_BEGIN,
|
||||
AB_ARROW_END,
|
||||
AB_ARROW_SPLIT,
|
||||
AB_ARROW_STYLE_NUM_VALUES /* must be last */
|
||||
} AB_ARROW_STYLE;
|
||||
|
||||
#define ab_label_is_arrow(lt) \
|
||||
((lt) == AB_LABEL_ARROW_DOWN || \
|
||||
(lt) == AB_LABEL_ARROW_UP || \
|
||||
(lt) == AB_LABEL_ARROW_RIGHT || \
|
||||
(lt) == AB_LABEL_ARROW_LEFT )
|
||||
/*
|
||||
* Scale subtypes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_SCALE_UNDEF = 0,
|
||||
AB_SCALE_SCALE,
|
||||
AB_SCALE_GAUGE,
|
||||
AB_SCALE_NUM_VALUES /* must be last! */
|
||||
} AB_SCALE_TYPE;
|
||||
|
||||
/*
|
||||
* File type masks for the File Chooser
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_FILE_TYPE_MASK_UNDEF = 0,
|
||||
AB_FILE_REGULAR,
|
||||
AB_FILE_DIRECTORY,
|
||||
AB_FILE_ANY,
|
||||
AB_FILE_TYPE_MASK_NUM_VALUES /* must be last! */
|
||||
} AB_FILE_TYPE_MASK;
|
||||
|
||||
/*
|
||||
* Message Box types
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_MSG_UNDEF = 0,
|
||||
AB_MSG_ERROR,
|
||||
AB_MSG_INFORMATION,
|
||||
AB_MSG_QUESTION,
|
||||
AB_MSG_WARNING,
|
||||
AB_MSG_WORKING,
|
||||
AB_MSG_TYPE_NUM_VALUES /* must be last! */
|
||||
} AB_MESSAGE_TYPE;
|
||||
|
||||
/*
|
||||
* Default Button.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AB_DEFAULT_BTN_UNDEF = 0,
|
||||
AB_DEFAULT_BTN_ACTION1,
|
||||
AB_DEFAULT_BTN_ACTION2,
|
||||
AB_DEFAULT_BTN_ACTION3,
|
||||
AB_DEFAULT_BTN_CANCEL,
|
||||
AB_DEFAULT_BTN_NONE,
|
||||
AB_DEFAULT_BTN_NUM_VALUES /* must be last! */
|
||||
} AB_DEFAULT_BUTTON;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
** **
|
||||
** Type converters **
|
||||
** **
|
||||
**************************************************************************/
|
||||
|
||||
AB_ARG_TYPE util_string_to_arg_type(
|
||||
STRING arg_type
|
||||
);
|
||||
STRING util_arg_type_to_string(
|
||||
AB_ARG_TYPE arg_type
|
||||
);
|
||||
|
||||
AB_ARG_CLASS util_string_to_arg_class(
|
||||
STRING arg_class_string
|
||||
);
|
||||
STRING util_arg_class_to_string(
|
||||
AB_ARG_CLASS arg_class
|
||||
);
|
||||
AB_ARG_CLASS_FLAGS util_arg_class_to_flag(
|
||||
AB_ARG_CLASS arg_class
|
||||
);
|
||||
AB_ARG_CLASS util_flag_to_arg_class(
|
||||
AB_ARG_CLASS_FLAGS arg_flag
|
||||
);
|
||||
|
||||
AB_LABEL_TYPE util_string_to_label_type(
|
||||
STRING label_type
|
||||
);
|
||||
STRING util_label_type_to_string(
|
||||
AB_LABEL_TYPE label_type
|
||||
);
|
||||
|
||||
AB_OBJECT_STATE util_string_to_object_state(
|
||||
STRING state
|
||||
);
|
||||
STRING util_object_state_to_string(
|
||||
AB_OBJECT_STATE state
|
||||
);
|
||||
|
||||
AB_OBJECT_TYPE util_string_to_object_type(
|
||||
STRING type
|
||||
);
|
||||
STRING util_object_type_to_string(
|
||||
AB_OBJECT_TYPE type
|
||||
);
|
||||
|
||||
AB_ORIENTATION util_string_to_orientation(
|
||||
STRING orientation
|
||||
);
|
||||
STRING util_orientation_to_string(
|
||||
AB_ORIENTATION orientation
|
||||
);
|
||||
|
||||
AB_MENU_TYPE util_string_to_menu_type(
|
||||
STRING menu_type
|
||||
);
|
||||
STRING util_menu_type_to_string(
|
||||
AB_MENU_TYPE menu_type
|
||||
);
|
||||
|
||||
AB_BUTTON_TYPE util_string_to_button_type(
|
||||
STRING button_type
|
||||
);
|
||||
STRING util_button_type_to_string(
|
||||
AB_BUTTON_TYPE button_type
|
||||
);
|
||||
|
||||
AB_ALIGNMENT util_string_to_alignment(
|
||||
STRING alignment
|
||||
);
|
||||
STRING util_alignment_to_string(
|
||||
AB_ALIGNMENT alignment
|
||||
);
|
||||
|
||||
AB_GROUP_TYPE util_string_to_group_type(
|
||||
STRING group_type
|
||||
);
|
||||
STRING util_group_type_to_string(
|
||||
AB_GROUP_TYPE group_type
|
||||
);
|
||||
|
||||
AB_CHOICE_TYPE util_string_to_choice_type(
|
||||
STRING choice_type
|
||||
);
|
||||
STRING util_choice_type_to_string(
|
||||
AB_CHOICE_TYPE choice_type
|
||||
);
|
||||
|
||||
AB_TEXT_TYPE util_string_to_text_type(
|
||||
STRING text_type
|
||||
);
|
||||
STRING util_text_type_to_string(
|
||||
AB_TEXT_TYPE text_type
|
||||
);
|
||||
|
||||
AB_BUILTIN_ACTION util_string_to_builtin_action(
|
||||
STRING action
|
||||
);
|
||||
STRING util_builtin_action_to_string(
|
||||
AB_BUILTIN_ACTION action
|
||||
);
|
||||
|
||||
AB_WHEN util_string_to_when(
|
||||
STRING when
|
||||
);
|
||||
STRING util_when_to_string(
|
||||
AB_WHEN when
|
||||
);
|
||||
|
||||
STRING util_object_type_to_browser_string(
|
||||
AB_OBJECT_TYPE type
|
||||
);
|
||||
AB_OBJECT_TYPE util_browser_string_to_object_type(
|
||||
STRING string_type
|
||||
);
|
||||
|
||||
AB_CONTAINER_TYPE util_string_to_container_type(
|
||||
STRING container_string
|
||||
);
|
||||
STRING util_container_type_to_string(
|
||||
AB_CONTAINER_TYPE type
|
||||
);
|
||||
|
||||
AB_ITEM_TYPE util_string_to_item_type(
|
||||
STRING item_string
|
||||
);
|
||||
STRING util_item_type_to_string(
|
||||
AB_ITEM_TYPE type
|
||||
);
|
||||
|
||||
#endif /* _AB_UTIL_TYPES_H */
|
||||
Reference in New Issue
Block a user