Exemplo n.º 1
0
int
fs_d81_format (fs64_filesystem * fs, uchar *name, uchar *id)
{
  /* format a D64 file */
  int t, s;
  uchar blocks[3][256] =
  {
    {0}};

  /* If id is non null then format each sector, otherwise
     only clear dir and BAM */
  if (id[0])
  {
    /* toast *everything* */
    for (t = 1; t < 81; t++)
    {
      for (s = 0; s < 40; s++)
      {
	if (writets (fs, t, s, blocks[0]))
	  return (-1);
      }
    }
    /* clear disk name */
    for (t = 24; t < 28; t++)
      blocks[0][t] = 0xa0;
    /* copy new id in */
    blocks[0][22] = id[0];
    blocks[0][23] = id[1];
  }
  else
  {
    /* toast first dir sector */
    if (writets (fs, 40, 3, blocks[0]))
      return (-1);
  }

  /* make shiny new bam */
  fs_d81_makebam (blocks);
  /* set DOS information */
  blocks[0][0] = 40;
  blocks[0][1] = 3;
  blocks[0][25] = '3';
  blocks[0][26] = 'D';
  blocks[0][2] = 'D';
  blocks[0][3] = 0;

  /* copy header in */
  for (t = 4; t < 22; t++)
    blocks[0][t] = 0xa0;
  for (t = 4; name[t - 4]; t++)
    blocks[0][t] = name[t - 4];

  /* write back */
  /* BUG: Needs to be written twice! */
  fs_d81_writebam (fs, blocks);

  set_error (0, 0, 0);
  return (0);

}
Exemplo n.º 2
0
int
fs_dhd_writebam (fs64_filesystem * fs, uchar blocks[3][256])
{
    /* write a D81 bam */
    int i;
    int num_tracks;

    fseek (fs->fsfile, 54, SEEK_SET);
    num_tracks = fgetc (fs->fsfile);
    if ((num_tracks < 1) || (num_tracks > 255))
    {
        set_error (74, 0, 0);
        return (-1);
    }

    for (i = 0; i < ((num_tracks / 8) + 3); i++)
    {
        if (writets (fs, 1, i, blocks[i]))
            return (-1);
        if (writets (fs, 1, i, blocks[i]))
            return (-1);
    }

    return (0);
}
Exemplo n.º 3
0
int
fs_d81_writebam (fs64_filesystem * fs, uchar blocks[3][256])
{
  /* write a D81 bam */
  int i;

  for (i = 0; i < 3; i++)
  {
    if (writets (fs, 40, i, blocks[i]))
      return (-1);
    if (writets (fs, 40, i, blocks[i]))
      return (-1);
  }
  return (0);
}
Exemplo n.º 4
0
/*
 * Process a timestamp.
 * Returns 0 on success, 1 if it had trouble writing, 2 if the tag wasn't
 * found (and it was explictly requested), or -1 if the tag wasn't found.
 */
