Phil Sidler wrote:
On Tue, 19 Dec 2006 08:49:27 -0700, Steve Comstock
<[EMAIL PROTECTED]> wrote:


  address link pgm parm_string



C does not like this. I cannot seem to find a
combination of code and compiler options that
let me access and printf the parm string and
the length. Does anyone have an example of
doing this, or see how to do it?


Hi Steve,

How about something like this...


#define MIN(a,b) (((a)<(b))?(a):(b))

#pragma environment(RXCLINK)
#pragma runopts(PLIST(OS))

struct argtable_entry {
  void          *argstring_ptr;    /* Address of the argument string */
  int            argstring_length; /* Length of the argument string  */
  };


int RXCLINK(struct argtable_entry * argp) {

  char * ts[256];

  strncpy(ts, argp->argstring_ptr, MIN(argp->argstring_length,sizeof(ts-1)));

  ts[255] = 0;
  printf(ts);

  return(0);
  }


Well, very impressive! But I'm having trouble getting a
clean compile. [Note I changed MAX to MIN as you mentioned
in your second post.]

I get:

strncpy(ts, argp->argstring_ptr, MIN(argp->argstring_length,sizeof(ts-1)));
__strncpy(ts,argp->argstring_ptr,(((argp->argstring_length)<(sizeof(ts-1)))?(argp->argstring_leng\+
..........a....................................................................................... =====> a - CCN3280 Function argument assignment between types "char*" and "char**" is not allowed. th):(sizeof(ts-1)))); +

printf(ts); ........a........................................................................................ ====> a - CCN3280 Function argument assignment between types "const char*" and "char**" is not allowed.



If change the definition of ts to be

char ts[256];

then I get a clean compile, but I abend with S0C1 when
I test.

Is there some simple little syntax thing to fix here?

Kind regards,

-Steve Comstock

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to