示例#1
0
static int jump_to_segment(int newsegi, struct seginfo *csp)
{
  if(newsegi <= segi) {
    segi = 0;
    isbeg();
    /*fseek(tapefp, firstseg_offs, SEEK_SET);*/
    rb->lseek(tapefd, firstseg_offs, SEEK_SET);
  }
  else if(!end_seg(csp)) return 0;

  while(segi != newsegi) {
    if(!read_header(rbuf, csp)) return 0;
    if(!end_seg(csp)) return 0;
  }
  return 1;
}
示例#2
0
static int end_seg(struct seginfo *csp)
{
  if(!segbeg) {
    if(csp->len != csp->ptr) {
      /*fseek(tapefp, tf_cseg.len - tf_cseg.ptr - 1, SEEK_CUR);*/
        rb->lseek(tapefd, tf_cseg.len - tf_cseg.ptr - 1, SEEK_CUR);

      if(getc(tapefd) == EOF) {
        premature(csp);
        return 0;
      }
    }
    segi++;
    isbeg();
  }
  playstate = PL_NONE;
  return 1;
}
示例#3
0
文件: getspool.c 项目: pgul/lgate
static int rmailfunc(char *addrlist)
{
  char *p, *p1;
  int  r, noaddr=1;

  conf=0;
  cnews=0;
  debug(4, "rmailfunc(\"%s\")", addrlist);
  p=addrlist;
  while (isspace(*p)) p++;
  for (; *p; lseek(fileno(stdin), 0, SEEK_SET))
  {
    for (p1=p; *p1 && !isspace(*p1); p1++);
    if (p1-p>=sizeof(addr))
    { logwrite('?', "Too long address\n");
      return 1;
    }
    strncpy(addr, p, (int)(p1-p));
    addr[(int)(p1-p)]='\0';
    ibufsrc=BUFSIZE;
    msgsize=-1;
    if (!myfgets(gotstr, sizeof(gotstr)))
    { logwrite('?', "Incorrect message\n");
      return 1;
    }
    if (isbeg(gotstr)!=0)
    { logwrite('?', "Incorrect message start\n");
      return 1;
    }
    r=msg_unmime(-1);
    if (r) return r;
    noaddr=0;
    for (p=p1; isspace(*p); p++);
  }
  debug(4, "rmailfunc ok");
  return noaddr;
}
示例#4
0
int open_tapefile(char *name, int type)
{
  int res;
  int ok;

  seg_desc[0] = '\0';
  currlev = 0;

  if(type != TAP_TAP && type != TAP_TZX) {
    rb->snprintf(seg_desc,DESC_LEN, "Illegal tape type");
    return 0;
  }

  /*tapefp = fopen(name, "rb");*/
  tapefd = rb->open(name, O_RDONLY);
  if(tapefd < 0 ) {
    /*rb->snprintf(seg_desc,DESC_LEN, "Could not open `%s': %s", name, strerror(errno));*/
    return 0;
  }
  
  tf_tpi.type = type;
  tf_cseg.pause = DEF_LEAD_PAUSE;
  INITTAPEOPT(tapeopt);

  currsegi = segi = 0;
  isbeg();

  firstseg_offs = 0;
  
  ok = 1;
  
  if(tf_tpi.type == TAP_TZX) {
    
    firstseg_offs = 10;
    res = readbuf(rbuf, 10, tapefd);
    if(res == 10 && rb->strncasecmp((char *)rbuf, tzxheader, 8) == 0) {
      tf_tpi.tzxmajver = rbuf[8];
      tf_tpi.tzxminver = rbuf[9];
      
      if(tf_tpi.tzxmajver > TZXMAJPROG) {
    rb->snprintf(seg_desc, DESC_LEN,
        "Cannot handle TZX file version (%i.%02i)", 
        tf_tpi.tzxmajver, tf_tpi.tzxminver);
    ok = 0;
      }
    }
    else {
      rb->snprintf(seg_desc,DESC_LEN, "Illegal TZX file header");
      ok = 0;
    }
  }
  
  if(!ok) {
    close_tapefile();
    return 0;
  }
  endnext = 0;

  loopctr = 0;
  callctr = 0;

  return 1;
}