static int
procts(FILE *fp, long pos, struct exiftags *t, const unsigned char *buf,
    u_int16_t tag, const char *ttype)
{
	int rc;
	char nts[EXIFTIMELEN];
	struct exifprop *p;

	p = findprop(t->props, tags, tag);
	if (ettime(nts, p)) {

		/*
		 * If ttags != 0, then the user explicitly requested the
		 * timestamp, so print an error if it doesn't exist.
		 */
		if (ttags) {
			fprintf(stderr, "%s: image %s time not available\n",
			    fname, ttype);
			return (2);
		}

		return (-1);
	}

	if (wflag)
		rc = writets(fp, pos, t, p, buf, ttype, nts);
	else {
		printf("%s%s%s\n", p->descr, delim, nts);
		rc = 0;
	}

	return (rc);
}
Exemplo n.º 5
0
void write_log (const TCHAR *format, ...)
{
    int count;
    TCHAR buffer[WRITE_LOG_BUF_SIZE], *ts;
    int bufsize = WRITE_LOG_BUF_SIZE;
    TCHAR *bufp;
    va_list parms;

    if (!cs_init)
        return;

    premsg ();

    if (!_tcsicmp (format, _T("*")))
        count = 0;

    EnterCriticalSection (&cs);
    va_start (parms, format);
    bufp = buffer;
    for (;;) {
        count = _vsntprintf (bufp, bufsize - 1, format, parms);
        if (count < 0) {
            bufsize *= 10;
            if (bufp != buffer)
                xfree (bufp);
            bufp = xmalloc (TCHAR, bufsize);
            continue;
        }
        break;
    }
    bufp[bufsize - 1] = 0;
    if (!_tcsncmp (bufp, _T("write "), 6))
        bufsize--;
    ts = writets ();
    if (bufp[0] == '*')
        count++;
    if (SHOW_CONSOLE || console_logging) {
        if (lfdetected && ts)
            writeconsole (ts);
        writeconsole (bufp);
    }
    if (debugfile) {
        if (lfdetected && ts)
            _ftprintf (debugfile, _T("%s"), ts);
        _ftprintf (debugfile, _T("%s"), bufp);
    }
    lfdetected = 0;
    if (_tcslen (bufp) > 0 && bufp[_tcslen (bufp) - 1] == '\n')
        lfdetected = 1;
    va_end (parms);
    if (bufp != buffer)
        xfree (bufp);
    if (always_flush_log)
        flush_log ();
    LeaveCriticalSection (&cs);
}
Exemplo n.º 6
0
static void EXTRACT_tsfunc( double T0 , double TR ,
                   int npts , float ts[] , double ts_mean , double ts_slope ,
                   void * udp , float * dumb)
{
   static int nvox , ncall ;
	extract_data uda,*ud;
	float xcor=0.0 ,  tmp=0.0 , tmp2 = 0.0 ,  dtx = 0.0 ,\
			 slp = 0.0 , vts = 0.0 , vrvec = 0.0 , rxcorCoef = 0.0;
	int i , is_ts_null , status , opt , actv , zpos , ypos , xpos , hit;
	
	ud = &uda;
	ud = (extract_data *) udp;
	
	
   /** is this a "notification"? **/

	
   if( dumb == NULL ){
		
      if( npts > 0 ){  /* the "start notification" */

         PLUTO_popup_meter( global_plint ) ;  /* progress meter  */
         nvox  = npts ;                       /* keep track of   */
         ncall = 0 ;                          /* number of calls */
			
      } else {  /* the "end notification" */
			
         PLUTO_set_meter( global_plint , 100 ) ; /* set meter to 100% */

      }
      return ;
   }

	
	hit = 0;
	ud->ln = npts;
	
	
	if (ud->iloc != -1)			/* for each ncall, find out if this index is wanted*/
		{
			*dumb = ud->fail;
			for (i=0;i<ud->nrows;++i)
				{
					if (ud->indvect[i] == (float)ncall) 
						{
							hit = 1;
						   *dumb = ud->pass;
							writets (ud,ts,ncall); 
							i = ud->nrows;
						}
				}
		}
	else
		{
			*dumb = ud->fail;
			indexTOxyz (ud, ncall, &xpos , &ypos , &zpos);
			for (i=0;i<ud->nrows;++i)
				{
					if (ud->xyzvect[i].x == (float)xpos)
						{
							if (ud->xyzvect[i].y == (float)ypos)
								{
									if (ud->xyzvect[i].z == (float)zpos)
										{
											hit = 1;
											*dumb = ud->pass;
											writets (ud,ts,ncall); 
											i = ud->nrows;
										}
								}
						}		
				}
			
		}
	
	
	/* the output brick generated here is practically useless, it has 1 at the voxels 
	whos time courses were used and 0 where nothing was extracted */

	
   
   if (ud->errcode == 0) 				/* if there are no errors, proceed */	
		{/* 						*/
   	}/* ud->errcode == 0 outer loop */
   
   /** set the progress meter to the % of completion **/
   ncall++ ;
   
   PLUTO_set_meter( global_plint , (100*ncall)/nvox ) ;
   
   ud->errcode = 0;	/* Rest error to nothing */
   
   return ;
}
Exemplo n.º 7
0
int 
fs64_writets (fs64_filesystem * fs, int track, int sector, uchar *sb)
{
  return (writets (fs, track, sector, sb));
}
Exemplo n.º 8
0
int
fs_dhd_format (fs64_filesystem * fs, uchar *name, uchar *id)
{
    /* format a D64 file */
    int t, s, num_tracks;
    uchar blocks[34][256] =
    {
        {0}
    };

    errno = 0;
    fseek (fs->fsfile, 54, SEEK_SET);
    num_tracks = fgetc (fs->fsfile);
    if ((num_tracks < 1) || (num_tracks > 255))
    {
        set_error (74, 0, 0);
        return (-1);
    }

    /* If id is non null then format each sector, otherwise
       only clear dir and BAM */
    if (id[0])
    {
        /* toast *everything* */
        for (t = 1; t <= num_tracks; t++)
        {
            for (s = 0; s < 256; s++)
            {
                if (writets (fs, t, s, blocks[0]))
                    return (-1);
            }
        }
        /* place padding */
        for (t = 24; t < 28; t++)
            blocks[1][t] = 0xa0;
        /* copy new id in */
        blocks[1][22] = id[0];
        blocks[1][23] = id[1];
    }
    else
    {
        /* toast first dir sector */
        if (writets (fs, 1, (num_tracks / 8) + 3, blocks[0]))
            return (-1);
    }

    /* make shiny new bam */
    fs_dhd_makebam (blocks, num_tracks);
    /* set DOS information */
    blocks[1][0] = 1;
    blocks[1][1] = (num_tracks / 8) + 3;
    blocks[1][25] = '1';
    blocks[1][26] = 'H';
    blocks[1][2] = 'H';
    blocks[1][3] = 0;
    /* root dir header pointer */
    blocks[1][32] = 1;
    blocks[1][33] = 1;
    /* parent header pointer */
    blocks[1][34] = 0x00;
    blocks[1][35] = 0x00;
    /* reference to location in parent */
    blocks[1][36] = 0x00;
    blocks[1][37] = 0x00;
    blocks[1][38] = 0x00;

    /* copy header in */
    for (t = 4; t < 22; t++)
        blocks[1][t] = 0xa0;
    for (t = 4; name[t - 4]; t++)
        blocks[1][t] = name[t - 4];

    /* write back */
    fs_dhd_writebam (fs, blocks);

    set_error (0, 0, 0);
    return (0);

}
Exemplo n.º 9
0
static void DELAY_tsfuncV2( double T0 , double TR ,
                   int npts , float ts[] , double ts_mean , double ts_slope ,
                   void * udp , int nbrick , float * buckar)
{
   static int nvox , ncall ;
	hilbert_data_V2 uda,*ud;
	float del, xcorCoef, buckara[4];
	float xcor=0.0 ,  tmp=0.0 , tmp2 = 0.0 ,  dtx = 0.0 ,\
			 delu = 0.0 , slp = 0.0 , vts = 0.0 , vrvec = 0.0 ;
	int i , is_ts_null , status , opt , actv , zpos , ypos , xpos ;
	
	ud = &uda;
	ud = (hilbert_data_V2 *) udp;
	
   /** is this a "notification"? **/

   if( buckar == NULL ){

      if( npts > 0 ){  /* the "start notification" */

         PLUTO_popup_meter( global_plint ) ;  /* progress meter  */
         nvox  = npts ;      /* keep track of   */
         ncall = 0 ;         /* number of calls */
			
      } else {  /* the "end notification" */
			opt = 0;					/* cleanup in hdelay */
   		#if 0
         status = hilbertdelay_V2 (ts,ud->rvec,ud->ln,ud->Nseg,ud->Pover,opt,ud->dtrnd,dtx,ud->biasrem,&tmp,&slp,&xcor,&tmp2,&vts,&vrvec);					/* cleanup time */
	      #else
         hilbertdelay_V2reset();
         #endif
         PLUTO_set_meter( global_plint , 100 ) ; /* set meter to 100% */

      }
      return ;
   }

	/* In the old version, I had to check for a match between the lengths of the reference time series and FMRI time series
	This is now done before the function is called. */
   
   if (is_vect_null (ts,npts) == 1) /* check for null vectors */
   	{
   		ud->errcode = ERROR_NULLTIMESERIES;
			error_report (ud , ncall );	/* report the error */
   		
   		del = 0.0;								/* Set all the variables to Null and don't set xcorCoef to an impossible value*/
   		xcorCoef = 0.0;						/*  because the data might still be OK */
   		xcor = 0.0;
   	}
   
   if (ud->errcode == 0) 				/* if there are no errors, proceed */	
		{/* ud->errcode == 0 outer loop */
			opt = 1;					/* activate hdelay */
   		
   		/* transform dtx from seconds to sampling units and correct for the number of points ignored*/
   		if (ud->Dsamp == YUP) 
   			dtx = (float) (T0 / TR) - ud->ignore;
   		else
   			dtx = 0.0;
   			
   		ud->errcode = hilbertdelay_V2 (ts,ud->rvec,ud->ln,ud->Nseg,ud->Pover,opt,ud->dtrnd,dtx,ud->biasrem,&delu,&slp,&xcor,&xcorCoef,&vts,&vrvec);					/* cleanup time */
			
			if (ud->errcode == 0) /* If there are no errors, proceed */
				{ /*ud->errcode == 0 inner loop */
					hunwrap (delu, (float)(1/TR), ud->T, slp, ud->wrp, ud->unt, 
                        0, 1.0, &del );
					
					actv = 1;						/* assume voxel is active */
	
					if (xcorCoef < ud->co) actv = 0;			/* determine if voxel is activated using xcorCoef  */
	
					if ((actv == 1) && (ud->out == YUP)) 		/* if voxel is truly activated, write results to file without modifying return value */
						{
							indexTOxyz ( ud , ncall, &xpos , &ypos , &zpos);
							fprintf (ud->outwrite,"%d\t%d\t%d\t%d\t%f\t%f\t%f\t%f\t%f\n", ncall , xpos , ypos , zpos ,  delu , del , xcor , xcorCoef , vts);
							if (ud->outts == YUP)
								{
									writets (ud,ts);	
								}
						}

				}/*ud->errcode == 0 inner loop */
			
			else if (ud->errcode == ERROR_LONGDELAY)
						{
							error_report ( ud , ncall);	
							
							del = 0.0;								/* Set all the variables to Null and don't set xcorCoef to an impossible value*/
   						xcorCoef = 0.0;						/*  because the data might still be OK */
   						xcor = 0.0;
							
						}
					else if (ud->errcode != 0)
								{
									error_report ( ud , ncall);	
									
									del = 0.0;								/* Set all the variables to Null and set xcorCoef to an impossible value*/
   								xcorCoef = NOWAYXCORCOEF;						
   								xcor = 0.0;
								}

   }/* ud->errcode == 0 outer loop */
   
	/* Now fill up the bucket array */
	
	buckar[DELINDX] = del;
	buckar[COVINDX] = xcor;
	buckar[COFINDX] = xcorCoef;
	buckar[VARINDX] = vts;


   /** set the progress meter to the % of completion **/
   ncall++ ;
   
   PLUTO_set_meter( global_plint , (100*ncall)/nvox ) ;
   
   ud->errcode = 0;	/* Rest error to nothing */
   
   return ;
}