⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 command.c

📁 mpeg 解复用
💻 C
📖 第 1 页 / 共 3 页
字号:
  } else {    set_lastfile (name);  }  if (name != NULL) {    if ((!forcereopen)     && ((f = input_existfile (name)) != NULL)) {      warn (LIMP,"Open Existing",ECOM,3,2,f);    } else {      f = input_openfile (name,filerefnum,content,automatic,programnb);      if (f != NULL) {        filerefer_forget (filerefnum);      }    }  } else {    fprintf (stderr, "Missing file name\n");    f = NULL;  }  return (f);}/* Parse a token word to see if it is a number in range low..high. * high=-1 denotes upper limit = infinite. * Precondition: low>=0 * Return: Number if parsed, -1 otherwise. */static long com_number (char *t,    long low,    long high){  long i;  char *e;  if (t == NULL) {    return (-1);  } else if (token_code (t) >= 0) {    return (-1);  }  errno = 0;  i = strtol (t,&e,0);  if (errno != 0) {    return (-1);  } else if (*e != 0) {    return (-1);  } else if ((i < low) || ((high >= low) && (i > high))) {    fprintf (stderr, "Number out of bounds: %ld\n", i);    return (-1);  } else {    return (i);  }}static void command_toofew (void){  fprintf (stderr, "Too few or bad arguments.\n");}/* Process one line of command words. * Precondition: argc==WordCount and argi==1 and comarg^==Word[0] * Return: TRUE, if processed ok, FALSE otherwise. */static boolean command (void){  char *fn;  int rn;  file_descr *f;  char *t;  boolean r;  boolean frop;  r = TRUE;  frop = FALSE;  t = available_token ();  while (r && (t != NULL)) {    next_token ();    warn (LIMP,"Command",ECOM,1,0,token_code(t));    switch (token_code (t)) {      case C_OPES:        fn = available_token ();        rn = com_number (fn,0,-1);        if (rn >= 0) {          fn = filerefer_name (rn);        }        if (fn != NULL) {          int tprg, tsid;          if (splice_multipleprograms) {            next_token ();            tprg = com_number (available_token (),0x0001L,0xFFFFL);          } else {            tprg = 0;          }          if (tprg >= 0) {            next_token ();            tsid = com_number (available_token (),0x00,0xFF);            if ((!fileagain (fn))             && (tsid < 0)) {              f = openfile (fn,rn,ct_packetized,TRUE,tprg,frop);              if (f == NULL) {                r = FALSE;              }            } else {              if (tsid >= 0) {                next_token ();                f = openfile (fn,rn,ct_packetized,FALSE,0,frop);                if (f != NULL) {                  f->u.pes.stream =                    connect_streamprog (                      f,tprg,0,tsid,guess_streamtype (tsid),f->u.pes.stream,                      NULL,TRUE);                } else {                  r = FALSE;                }              } else {                command_toofew ();                r = FALSE;              }            }          } else {            command_toofew ();            r = FALSE;          }        } else {          command_toofew ();          r = FALSE;        }        frop = FALSE;        break;      case C_OPS:        fn = available_token ();        rn = com_number (fn,0,-1);        if (rn >= 0) {          fn = filerefer_name (rn);        }        if (fn != NULL) {          int tprg, tsid, ssid;          if (splice_multipleprograms) {            next_token ();            tprg = com_number (available_token (),0x0001L,0xFFFFL);          } else {            tprg = 0;          }          if (tprg >= 0) {            next_token ();            ssid = com_number (available_token (),0x00,0xFF);            if ((!fileagain (fn))             && (ssid < 0)) {              f = openfile (fn,rn,ct_program,TRUE,tprg,frop);              if (f == NULL) {                r = FALSE;              }            } else {              if (ssid >= 0) {                next_token ();                f = openfile (fn,rn,ct_program,FALSE,0,frop);                if (f != NULL) {                  tsid = com_number (available_token (),0x00,0xFF);                  if (tsid >= 0) {                    next_token ();                  }                  f->u.ps.stream[ssid] =                    connect_streamprog (                      f,tprg,ssid,tsid<0?-ssid:tsid,                      guess_streamtype (tsid<0?ssid:tsid),                      f->u.ps.stream[ssid],f->u.ps.stream[0],TRUE);                } else {                  r = FALSE;                }              } else {                command_toofew ();                r = FALSE;              }            }          } else {            command_toofew ();            r = FALSE;          }        } else {          command_toofew ();          r = FALSE;        }        frop = FALSE;        break;      case C_OTS:        fn = available_token ();        rn = com_number (fn,0,-1);        if (rn >= 0) {          fn = filerefer_name (rn);        }        if (fn != NULL) {          int sprg, tprg, tsid, ssid;          next_token ();          sprg = com_number (available_token (),0x0000L,0xFFFFL);          if ((!fileagain (fn))           && (sprg < 0)) {            f = openfile (fn,rn,ct_transport,TRUE,0,frop);          } else {            if (sprg >= 0) {              f = openfile (fn,rn,ct_transport,FALSE,0,frop);              if (splice_multipleprograms) {                next_token ();                tprg = com_number (available_token (),0x0001L,0xFFFFL);              } else {                tprg = 0;              }              if (tprg >= 0) {                next_token ();                ssid = com_number (available_token (),0x00,0xFF);                if (ssid >= 0) {                  next_token ();                  tsid = com_number (available_token (),0x00,0xFF);                  if (tsid >= 0) {                    next_token ();                  } else {                    tsid = -ssid;                  }/*                  if (stream yet open somewhere) {                    connect_streamprog (...);                    f = NULL;                  }*/                } else {                  ssid = -1;                  tsid = -1;                }              } else {                tprg = sprg;                ssid = -1;                tsid = -1;              }              if ((sprg == 0)               && (ssid < 0)) { /* if sprg=0, then tprg & ssid obligatory */                command_toofew ();                r = FALSE;              } else {                if (f != NULL) {                  tsauto_descr *a;                  a = malloc (sizeof (tsauto_descr));                  if (a != NULL) {                    a->next = f->u.ts.tsauto;                    a->sprg = sprg;                    a->tprg = tprg;                    a->ssid = ssid;                    a->tsid = tsid;                    f->u.ts.tsauto = a;                  }                }              }            } else {              command_toofew ();              r = FALSE;            }          }        } else {          command_toofew ();          r = FALSE;        }        frop = FALSE;        break;      case C_CLOS:        fn = available_token ();        rn = com_number (fn,0,-1);        if (rn >= 0) {          fn = filerefer_name (rn);        }        if (fn != NULL) {          next_token ();          f = input_filereferenced (rn,fn);          if (f != NULL) {            input_stopfile (f);            set_lastfile (fn);          } else {            warn (LWAR,"File not open",ECOM,1,4,0);            r = FALSE;          }        } else {          command_toofew ();          r = FALSE;        }        break;      case C_APPE:        fn = available_token ();        rn = com_number (fn,0,-1);        if (rn >= 0) {          fn = filerefer_name (rn);        }        if (fileagain (fn)) {          fn = lastfile;        }        if (fn != NULL) {          next_token ();          f = input_filereferenced (rn,fn);          if (f != NULL) {            fn = available_token ();            rn = com_number (fn,0,-1);            if (rn >= 0) {              fn = filerefer_name (rn);            }            if (fn != NULL) {              next_token ();              if (f->append_name != NULL) {                free (f->append_name);              }              if ((f->append_name = malloc (strlen (fn) + 1)) != NULL) {                int rept;                strcpy (f->append_name,fn);                f->append_filerefnum = rn;                filerefer_forget (rn);                rept = com_number (available_token (),0,-1);                if (rept >= 0) {                  next_token ();                  f->append_repeatitions = rept-1;                } else {                  f->append_repeatitions = 0;                }              }            } else {              command_toofew ();              r = FALSE;            }          } else {            warn (LWAR,"File not open",ECOM,1,5,0);            r = FALSE;          }        } else {          command_toofew ();          r = FALSE;        }        break;      case C_FILE:        rn = com_number (available_token (),0,-1);        if (rn >= 0) {          next_token ();          fn = available_token ();          if (fn != NULL) {            filerefer_remind (rn,fn);            set_lastfile (fn);            next_token ();          } else {            command_toofew ();            r = FALSE;          }        } else {          command_toofew ();          r = FALSE;        }        break;      case C_CROP:        {          int tprg, tsid;          prog_descr *p;          stream_descr *s;          if (splice_multipleprograms) {            tprg = com_number (available_token (),0x0000L,0xFFFFL);            next_token ();          } else {            tprg = 0;          }          if (tprg >= 0) {            p = splice_getprog (tprg);            if (p != NULL) {              tsid = com_number (available_token (),0x00,0xFF);              if (tsid >= 0) {                next_token ();                s = get_streamprog (p,tsid);                if (s != NULL) {                  remove_streamprog (s,p);                } else {                  warn (LWAR,"Stream not found",ECOM,1,3,0);                  r = FALSE;                }              } else {                splice_closeprog (p);              }            } else {              warn (LWAR,"Program not found",ECOM,1,2,0);              r = FALSE;            }          } else {            command_toofew ();            r = FALSE;          }          frop = FALSE;        }        break;      case C_VERB:        if ((verbose_level             = com_number (available_token (),0,LDEB)) >= 0) {          next_token ();        } else {          verbose_level = LWAR;        }        break;      case C_VERS:        fprintf (stderr, "1.0.2\n");        if (first) {          force_quit = TRUE;        }        break;      case C_HELP:        command_help ();        if (first) {          r = FALSE;        }        break;      case C_QUIT:        force_quit = TRUE;        break;      case C_BUSY:        {          int busy;          busy = com_number (available_token (),0,1);          busy_work = (busy != 0);          if (busy >= 0) {            next_token ();          }        }        break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -