Accessing parm_table[] outside of loadparm.c

Steve Litt slitt at troubleshooters.com
Wed Dec 1 14:34:40 GMT 1999


Sorry about this dumb question.

I'm writing a synonym finder program. I'd prefer to make no modifications
to loadparm.c. Given a parameter, I want to walk thru parm_table[], find
the parm whose label matches the parameter, then walk back thru again and
find the labels of all parms whose ptr matches the ptr of the first one found.

Unfortunately, I cannot use lp_next_parameter() because that function skips
over synonyms (if (parm_table[*i].ptr ==parm_table[*i-1].ptr) continue). I
tried the following:

extern struct parm_struct parm_table[];

But because it's static in loadparm.c, the above syntax gave me a link error.

I tried adding the following function to loadparm.c

struct parm_struct *getparm(int ss)
  {
  if (ss < NUMPARAMETERS)
     return(&(parm_table[ss]));
  else
     return(NULL);
  }                

And that worked perfectly and my synonym program now works, but that's an
ugly hack. One shouldn't need to mess up somebody else's tested code just
to write a utility.

What am I missing? If anyone has a suggestion, please send it my way.

Thanks

Steve Litt




More information about the samba-technical mailing list