[BACK]Return to apprentice.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / file

Diff for /src/usr.bin/file/Attic/apprentice.c between version 1.4 and 1.5

version 1.4, 1997/02/09 23:58:16 version 1.5, 1998/07/10 15:05:13
Line 32 
Line 32 
 #include <string.h>  #include <string.h>
 #include <ctype.h>  #include <ctype.h>
 #include <errno.h>  #include <errno.h>
   #include <err.h>
 #include "file.h"  #include "file.h"
   
 #ifndef lint  #ifndef lint
Line 66 
Line 67 
         magic = (struct magic *) calloc(sizeof(struct magic), maxmagic);          magic = (struct magic *) calloc(sizeof(struct magic), maxmagic);
         mfn = malloc(strlen(fn)+1);          mfn = malloc(strlen(fn)+1);
         if (magic == NULL || mfn == NULL) {          if (magic == NULL || mfn == NULL) {
                 (void) fprintf(stderr, "%s: Out of memory.\n", progname);                  warn("malloc");
                 if (check)                  if (check)
                         return -1;                          return -1;
                 else                  else
Line 84 
Line 85 
                 fn = p;                  fn = p;
         }          }
         if (errs == -1)          if (errs == -1)
                 (void) fprintf(stderr, "%s: couldn't find any magic files!\n",                  warnx("couldn't find any magic files!");
                                progname);  
         if (!check && errs)          if (!check && errs)
                 exit(1);                  exit(1);
   
Line 107 
Line 107 
         f = fopen(fn, "r");          f = fopen(fn, "r");
         if (f==NULL) {          if (f==NULL) {
                 if (errno != ENOENT)                  if (errno != ENOENT)
                         (void) fprintf(stderr,                          warn(fn);
                         "%s: can't read magic file %s (%s)\n",  
                         progname, fn, strerror(errno));  
                 return -1;                  return -1;
         }          }
   
Line 165 
Line 163 
                 case STRING:                  case STRING:
                         break;                          break;
                 default:                  default:
                         magwarn("can't happen: m->type=%d\n",                          warnx("can't happen: m->type=%d\n", m->type);
                                 m->type);  
                         return -1;                          return -1;
                 }                  }
         return v;          return v;
Line 190 
Line 187 
             if ((magic = (struct magic *) realloc(magic,              if ((magic = (struct magic *) realloc(magic,
                                                   sizeof(struct magic) *                                                    sizeof(struct magic) *
                                                   maxmagic)) == NULL) {                                                    maxmagic)) == NULL) {
                 (void) fprintf(stderr, "%s: Out of memory.\n", progname);                  warn("malloc");
                 if (check)                  if (check)
                         return -1;                          return -1;
                 else                  else
Line 219 
Line 216 
         /* get offset, then skip over it */          /* get offset, then skip over it */
         m->offset = (int) strtoul(l,&t,0);          m->offset = (int) strtoul(l,&t,0);
         if (l == t)          if (l == t)
                 magwarn("offset %s invalid", l);                  warnx("offset %s invalid", l);
         l = t;          l = t;
   
         if (m->flag & INDIR) {          if (m->flag & INDIR) {
Line 243 
Line 240 
                                 m->in.type = BYTE;                                  m->in.type = BYTE;
                                 break;                                  break;
                         default:                          default:
                                 magwarn("indirect offset type %c invalid", *l);                                  warnx("indirect offset type %c invalid", *l);
                                 break;                                  break;
                         }                          }
                         l++;                          l++;
Line 257 
Line 254 
                 else                  else
                         t = l;                          t = l;
                 if (*t++ != ')')                  if (*t++ != ')')
                         magwarn("missing ')' in indirect offset");                          warnx("missing ')' in indirect offset");
                 l = t;                  l = t;
         }          }
   
Line 318 
Line 315 
                 m->type = LEDATE;                  m->type = LEDATE;
                 l += NLEDATE;                  l += NLEDATE;
         } else {          } else {
                 magwarn("type %s invalid", l);                  warnx("type %s invalid", l);
                 return -1;                  return -1;
         }          }
         /* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */          /* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */
Line 364 
Line 361 
         /*          /*
          * TODO finish this macro and start using it!           * TODO finish this macro and start using it!
          * #define offsetcheck {if (offset > HOWMANY-1)           * #define offsetcheck {if (offset > HOWMANY-1)
          *      magwarn("offset too big"); }           *      warnx("offset too big"); }
          */           */
   
         /*          /*

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5