home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / os9 / 1175 < prev    next >
Encoding:
Text File  |  1992-08-29  |  2.7 KB  |  88 lines

  1. Path: sparky!uunet!europa.asd.contel.com!emory!wa4mei!westgac3!tomk
  2. From: tomk@westgac3
  3. Newsgroups: comp.os.os9
  4. Subject: wierd happenings with C compiler
  5. Summary: Can anyone explain these?
  6. Keywords: C compiler
  7. Message-ID: <14@westgac3>
  8. Date: 28 Aug 92 10:09:44 GMT
  9. Organization: West Georgia Color Computer 3
  10. Lines: 76
  11.  
  12. SETUP: Color Computer 3 w/OS9 Level2, C compiler from Level 1, patched for HD.
  13.        Stock libraries replaced by Kreider libraries.
  14.  
  15. Problems .....
  16.  
  17. 1) In the header file from Rick Adams UUCP, There is the entry
  18.    #define PUBDIR "/dd/spool/uucppublic"
  19.  
  20.    While attempting to apply a patch to one of the modules for "uucico"...
  21.  
  22. ssendfile(cline)
  23.         char *cline;
  24. {
  25.         FILE *file;
  26.         static char holdit[200];
  27.  
  28.   (stuff deleted)
  29.  
  30.         if ((index(words[4], 'c') != NULL) && (words[2][0] == '~')) {
  31.            sprintf(holdit,"%s%s",PUBDIR,rindex(words[1],'/'));
  32.            if(debuglvl >= 3) printf("Receiving UNIX file %s.\n",holdit);
  33.  
  34.   (rest of stuff deleted)
  35.  
  36.     When the debug message was printed, I got the following:
  37. Receiving UNIX file /dd/spool/uucppubl/watizit.z
  38.                               ^^^^^^^^
  39.                              what happened?????
  40.  
  41. Anyhow, my fix for that compiler generated booboo was:
  42.       char *dir_pub="/dd/spool/uucppublic";
  43.       ...
  44.       sprintf(holdit,"%s%s",dir_pub,rindex(words[1],'/'));
  45. Again, does anyone know _why_ the compiler truncated the header definition??
  46.  
  47. 2) I was trying to do some fancy footwork with the function "sscanf()", perhaps
  48. someone can explain this one...
  49.  
  50. typedef struct {
  51.          char name[32],
  52.               passwd[40];
  53.          int  uid,
  54.               priority;
  55.          char execution[80],
  56.               homebase[80],
  57.               startpgm[80];
  58.       } PSWD;
  59.  
  60. fetch_pw()
  61. {
  62.     PSWD *p, pwd;
  63.     FILE *f, fopen();
  64.     (etc.)
  65.  
  66.     p = &pwd;
  67.  
  68.     (open system password file and place entry into char buffer, "cbuf")
  69.  
  70.     sscanf(cbuf,"%[^,],%[^,],%d,%d,%[^,],%[^,],%s",p->name,p->passwd,
  71.     p->uid,p->priority,p->execution,p->homebase,p->startpgm);
  72.  
  73.     printf("%s %s %d %d %s %s %s\n",p->name,p->passwd,p->uid,p->priority,
  74.     p->execution,p->homebase,p->startpgm);
  75.  
  76.     (and continue with rest of file)
  77. }
  78. The result that I get from fetch_pw() is the first string and all other
  79. parts of the struct are NULL/ZIPPO/NADA. I then replaced the struct
  80. access with individual variables and adjusted the sscanf() & printf() to
  81. fill those variables and the _same_ result. Does anyone have a clue as
  82. to why sscanf() won't parse the string correctly???
  83.  
  84.  -- 
  85. Thomas Kocourek  KD4CIK                       :UUCP on an OS9 system,
  86. UUCP: ...!{emory,gatech}!wa4mei!westgac3!tomk :Multitasking & windows in
  87. INTERNET tomk@westgac3                        :512KBytes - All in a COCO3!
  88.