コード例 #1
0
ファイル: mesg.c プロジェクト: gallexis/M1
void Producteur(t_fmsg *f) {
	int i;

	printf("Producteur numéro %d \n", getfid());

	
	for (i = 0; i < NBMSGPROD; i++) {
		char *msg;
		if ((msg = malloc(80)) == NULL) {
			perror("Prod - malloc");
			exit(1);
		}
		sprintf(msg, "MESSAGE Numero %d", i);
		DeposerFile(f, (void *)msg);
		printf("Production %d de %d\n", i, getfid());
	}
}
コード例 #2
0
ファイル: mesg.c プロジェクト: gallexis/M1
void Consommateur(t_fmsg *f) {
	int i, exp;

	printf("Consommateur numéro %d \n", getfid());

	
	for (i = 0; i < NBMSGPROD*NBPROD; i++) {
		char *msg;
		msg = (char *) RetirerFile(f, &exp);
		printf("From : %d, %s\n", exp, msg);
		free(msg);
	}
}
コード例 #3
0
ファイル: filerepair.c プロジェクト: krichter722/coda
int main(int argc, char **argv) {
    struct stat statbuf;
    int rc;
    ViceFid fixfid;
    char fixrealm[MAXHOSTNAMELEN];
    vv_t fixvv;
    char fixpath[MAXPATHLEN];
    struct ViceIoctl vioc;
    char space[2048];

    if (argc != 3) {
	fprintf(stderr, "Usage: %s <inc-file-name> <merged-file-name>\n", argv[0]);
	exit(-1);
    }

    /*  make sure repair file exists  */
    rc = stat(argv[2], &statbuf);
    if (rc != 0) {
	fprintf(stderr, "Couldn't find %s(errno = %d)\n", argv[2], errno);
	exit(-1);
    }
    if (!(statbuf.st_mode & S_IFREG)) {
	fprintf(stderr, "File %s cannot be used for repair\n", argv[2]);
	exit(-1);
    }

    if (!getfid(argv[2], &fixfid, fixrealm, &fixvv))
	sprintf(fixpath, "@%08x.%08x.%08x@%s", fixfid.Volume, fixfid.Vnode, fixfid.Unique, fixrealm);
    else strcpy(fixpath, argv[2]);
	
    /* do the repair */
    vioc.in_size = (short)(1+strlen(fixpath));
    vioc.in = fixpath;
    vioc.out_size = (short)sizeof(space);
    vioc.out = space;
    memset(space, 0, sizeof(space));
    rc = pioctl(argv[1], _VICEIOCTL(_VIOC_REPAIR), &vioc, 0);
    if (rc < 0 && errno != ETOOMANYREFS) {
	fprintf(stderr, "Error %d for repair\n", errno);
	exit(-1);
    }
	
    if (stat(argv[1], &statbuf)) 
	exit(-1);
    exit(0);
}
コード例 #4
0
ファイル: cpu.c プロジェクト: 99years/plan9
void
notefs(int fd)
{
	uchar buf[IOHDRSZ+Maxfdata];
	int i, n, ncpunote;
	Fcall f;
	Qid wqid[MAXWELEM];
	Fid *fid, *nfid;
	int doreply;

	rfork(RFNOTEG);
	fmtinstall('F', fcallfmt);

	for(n = 0; n < Nfid; n++){
		fids[n].file = -1;
		fids[n].omode = -1;
	}

	ncpunote = 0;
	for(;;){
		n = read9pmsg(fd, buf, sizeof(buf));
		if(n <= 0){
			if(dbg)
				fprint(2, "read9pmsg(%d) returns %d: %r\n", fd, n);
			break;
		}
		if(convM2S(buf, n, &f) <= BIT16SZ)
			break;
		if(dbg)
			fprint(2, "notefs: ->%F\n", &f);
		doreply = 1;
		fid = getfid(f.fid);
		if(fid == nil){
nofids:
			f.type = Rerror;
			f.ename = Enofile;
			fsreply(fd, &f);
			continue;
		}
		switch(f.type++){
		default:
			f.type = Rerror;
			f.ename = "unknown type";
			break;
		case Tflush:
			flushreq(f.oldtag);
			break;
		case Tversion:
			if(f.msize > IOHDRSZ+Maxfdata)
				f.msize = IOHDRSZ+Maxfdata;
			break;
		case Tauth:
			f.type = Rerror;
			f.ename = "authentication not required";
			break;
		case Tattach:
			f.qid = fstab[Qdir].qid;
			fid->file = Qdir;
			break;
		case Twalk:
			nfid = nil;
			if(f.newfid != f.fid){
				nfid = getfid(f.newfid);
				if(nfid == nil)
					goto nofids;
				nfid->file = fid->file;
				fid = nfid;
			}
			for(i=0; i<f.nwname && i<MAXWELEM; i++){
				if(fid->file != Qdir){
					f.type = Rerror;
					f.ename = Enotdir;
					break;
				}
				if(strcmp(f.wname[i], "..") == 0){
					wqid[i] = fstab[Qdir].qid;
					continue;
				}
				if(strcmp(f.wname[i], "cpunote") != 0){
					if(i == 0){
						f.type = Rerror;
						f.ename = "file does not exist";
					}
					break;
				}
				fid->file = Qcpunote;
				wqid[i] = fstab[Qcpunote].qid;
			}
			if(nfid != nil && (f.type == Rerror || i < f.nwname))
				nfid ->file = -1;
			if(f.type != Rerror){
				f.nwqid = i;
				for(i=0; i<f.nwqid; i++)
					f.wqid[i] = wqid[i];
			}
			break;
		case Topen:
			if(f.mode != OREAD){
				f.type = Rerror;
				f.ename = Eperm;
				break;
			}
			fid->omode = f.mode;
			if(fid->file == Qcpunote)
				ncpunote++;
			f.qid = fstab[fid->file].qid;
			f.iounit = 0;
			break;
		case Tread:
			if(fsread(fd, fid, &f) < 0)
				goto err;
			doreply = 0;
			break;
		case Tclunk:
			if(fid->omode != -1 && fid->file == Qcpunote){
				ncpunote--;
				if(ncpunote == 0)	/* remote side is done */
					goto err;
			}
			fid->file = -1;
			fid->omode = -1;
			break;
		case Tstat:
			if(fsstat(fd, fid, &f) < 0)
				goto err;
			doreply = 0;
			break;
		case Tcreate:
		case Twrite:
		case Tremove:
		case Twstat:
			f.type = Rerror;
			f.ename = Eperm;
			break;
		}
		if(doreply)
			if(fsreply(fd, &f) < 0)
				break;
	}
err:
	if(dbg)
		fprint(2, "notefs exiting: %r\n");
	werrstr("success");
	postnote(PNGROUP, exportpid, "kill");
	if(dbg)
		fprint(2, "postnote PNGROUP %d: %r\n", exportpid);
	close(fd);
}
コード例 #5
0
ファイル: lp.c プロジェクト: DanIverson/OpenVnmrJ
/*-----------------------------------------------
|						|
|		    lpcmd()			|
|						|
|  This function performs 1D LP on a single	|
|  or arrayed FID data set. A new fid file      |
|  is write to argv[1] or curexpdir/lp.fid      |
|  if not specified.                            |
|						|
+----------------------------------------------*/
int lpcmd(int argc, char *argv[], int retc, char *retv[])
{
  char		filepath[MAXPATHL];
  int		status,
		res,
		cblock,
		lastcblock,
		blocksdone,
		lsfidx,
		fidnum = 0,
		arg_no,
		npx,
		npadj,
		ftflag,
		noreal,
		element_no,
		lastfid,
		first,
		last,
		step,
		i,
		ctcount,
		realt2data;
  float		*outp;
  dpointers	inblock;
  dpointers	outblock;
  dfilehead	fidhead,
		datahead,
		phasehead;
  lpstruct	parLPinfo;
  ftparInfo	ftpar;
  char		newfidpath[MAXPATHL];

  Wturnoff_buttons();
  ftpar.procstatus = (CMPLX_t2|LP_F2PROC);

/************************************
*  Initialize all parameterizeable  *
*  variables                        *
************************************/

  arg_no = first = step = element_no = 1;
  ftpar.nblocks = MAXINT;
  last = MAXINT;

  noreal = ftflag = TRUE;
  ftpar.t2dc = -1;
  ftpar.zeroflag = FALSE;
  ftpar.sspar.lfsflag = ftpar.sspar.zfsflag = FALSE;
  ftpar.dspar.dsflag = FALSE;
  ftpar.dspar.fileflag = FALSE;
  ftpar.dspar.newpath[0] = '\0';
  ftpar.ftarg.useFtargs = 0;
 
  // default newfidpath
  sprintf(newfidpath,"%s/lp.fid",curexpdir);

/*********************************
*  Parse STRING arguments first  *
*********************************/

  while ( (argc > arg_no) && (noreal = !isReal(argv[arg_no])) )
  {
     if(strcmp(argv[arg_no],"rlp") == 0) { // e.g., lp('/tmp/lp.fid')
       ftpar.procstatus = (REAL_t2|LP_F2PROC);
     } else if(argv[arg_no][0] == '/') { // e.g., lp('/tmp/lp.fid')
        strcpy(newfidpath,argv[arg_no]);
     } else {
        sprintf(newfidpath,"%s/%s",curexpdir,argv[arg_no]);
     }
     arg_no++;
  }
  if(strcmp(newfidpath+strlen(newfidpath)-4,".fid") != 0 &&
     strcmp(newfidpath+strlen(newfidpath)-5,".fid/") != 0) strcat(newfidpath,".fid");
  
/******************************
*  Initialize data files and  *
*  FT parameters.             *
******************************/

  if ( i_ft(argc, argv, (S_DATA | S_FLOAT),
            0, 0, &ftpar, &fidhead, &datahead, &phasehead) )
  {
      disp_status("        ");
      ABORT;
  }
  
  if ( (res = D_getbuf(D_USERFILE, fidhead.nblocks,  0, &inblock)) ) { 
    ctcount=1;
  } else ctcount = inblock.head->ctcount; 

  if(ctcount<1) ctcount=1;

  if (ftpar.t2dc == -1)
  {
      ftpar.t2dc = (fidhead.status & S_DDR) ? FALSE : TRUE;
  }
  disp_current_seq();

  ftpar.cf = first;

     specIndex = first;		/* tells interactive programs
				   that new data exist */
/***************************************************
*  np0  =  total number of points in the fid       *
*  npx  =  used number of points in the fid        *
*                                                  *
*  Adjust "npx" and "lsfidx".                      *
***************************************************/

  lsfidx = ftpar.lsfid0;

    npx = ftpar.np0;
    npadj = npx - lsfidx;     /* adjusted number of FID data points */

  if (lsfidx < 0)
  {
     if (npx < 2)
     {
        Werrprintf("lsfid is too large in magnitude");
        ABORT;
     }
  }
  else
  {
     if (lsfidx >= npx)
     {
        Werrprintf("lsfid is too large in magnitude");
        ABORT;
     }
  }

  realt2data = (ftpar.procstatus & REAL_t2);
  fpointmult = getfpmult(S_NP, fidhead.status & S_DDR);

  // note, limit for forward LP is npadj (5th arg)
  if ( setlppar(&parLPinfo, S_NP, ftpar.procstatus, npadj/2, MAXINT,
		  LPALLOC, "ft2d") )
  {
     disp_status("        ");
     releaseAllWithId("ft2d");
     Wsetgraphicsdisplay("");		/* TRY THIS!  SF */
     ABORT;
  }

  if (parLPinfo.sizeLP)
  {
     int	maxlpnp,
		nptmp;

     if (realt2data)
     {
        Werrprintf("LP analysis is not supported for real t2 data");
        releaseAllWithId("ft2d");
        disp_status("        ");
        ABORT;
     }

     maxlpnp = npadj;

     for (i = 0; i < parLPinfo.sizeLP; i++)
     {
        lpparams = *(parLPinfo.parLP + i);

        if (lpparams.status & FORWARD)
        {
           nptmp = 2*(lpparams.startextpt + lpparams.ncextpt - 1);
           if (nptmp > maxlpnp)
              maxlpnp = nptmp;
        }
     }

     npadj = maxlpnp;
  }

/**************************
*  Start loop over FIDs.  *
**************************/

  lastfid = ftpar.ni0 * ftpar.ni1 * ftpar.arraydim;
     if (lastfid > ftpar.nblocks)
        lastfid = ftpar.nblocks;
     if (first > lastfid)
     {
        last = lastfid;
     }

  D_trash(D_DATAFILE);
  if(access(newfidpath,F_OK) != 0) {
   if(mkdir(newfidpath,0777)) {
     Winfoprintf("cannot create %s",newfidpath);
     ABORT;
   }
  }

  status = (S_DATA | S_FLOAT | S_COMPLEX | ftpar.D_cmplx);

  // now write out fid to newfidpath
  strcpy(filepath,newfidpath); 
  strcat(filepath,"/fid");
  
  datahead.status = fidhead.status;
  datahead.vers_id = fidhead.vers_id;
  datahead.nbheaders = fidhead.nbheaders;
  datahead.nblocks = fidhead.nblocks;
  datahead.ntraces = 1;
  datahead.np = npadj; 
  datahead.ebytes = fidhead.ebytes;
  datahead.tbytes = npadj*fidhead.ebytes;
  datahead.bbytes = datahead.tbytes + sizeof(dblockhead);;
   
  if (D_newhead(D_DATAFILE, filepath, &datahead) )
  {
     Werrprintf("cannot open file %s", filepath);
     ABORT;
  }

/***********************************************
*  Necessary until I can devise a function to  *
*  read only the FID block header in order to  *
*  determine if FID data exists in that block. *
***********************************************/

  blocksdone = FALSE;
  lastcblock = ftpar.nblocks;

  cblock = 0;

  while ((cblock < lastcblock) && (!blocksdone))
  {
     DPRINT1("block %d\n", cblock);
     if ( (res = D_allocbuf(D_DATAFILE, cblock, &outblock)) )
     {
        D_error(res);
        releaseAllWithId("ft2d");
        disp_status("        ");
        ABORT;
     }
     
     outblock.head->ctcount = ctcount;  /* default setting */
     outblock.head->scale = 0;    /* default setting */

       outp = (float *)outblock.data;

/**********************************************************
*  Start filling at the start of the output data buffer.  *
*  This facilitates the automatic array-like processing   *
*  of 'cf' and 'nf' in 1D.                                *
**********************************************************/

        fidnum = cblock;
     
     if (interuption)
     {
        releaseAllWithId("ft2d");
        D_trash(D_PHASFILE);
        D_trash(D_DATAFILE);
        disp_status("        ");
        ABORT;
     }

     if ((cblock + 1) == first)
     {
        if ( ! ((cblock+1) & 15) )
           disp_index(cblock + 1);
        if ( getfid(fidnum, outp, &ftpar, &fidhead, &lastfid) )
	{

	   Werrprintf("Unable to get FID data");
           releaseAllWithId("ft2d");
	   disp_index(0);
           disp_status("        ");
           ABORT;
        }

	if (lastfid == 0)
	{
           releaseAllWithId("ft2d");
	   disp_index(0);
	   disp_status("        ");
           ABORT;
        }
        else if (cblock == lastfid)
	{
           status = 0;
           blocksdone = TRUE;
           if (last == MAXINT)
           {
              last = cblock;
           }
	}
        else
        {
           if (parLPinfo.sizeLP)
           {
              for (i = 0; i < parLPinfo.sizeLP; i++)
              {
                 lpparams = *(parLPinfo.parLP + i);
                 disp_status(lpparams.label);

                 if (lpz(fidnum, outp, (npx - lsfidx)/2, lpparams))
                 {
                    Werrprintf("LP analysis failed");
                    releaseAllWithId("ft2d");
                    disp_index(0);
                    disp_status("       ");
                    ABORT;
                 }
              }
           }

           if (fpointmult != 1.0)
           {
              *outp *= fpointmult;
              *(outp + 1) *= fpointmult;
           }

           //zerofill(outp + npadj, ftpar.fn0 - npadj);

           last = cblock + 1;
        }

        // multiply outp by ctcount
        outp = (float *)outblock.data;
        outp += npadj;
        for(i = 0; i < npadj; i++)
	  *(--outp) *= ctcount;
       
        setheader(&outblock, status, 0, cblock+1,
			ftpar.hypercomplex);
        first += step;
     }
     else
     {
        setheader(&outblock, 0, 0, cblock, ftpar.hypercomplex);
     }

     if ( (res = D_markupdated(D_DATAFILE, cblock)) )
     {
        D_error(res);
        releaseAllWithId("ft2d");
        disp_index(0);
        disp_status("        ");
        ABORT;
     }

     if ( (res = D_release(D_DATAFILE, cblock)) )
     {
        D_error(res);
        releaseAllWithId("ft2d");
        disp_index(0);
        disp_status("        ");
        ABORT;
     }

     cblock++;
     if (!blocksdone)
        blocksdone = (first > lastcblock);
  }

  if ( (last != ftpar.nblocks) && (last != MAXINT) )
  {
     if ( (res = D_gethead(D_DATAFILE, &datahead)) )
     {
        D_error(res);
        disp_index(0);
        disp_status("        ");
        ABORT;
     }

     datahead.nblocks = last;
     if ( (res = D_updatehead(D_DATAFILE, &datahead)) )
     {
        D_error(res);
        disp_index(0);
        disp_status("        ");
        ABORT;
     }
  }

  releasevarlist();
  releaseAllWithId("ft2d");
  disp_index(0);
  disp_status("    ");
  D_close(D_USERFILE);
  D_flush(D_DATAFILE);
  D_trash(D_DATAFILE);
  D_trash(D_PHASFILE);

  // save procpar
  strcpy(filepath,newfidpath); 
  strcat(filepath,"/procpar");
  if(npx == npadj) {
     saveProcpar(filepath);
  } else {
     
     double sw,at, oldat;
     P_getreal(PROCESSED,"at", &oldat, 1);
     P_setreal(PROCESSED,"np",(double)npadj,1);
     if(!P_getreal(PROCESSED,"sw",&sw,1) && sw > 0) {
        at = npadj/(2*sw);
        P_setreal(PROCESSED,"at",at,1);	
     }  
     saveProcpar(filepath);
     P_setreal(PROCESSED,"np",(double)npx,1);
     P_setreal(PROCESSED,"at",oldat,1);
  }

  RETURN;
}
コード例 #6
0
ファイル: vdp_ascii.c プロジェクト: cordellia/lldpad
static int str2vdpnl(char *argvalue, struct vdpnl_vsi *vsi)
{
	int rc = -ENOMEM;
	unsigned int no;
	unsigned short idx;
	char *cmdstring, *token;

	cmdstring = strdup(argvalue);
	if (!cmdstring)
		goto out_free;
	rc = -EINVAL;
	/* 1st field is VSI command */
	token = strtok(cmdstring, ",");
	if (!token || !getmode(vsi, token))
		goto out_free;

	/* 2nd field is VSI Manager Identifer (16 bytes maximum) */
	token = strtok(NULL, ",");
	if (!token || !getmgr2id(vsi, token))
		goto out_free;

	/* 3rd field is type identifier */
	token = strtok(NULL, ",");
	if (!token || !getnumber(token, 0, 0xffffff, &no))
		goto out_free;
	vsi->vsi_typeid = no;

	/* 4th field is type version identifier */
	token = strtok(NULL, ",");
	if (!token || !getnumber(token, 0, 0xff, &no))
		goto out_free;
	vsi->vsi_typeversion = no;

	/* 5th field is filter VSI UUID */
	token = strtok(NULL, ",");
	if (!token || vdp_str2uuid(vsi->vsi_uuid, token, sizeof(vsi->vsi_uuid)))
		goto out_free;
	vsi->vsi_idfmt = VDP22_ID_UUID;

	/* 6th field is migration hints */
	token = strtok(NULL, ",");
	if (!token || !gethints(vsi, token))
		goto out_free;

	/*
	 * 7th and remaining fields are filter information format data.
	 * All fields must have the same format. The first fid field determines
	 * the format.
	 */
	for (idx = 0, token = strtok(NULL, ","); token != NULL;
					++idx, token = strtok(NULL, ",")) {
		if (idx < vsi->macsz && !getfid(vsi, token, idx))
			goto out_free;
	}

	/* Return error if no filter information provided */
	if (idx)
		rc = 0;
out_free:
	free(cmdstring);
	return rc;
}
コード例 #7
0
ファイル: df2d.c プロジェクト: timburrow/OpenVnmrJ
/*-----------------------------------------------
|                                               |
|               get_one_fid()/3                 |
|                                               |
|    This function returns a pointer to the     |
|    requested FID in a 1D, arrayed, or 2D      |
|    experiment.                                |
|                                               |
+----------------------------------------------*/
float *get_one_fid(int curfid, int *np, dpointers *c_block, int dcflag)
{
  char          filepath[MAXPATHL],
                dcrmv[4];
  int           res,
                lastfid,
                force_getfid,
                headok;
  float         *fidptr;
  int           cftemp;
  int           cttemp;
  double        tmp;
  vInfo         info;
  ftparInfo	ftpar;
  dfilehead	fidhead,
		phasehead;
 
 
  force_getfid = (*np < 0);
  if (force_getfid)
     *np = -(*np);
  acqflag = FALSE;
  ftpar.np0 = *np;
  ftpar.fn0 = *np;
  ftpar.hypercomplex = FALSE;	/* ==> will not work for hypercomplex
				   2D interferograms */
  D_allrelease();
 
  if ( (res = D_gethead(D_PHASFILE, &phasehead)) )
  {
     if (res == D_NOTOPEN)
     {
        if ( (res = D_getfilepath(D_PHASFILE, filepath, curexpdir)) )
        {
           D_error(res);
           return(NULL);
        }

        res = D_open(D_PHASFILE, filepath, &phasehead); /* open the file */
     }
 
     if (res)
     {
        if ( new_phasefile(&phasehead, 0, 0, 0, 0, 0, ftpar.hypercomplex) )
           return(NULL);
     }
  }
 
  cftemp = 1;
  if (!P_getreal(CURRENT, "cf", &tmp, 1))
  {
     if (!P_getVarInfo(CURRENT, "cf", &info))
     {
        if (info.active)
           cftemp = (int) tmp;
     }
  }
  cttemp = 0;
  if (!P_getreal(PROCESSED, "ct", &tmp, 1))
     cttemp = (int) (tmp + 0.5);

  ls_ph_fid("lsfid", &(ftpar.lsfid0), "phfid", &(ftpar.phfid0), "lsfrq",
		&(ftpar.lsfrq0));
  headok = ( (phasehead.status == (S_DATA|S_FLOAT|S_COMPLEX)) &&
            (phasehead.ntraces == 1) && (phasehead.np == ftpar.np0) );
 
  if (headok)
  { /* if phase file does contain fid data, open the file */
     res = D_getbuf(D_PHASFILE, phasehead.nblocks, curfid, c_block);
 
     if (!res)
     {
        if ( (c_block->head->status == (S_DATA|S_FLOAT|S_COMPLEX)) &&
             (c_block->head->rpval == (float) (ftpar.phfid0)) &&
             (c_block->head->lpval == (float) (ftpar.lsfid0/2)) &&
             (c_block->head->lvl   == (float) (cftemp)) &&
             (c_block->head->tlt   == (float) (cttemp)) &&
             !force_getfid )
        {
           long_event();
           return((float *)c_block->data);
        }
     }
  }
 
/********************************************
*  If phasefile does not contain FID data,  *
*  open phasefile with the data handler.    *
********************************************/

  ftpar.zeroflag = FALSE;
  ftpar.arraydim = dim1count();
  lastfid = ftpar.arraydim;
  ftpar.fn0 = ftpar.np0;
  if ( i_fid(&fidhead, &ftpar) )   /* open fid file with data handler */
     return(NULL);
  if (ftpar.fn0 != ftpar.np0)
     headok = 0;

  *np = ftpar.np0;
  ftpar.fn0 = ftpar.np0;
 
  if (!headok)
  {
     if (new_phasefile(&phasehead, 0, ftpar.arraydim, 2*ftpar.np0, 1,
                    (S_DATA|S_FLOAT|S_COMPLEX), ftpar.hypercomplex))
     {
        return(NULL);
     }
  }
 
  if ( (res = D_allocbuf(D_PHASFILE, curfid, c_block)) )
  {
     D_error(res);
     return(NULL);
  }
 
  fidptr = (float *)c_block->data;
 
  /*******************************************
  *   provision for baseline offset removal  *
  *   using numbers reported by noise check  *
  *******************************************/

  ftpar.offset_flag = FALSE;
  if (!P_getstring(CURRENT,"dcrmv",dcrmv,1,4))
  {
    if (dcrmv[0] == 'y')
    {
      ftpar.offset_flag = TRUE;
    }
  }
  ftpar.t2dc = dcflag;
     
  if ( getfid(curfid, fidptr, &ftpar, &fidhead, &lastfid) ||
        (lastfid <= curfid) )
  {
     return(NULL);
  }
 
  if (ftpar.lsfid0 > 0)
     zerofill(fidptr + ftpar.np0 - ftpar.lsfid0, ftpar.lsfid0);
 
  D_close(D_USERFILE);
  setheader(c_block, (S_DATA|S_FLOAT|S_COMPLEX), NP_PHMODE, curfid,
                ftpar.hypercomplex);
  c_block->head->rpval = (float) (ftpar.phfid0);
  c_block->head->lpval = (float) (ftpar.lsfid0/2);
  c_block->head->lvl   = (float) (ftpar.cf);
  c_block->head->tlt   = (float) (ftpar.dspar.ctcount);
 
  if ( ftpar.cf != cftemp)
  {  /* cf is misset or inactive - just set it = 1 */
     Werrprintf("cf = %d is inconsistent with data",cftemp);
     P_setreal(CURRENT,  "cf", 1.0, 0);
     P_setreal(PROCESSED,"cf", 1.0, 0);
  }
  if ( (res = D_markupdated(D_PHASFILE, curfid)) )
  {
     D_error(res);
     return(NULL);
  }
 
  return(fidptr);
}
コード例 #8
0
ファイル: df2d.c プロジェクト: timburrow/OpenVnmrJ
/*  blocknum    DATA block number to store converted data    */
static int convertblock(int *curfid, int blocknum, int *lastfid, int fidincr,
                ftparInfo *ftpar, dfilehead *fidhead, int nf_firstfid)
{
  int                   status,
                        res,
                        outfile,
                        npadj,
			fidnum,
			zfnumber;
  register int          fidcnt;
  register float        *outp;
  dpointers             outblock;
 
 
  outfile = D_DATAFILE;
 
/****************************************
*  Block "blocknum+nblocks" is used in  *
*  D_DATAFILE to transpose data.        *
****************************************/
 
  if ( (res = D_allocbuf(outfile, blocknum + ftpar->nblocks, &outblock)) )
  {
     D_error(res);
     return(ERROR);
  }
 
  outp = (float *)outblock.data;
/*************************************************
*  Start filling at the beginning of the output  *
*  data buffer.                                  *
*                                                *
*  np0 = the number of actual points in the FID  *
*  fn0 = the number of actual points in the      *
*        converted file                          *
*************************************************/
 
  npadj = ( (ftpar->lsfid0 < 0) ? ftpar->np0 : (ftpar->np0 - ftpar->lsfid0) );
  if (npadj > ftpar->fn0)
     npadj = ftpar->fn0;
  zfnumber = ftpar->fn0 - npadj;
 
/*********************************************
*  DF2D of NF-arrayed 2D data will not work  *
*  at this time.                             *
*********************************************/
  *lastfid = *curfid + ftpar->sperblock0*fidincr;
  for (fidcnt = *curfid; fidcnt < *lastfid; fidcnt += fidincr)
  {
     fidnum = ( (ftpar->D_dimname & S_NF) ? nf_firstfid : fidcnt );
     if ( getfid(fidnum, outp, ftpar, fidhead, lastfid) )
        return(ERROR);
 
     if (*lastfid == 0)
        return(ERROR);
 
     if (fidcnt < (*lastfid))
     {
        if (zfnumber > 0)
           zerofill(outp + npadj, zfnumber);
        scalefid(outp,npadj);
	if (ftpar->D_dimname & S_NF)
           ftpar->cf += ftpar->cfstep;/* increment cf for NF processing */
     }
     outp += ftpar->fn0;
  }
 
  fidnum = fidcnt;
  for (fidcnt = *lastfid + fidincr; fidcnt < *curfid + ftpar->sperblock0*fidincr;
       fidcnt += fidincr)
  {
     zerofill(outp, ftpar->fn0);
     outp += ftpar->fn0;
  }
  *curfid = fidnum;
  status = (S_DATA|S_FLOAT|S_COMPLEX);
     
  setheader(&outblock, status, ftpar->D_dsplymode, blocknum,
                ftpar->hypercomplex);
  if ( (res = D_markupdated(outfile, blocknum + ftpar->nblocks)) )
  {
     D_error(res);
     return(ERROR);
  }
 
  if ( (res = D_release(outfile, blocknum + ftpar->nblocks)) )
  {
     D_error(res);
     return(ERROR);
  }
 
  return(COMPLETE);
}