Dear List, Currently, I read this in clientserver.c, line 148. motd = lp_motd_file(); I have googled, but didn't the definition of char *lp_motd_file(void). Can anyone help to explain the following code segment. Many thanks. #line 147 ~ 160, in clientserver.c, version 3.0.5> if (!am_client) { > motd = lp_motd_file(); > if (motd && *motd) { > FILE *f = fopen(motd,"r"); > while (f && !feof(f)) { > int len = fread(buf, 1, bufsiz - 1, f); > if (len > 0) > write_buf(f_out, buf, len); > } > if (f) > fclose(f); > write_sbuf(f_out, "\n"); > } > }$ grep "lp_motd_file" . -R ./proto.h:char *lp_motd_file(void); ./loadparm.c:FN_GLOBAL_STRING(lp_motd_file, &Globals.motd_file) ./clientserver.c: motd = lp_motd_file(); -- Daniel
On Wed 22 Apr 2009, Daniel.Li wrote:> > Currently, I read this in clientserver.c, line 148. > > motd = lp_motd_file(); > > I have googled, but didn't the definition of char *lp_motd_file(void).> $ grep "lp_motd_file" . -R > ./proto.h:char *lp_motd_file(void); > ./loadparm.c:FN_GLOBAL_STRING(lp_motd_file, &Globals.motd_file)So look in loadparm.c ... I'm guessing this is for some school course? If you're reasonably able to read code, that code snippet shouldn't be hard to understand, and if not, ask your teacher, not us :-) Paul
On Wed, 2009-04-22 at 15:54 +0800, Daniel.Li wrote:> Dear List, > > Currently, I read this in clientserver.c, line 148. > > motd = lp_motd_file(); > > I have googled, but didn't the definition of char *lp_motd_file(void). > Can anyone help to explain the following code segment. Many thanks.I got this, just take a closer look at those macros FN_GLOBAL_STRING(lp_motd_file, &Globals.motd_file) #define FN_LOCAL_STRING(fn_name,val) \ char *fn_name(int i) {return((LP_SNUM_OK(i)&&pSERVICE(i)->val)?pSERVICE(i)->val : (sDefault.val?sDefault.val:""));} So, char *lp_motd_file(void) is as below. Well, I still didn't have a clear picture about below function. Any help is mostly appreciated.:) char *lp_motd_file(int i) { return((LP_SNUM_OK(i)&&pSERVICE(i)->&Globals.motd_file)? pSERVICE(i)->&Globals.motd_file : (sDefault.&Globals.motd_file?sDefault.&Globals.motd_file:"")); } -- Daniel