× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.





Hi Simon,

I hit send by accident on a message a few minutes ago.

My partner who wrote this code is deceased. I'm able to fix/change most
normal user application level stuff in C with some struggling, but some
of the lower level tool type functions he wrote are confusing to me.
Fortunately there hasn't been much that needs changing because this C
code is all server stuff and 95% of the application is client stuff that
I wrote in RPG. I do use APIs in RPG but then I'm doing so with an
understanding of what I need going in. This I don't understand.

Could you please suggest a change to this code which replaces that which
you view as no longer able to work. I've removed the reference to
PC_DOS. I'll be doing this at V4R5.

Thank you for your enlightenment so far and for anything you might
further suggest.

Steve Moland
Access Paths Inc
12 Parmenter Rd Unit C4
Londonderry NH 03053
603 845-0190 Ext 2
603 315-0340 Cell
steve@xxxxxxxxxxx

===============================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "trerror.h"
#include "strutil.h"
#if defined(AS400)
#include <signal.h>
#include <setjmp.h>
#include <miptrnam.h>
#include "qusrtool/qattsysc(opusapi)"
#endif

/********************************************************************
* Program.....: GETINVAR
* Date........: August 1993
* Copyright...: Copyright (c) 1993 Access Paths Inc
* Version.....: ILE C/400, Watcom C/C++
* Modified....:
* Description.:
*
* This program reads the *LIBL/TRECSINI User Space or or
%path%\TRECS.INI,
* looks up the variable name passed, and returns the value assigned to
the
* variable as a NULL terminated string.
*
* Parameters passed are 1. INI user space name defaults to
*LIBL/TRECSINI
* 2. Variable name
* 3. Variable value returned to caller
#if defined(AS400)
* 4. (optional) length of target area
#endif
********************************************************************/

#define TRUE 1
#define FALSE 0

int givcfghex(char *, int);
char *givcfgvar(char *);
int givcfgint(char *);
double givcfgflt(char *);
char *givcfgstr(char *);
char *stpblk(char *);
extern char *Errwrk;

#define BADPTR 0 /* CMPPTRT (MI Instruction) operand 2 type
*/
#define SYSPTR 1
#define SPCPTR 2
#define DTAPTR 3
#define INSPTR 4
#define _MAX_PATH 45

typedef struct error_code_t {
int byte_provided;
int byte_available;
char exception_id[7];
char reserve;
char exception_data[256];
} ERROR_CODE_T;

int main(int argc, char *argv[])
{
char uspname[21],usplib[11],uspfile[11],uspmbr[11],uspfmt[11];
char uspextattr[11]="USP ";
char *uspptr;
char *cfgbuf=NULL, *vptr, *p1, scmd[40];
int rc,val,w1, libele, varele, valele, varlen;
char cfgpath[_MAX_PATH],var[81];
D0100FMT d0100;
ERROR_CODE_T e0100;

if (argc >= 4)
{
libele = 1;
varele = 2;
valele = 3;
if (argc >=5)
varlen = atoi(argv[4]);
else
varlen = 0;
if (cmpptrt(argv[libele],SPCPTR)==TRUE)
{
for (w1=0;argv[libele][w1] !='\0' && w1<80;w1++)
{
if (argv[libele][w1] == ' ')
{
argv[libele][w1] = '\0';
break;
}
}
if (strlen(argv[libele])==0 ||
strlen(argv[libele])>_MAX_PATH)
strcpy(cfgpath,"*LIBL/TRECSINI");
else
strcpy(cfgpath,argv[libele]);
}
else
strcpy(cfgpath,"*LIBL/TRECSINI");
lfnsplit(cfgpath,usplib,uspfile,uspmbr,uspfmt);
sprintf(scmd,"%-10.10s%-10.10s",uspfile,usplib);
memset(&e0100,0,sizeof(e0100));
e0100.byte_provided = sizeof(e0100);
QUSROBJD(&d0100,sizeof(d0100),"OBJD0100",scmd,"*USRSPC
",&e0100);
if (e0100.byte_available == 0)
{
strcpy(usplib,d0100.return_library);
sprintf(scmd,"%-10.10s%-10.10s",uspfile,usplib);
QUSPTRUS(scmd,&cfgbuf);
}
else
{
if (varlen > 0)
memset(argv[valele],' ',varlen);
else
strcpy(argv[valele],"");
exit(1);
}
if (cfgbuf == NULL)
{
if (varlen > 0)
memset(argv[valele],' ',varlen);
else
strcpy(argv[valele],"");
exit(2);
}
memset(var,0,sizeof(var));
for (w1=0;argv[varele][w1] !='\0' && w1<80;w1++)
{
if ((*(var+w1) = toupper(argv[varele][w1])) == ' ')
{
*(var+w1) = '\0';
break;
}
}
if (varlen > 0)
memset(argv[valele],' ',varlen);
else
strcpy(argv[valele],"");
while (*cfgbuf != '\0')
{
if (*(stpblk(cfgbuf)) != '*')
{
vptr=givcfgvar(cfgbuf);
strupr(vptr);
if (strcmp(var,vptr)==0)
{
vptr = givcfgstr(vptr+strlen(vptr)+1);
if (varlen > 0)
strncpy(argv[valele],vptr,strlen(vptr));
else
strcpy(argv[valele],vptr);
break;
}
}
cfgbuf = strchr(cfgbuf,'\0') + 1;
}
if (*cfgbuf == '\0')
rc = 3;
else
rc = 0;
}
return(rc);
}




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.