Re: Using Informix-4gl compiled help messages
Posted in 1995
Christmas is coming, the goose is getting fat. Etc. Some source code and a makefile follows. The source code builds a program, listiem, and a library file, msgtext.o. The original request, below, is for the code in msgtext.c, but it only handles the old style, short message numbers. 6.0x I4GL has to be able to handle modern long error message numbers too. The code for listiem does that -- not necessarily very elegantly, but it works for me. Strictly, therefore, some similar set of changes needs to be hacked into the msgtext.c code. If someone does it, I'd appreciate a copy of the hacked code. I also note that msgtext.c should include <stdlib.h> to obtain a prototype for bsearch(), and you also really need to find prototypes for ldint(), ldlong(), popstring(), retint() and retquote(). The popX and retX functions should be declared in $INFORMIXDIR/incl/tools/fglsys.h. The ldX functions are more problematic; there are declarations in isam.h, or you can write your own. Sorry it's not cleaner. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> PS: Prototypes for missing functions: extern void popint(int *ip); extern void popquote(char *str, int len); extern void retint(int i); extern void retquote(char *s); extern int ldint(char *s); extern /*unsigned*/ long ldlong(char *s); PPS: This code is completely independent of the Informix official code. It therefore uses an extra file descriptor. I do not recall how memory clean the msgtext.c code is -- it probably isn't therefore. PPPS: Supplied without manual page or support -- if it works for you, great. If not, fix it and let me have the results, and I'll be grateful. If you can't manage to fix it, I'm sorry for wasting your time. >Date: Sun, 3 Dec 1995 14:11:51 -0500 >From: Melvin Perez Cedano <m.mejia@server1.codetel.net.do> >Subject: Using Informix-4gl compiled help messages >X-Informix-List-Id: <list.8123> > >Hello Informixers! > >This message is similar to a previous one I wrote. Anybody knows how works >the MKMESSAGE utility? I guess that it create a file "indexed" by the help >number. But, how can I access this file in a good way without call the >SHOWHELP function? > >I trying to put my error messages in a file, as Informix products does, and >then use a function that access that file in a efficiently way. > >--************************************************************************** >NOTE TO INFORMIX: WHY WE CANNOT MANAGE THE ERROR MESSAGES AS THE HELP MESSAGES? > FOR EXAMPLE: > WE NEED ONE MORE CLAUSE IN THE "OPTIONS" STATATEMENT: >ERROR FILE, AND > A FUNCTION FOR ACCESS THE FILE: SHOWERROR. > THAT'S ALL!! >--************************************************************************** >TIA > > ////// >+------------------------------ooo-O-O-ooo--------------------------------+ >| U | >| Melvin Perez Cedano Santo Domingo, Dom. Rep.| >| Vice-President m.mejia@codetel.net.do | >| Systems Development Phone (809) 686-5574 | >| CAM Informatica, S. A. Fax (809) 686-5467 | >+-------------------------------------------------------------------------+ : "@(#)shar.sh 1.9" #! /bin/sh # # This is a shell archive. # Remove everything above this line and run sh on the resulting file. # If this archive is complete, you will see this message at the end: # "All files extracted" # # Created: Mon Dec 4 10:23:55 PST 1995 by johnl at Informix Software Ltd. # Files archived in this archive: # ffilter.c # filter.h # getopt.c # getopt.h # ldint.c # ldlong.c # listiem.c # makefile # msgtext.c # stderr.c # stderr.h # #-------------------- if [ -f ffilter.c -a "$1" != "-c" ] then echo shar: ffilter.c already exists else echo 'x - ffilter.c (4096 characters)' sed -e 's/^X//' >ffilter.c <<'SHAR-EOF' X/* X@(#) File: ffilter.c X@(#) Version: 3.3 X@(#) Last changed: 93/06/29 X@(#) Purpose: Standard File Filter X@(#) Author: J Leffler X@(#)Product: :PRODUCT: X*/ X X/*TABSTOP=4*/ X/*LINTLIBRARY*/ X X#include <stdio.h> X#include <string.h> X X#include "stderr.h" X#include "filter.h" X X#ifndef lint Xstatic char sccs[] = "@(#)ffilter.c 3.3 93/06/29"; X#endif X X#ifdef __STDC__ Xvoid filter(int argc, char **argv, int optind, Filter function) X#else Xvoid filter(argc, argv, optind, function) Xint argc; /* In: Number of arguments */ Xchar **argv; /* In: Argument list of program */ Xint optind; /* In: Offset in list to start at */ XFilter function; /* In: Function to process file */ X#endif /* __STDC__ */ X X/* X Purpose: Standard File Filter X X Maintenance Log X --------------- X 09/03/87 JL Original version stabilised X 18/04/88 JL Now pass fp and file name to function X 15/12/91 JL Upgrade for ANSI C X 29/06/93 JL Rename to filter and accept optind argument X X Comments X -------- X 1. For every non-flag option in the argument list, or standard input X if there are no non-flag arguments, run 'function' on file. X 2. If a file name is '-', use standard input. X 3. The optind argument should normally be the value of optind as X supplied by getopt(3). But it should be the index of the first X non-flag argument. X X*/ X{ X int i; X FILE *fp; X char *file; X X if (argc <= optind) X { X /* Assumes argv[argc] == NIL(char *) and can be assigned to */ X argv[argc] = "-"; X argc++; X } X X for (i = optind; i < argc; i++) X { X if (strcmp(argv[i], "-") == 0) X { X file = "(standard input)"; X (*function)(stdin, file); X } X else if ((fp = fopen(argv[i], "r")) != NULL) X { X file = argv[i]; X (*function)(fp, file); X fclose(fp); X } X else X error2("failed to open file", argv[i]); X } X} X X#ifdef __STDC__ Xvoid ffilter(int argc, char **argv, Filter function) X#else Xvoid ffilter(argc, argv, function) Xint argc; /* In: Number of arguments */ Xchar **argv; /* In: Argument list of program */ XFilter function; /* In: Function to process file */ X#endif /* __STDC__ */ X X/* X Purpose: Compatability function X X Maintenance Log X --------------- X 29/06/93 JL Original version stabilised X X Comments X -------- X 1. The standard calling sequence for ffilter is: X argc -= optind - 1; X argv += optind - 1; X argv[0] = ar