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

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

version 1.4, 2003/06/10 22:20:48 version 1.5, 2004/05/14 04:27:26
Line 37 
Line 37 
  * POSSIBILITY OF SUCH DAMAGE.   * POSSIBILITY OF SUCH DAMAGE.
  */   */
   
   #include <sys/types.h>
   #include <sys/stat.h>
   #include <sys/ioctl.h>
   #include <sys/midiio.h>
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
   #include <limits.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <err.h>  #include <err.h>
 #include <unistd.h>  #include <unistd.h>
 #include <string.h>  #include <string.h>
 #include <sys/types.h>  
 #include <sys/stat.h>  
 #include <sys/ioctl.h>  
 #include <sys/midiio.h>  
   
 #define DEVMUSIC "/dev/music"  #define DEVMUSIC "/dev/music"
   
Line 130 
Line 132 
 void  void
 usage(void)  usage(void)
 {  {
         printf("Usage: %s [-d unit] [-f file] [-l] [-m] [-q] [-t tempo] [-v] [-x] [file ...]\n",          printf("Usage: %s [-d unit] [-f file] [-l] [-m] [-q] [-t tempo]"
                 __progname);              "[-v] [-x] [file ...]\n", __progname);
         exit(1);          exit(1);
 }  }
   
Line 244 
Line 246 
 void  void
 playfile(FILE *f, char *name)  playfile(FILE *f, char *name)
 {  {
         u_char *buf;          u_char *buf, *newbuf;
         u_int tot, n, size, nread;          u_int tot, n, size, newsize, nread;
   
         /*          /*
          * We need to read the whole file into memory for easy processing.           * We need to read the whole file into memory for easy processing.
Line 255 
Line 257 
          */           */
         size = 1000;          size = 1000;
         buf = malloc(size);          buf = malloc(size);
         if (buf == 0)          if (buf == NULL)
                 errx(1, "malloc() failed");                  err(1, "malloc() failed");
         nread = size;          nread = size;
         tot = 0;          tot = 0;
         for (;;) {          for (;;) {
Line 266 
Line 268 
                         break;                          break;
                 /* There must be more to read. */                  /* There must be more to read. */
                 nread = size;                  nread = size;
                 size *= 2;                  newsize = size * 2;
                 buf = realloc(buf, size);                  newbuf = realloc(buf, newsize);
                 if (buf == NULL)                  if (newbuf == NULL)
                         errx(1, "realloc() failed");                          err(1, "realloc() failed");
                   buf = newbuf;
                   size = newsize;
         }          }
         playdata(buf, tot, name);          playdata(buf, tot, name);
         free(buf);          free(buf);
Line 318 
Line 322 
                 return;                  return;
         tracks = malloc(ntrks * sizeof(struct track));          tracks = malloc(ntrks * sizeof(struct track));
         if (tracks == NULL)          if (tracks == NULL)
                 errx(1, "malloc() tracks failed");                  err(1, "malloc() tracks failed");
         for (t = 0; t < ntrks; ) {          for (t = 0; t < ntrks; ) {
                 if (p >= end - MARK_LEN - SIZE_LEN) {                  if (p >= end - MARK_LEN - SIZE_LEN) {
                         warnx("Cannot find track %d", t);                          warnx("Cannot find track %d", t);
Line 484 
Line 488 
         char *file = DEVMUSIC;          char *file = DEVMUSIC;
         struct synth_info info;          struct synth_info info;
         FILE *f;          FILE *f;
           const char *errstr;
   
         while ((ch = getopt(argc, argv, "?d:f:lmqt:vx")) != -1) {          while ((ch = getopt(argc, argv, "?d:f:lmqt:vx")) != -1) {
                 switch(ch) {                  switch (ch) {
                 case 'd':                  case 'd':
                         unit = atoi(optarg);                          unit = strtonum(optarg, 0, INT_MAX, &errstr);
                           if (errstr)
                                   errx(1, "unit is %s: %s", errstr, optarg);
                         break;                          break;
                 case 'f':                  case 'f':
                         file = optarg;                          file = optarg;
Line 503 
Line 510 
                         play = 0;                          play = 0;
                         break;                          break;
                 case 't':                  case 't':
                         ttempo = atoi(optarg);                          ttempo = strtonum(optarg, 0, INT_MAX, &errstr);
                           if (errstr)
                                   errx(1, "tempo is %s: %s", errstr, optarg);
                         break;                          break;
                 case 'v':                  case 'v':
                         verbose++;                          verbose++;

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