コード例 #1
0
ファイル: type.c プロジェクト: FDOS/freecom
int cmd_type(char *param)
{
    char buf[256];
    char **argv;
    int argc, opts, ec = E_None;
    int fd, len;

    if((argv = scanCmdline(param, 0, 0, &argc, &opts)) == 0)
        return 1;

    /* Because no option was passed into scanCmdline() no
    	option can have been processed */
    assert(opts == 0);

    if(!argc) {
        error_req_param_missing();
        ec = E_Useage;
        goto errRet;
    }

    for(argc = 0; argv[argc]; ++argc) {
        if((fd = devopen(argv[argc], O_RDONLY)) == 0) {
            error_sfile_not_found(argv[argc]);
            ec = E_Other;
            break;
        }

        while((len = dos_read(fd, buf, sizeof(buf))) >= 0) {
            char *bufp, *p;
            if(cbreak) {
                dos_close(fd);
                ec = E_CBreak;
                goto errRet;
            }
            bufp = buf;
            for(p = buf; p < buf+len; p++) {
                if(*p == 26) break; /* CTRL-Z */
                if(*p == '\r' || *p == '\n') {
                    if(p > bufp) dos_write(1, bufp, p - bufp);
                    if(*p == '\n') dos_write(1, "\r\n", 2);
                    bufp = p + 1;
                }
            }
            dos_write(1, bufp, p - bufp);
            if (len < sizeof(buf) || *p == 26) break;
        }
        dos_close(fd);
        if(cbreak) {
            ec = E_CBreak;
            break;
        }
    }

errRet:
    freep(argv);

    return ec;
}
コード例 #2
0
ファイル: fcbfns.c プロジェクト: TijmenW/FreeDOS
BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode)
{
  sft FAR *s;
  LONG lPosit;
  COUNT nWritten;
  psp FAR *p = MK_FP(cu_psp, 0);

  /* Convert to fcb if necessary                                  */
  lpFcb = ExtFcbToFcb(lpXfcb);

  /* Get the SFT block that contains the SFT      */
  if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1)
    return FALSE;

  /* If this is not opened another error          */
  if (s->sft_count == 0)
    return FALSE;

  /* Now update the fcb and compute where we need to position     */
  /* to.                                                          */
  lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec)
      * lpFcb->fcb_recsiz;
  if (dos_lseek(s->sft_status, lPosit, 0) < 0)
  {
    *nErrorCode = FCB_ERR_EOF;
    return FALSE;
  }

  if (s->sft_flags & SFT_FSHARED)
  {
    nWritten = Remote_RW(REM_WRITE, lpFcb->fcb_recsiz, p->ps_dta, s, nErrorCode);
  }
  else
  {

    /* Do the read                                                  */
    nWritten = dos_write(s->sft_status, p->ps_dta, lpFcb->fcb_recsiz);
  }

  /* Now find out how we will return and do it.                   */
  if (nWritten == lpFcb->fcb_recsiz)
  {
    lpFcb->fcb_fsize = dos_getcufsize(s->sft_status);
    FcbNextRecord(lpFcb);
    *nErrorCode = FCB_SUCCESS;
    return TRUE;
  }
  else if (nWritten <= 0)
  {
    *nErrorCode = FCB_ERR_WRITE;
    return TRUE;
  }
  *nErrorCode = FCB_ERR_WRITE;
  return FALSE;
}
コード例 #3
0
ファイル: deskapp.c プロジェクト: kelihlodversson/emutos
/*
 *  Perform the actual save of the EMUDESK.INF file
 */
static void save_to_disk(void)
{
    LONG ret, len;
    WNODE *w;
    WORD fh = -1;
    BYTE inf_file_name[sizeof(INF_FILE_NAME)];

    /* make sure user really wants to save the desktop */
    if (fun_alert(1, STSVINF) != 1)
        return;

    strcpy(inf_file_name, INF_FILE_NAME);
    inf_file_name[0] += gl_stdrv;   /* Adjust drive letter  */

    ret = dos_create(inf_file_name, 0);
    if (ret >= 0L)
    {
        fh = (WORD) ret;
        len = G.g_afsize - 1;
        ret = dos_write(fh, len, gl_afile);
        dos_close(fh);
        if (ret != len)             /* write error */
            ret = -1L;
    }
    if (ret < 0L)                   /* open error or write error */
        fun_alert(1, STNOINF);

    /*
     * now update any open windows for the directory containing
     * the saved file (as long as the file was created ok).
     */
    if (fh >= 0)                    /* file was created */
    {
        del_fname(inf_file_name);       /* convert to pathname ending in *.* */
        w = fold_wind(inf_file_name);   /* scan for matching windows */
        if (w)                          /* got one:                          */
            fun_rebld(w);               /* rebuild all matching open windows */
    }
}
コード例 #4
0
ファイル: mcopy.c プロジェクト: BiancoZandbergen/RTMINIX3
static int unix_to_dos(MainParam_t *mp)
{
	return dos_write(0, mp, 1);
}
コード例 #5
0
ファイル: mcopy.c プロジェクト: BiancoZandbergen/RTMINIX3
static int dos_to_dos(direntry_t *entry, MainParam_t *mp)
{
	return dos_write(entry, mp, 0);
}