Ejemplo n.º 1
0
static int xzdClose( /*@only@*/ void * cookie)
	/*@globals fileSystem, internalState @*/
	/*@modifies fileSystem, internalState @*/
{
    FD_t fd = c2f(cookie);
    XZFILE *xzfile;
    const char * errcookie;
    int rc;

    xzfile = xzdFileno(fd);

    if (xzfile == NULL) return -2;
    errcookie = strerror(ferror(xzfile->fp));

    fdstat_enter(fd, FDSTAT_CLOSE);
    /*@-dependenttrans@*/
    rc = xzclose(xzfile);
    /*@=dependenttrans@*/
    fdstat_exit(fd, FDSTAT_CLOSE, rc);

    if (fd && rc == -1)
	fd->errcookie = errcookie;

DBGIO(fd, (stderr, "==>\txzdClose(%p) rc %lx %s\n", cookie, (unsigned long)rc, fdbg(fd)));

    if (_rpmio_debug || rpmIsDebug()) fdstat_print(fd, "XZDIO", stderr);
    /*@-branchstate@*/
    if (rc == 0)
	fd = fdFree(fd, "open (xzdClose)");
    /*@=branchstate@*/
    return rc;
}
Ejemplo n.º 2
0
/*@-globuse@*/
static int xzdFlush(void * cookie)
	/*@globals fileSystem @*/
	/*@modifies fileSystem @*/
{
    FD_t fd = c2f(cookie);
    return xzflush(xzdFileno(fd));
}
Ejemplo n.º 3
0
/*@-mustmod@*/          /* LCL: *buf is modified */
static ssize_t xzdRead(void * cookie, /*@out@*/ char * buf, size_t count)
	/*@globals fileSystem, internalState @*/
	/*@modifies *buf, fileSystem, internalState @*/
{
    FD_t fd = c2f(cookie);
    XZFILE *xzfile;
    ssize_t rc = -1;

assert(fd != NULL);
    if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
    xzfile = xzdFileno(fd);
assert(xzfile != NULL);
    fdstat_enter(fd, FDSTAT_READ);
/*@-compdef@*/
    rc = xzread(xzfile, buf, count);
/*@=compdef@*/
DBGIO(fd, (stderr, "==>\txzdRead(%p,%p,%u) rc %lx %s\n", cookie, buf, (unsigned)count, (unsigned long)rc, fdbg(fd)));
    if (rc == -1) {
	fd->errcookie = "Lzma: decoding error";
    } else if (rc >= 0) {
	fdstat_exit(fd, FDSTAT_READ, rc);
	/*@-compdef@*/
	if (fd->ndigests > 0 && rc > 0) fdUpdateDigests(fd, (void *)buf, rc);
	/*@=compdef@*/
    }
    return rc;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
  jit_node_t *nc, *nf;
  pifi c2f, f2c;
  int i;

  init_jit(argv[0]);
  _jit = jit_new_state();

  nc = compile_rpn("32x9*5/+");
  nf = compile_rpn("x32-5*9/");
  (void)jit_emit();
  c2f = (pifi)jit_address(nc);
  f2c = (pifi)jit_address(nf);
  jit_clear_state();

  printf("\nC:");
  for (i = 0; i <= 100; i += 10) printf("%3d ", i);
  printf("\nF:");
  for (i = 0; i <= 100; i += 10) printf("%3d ", c2f(i));
  printf("\n");

  printf("\nF:");
  for (i = 32; i <= 212; i += 18) printf("%3d ", i);
  printf("\nC:");
  for (i = 32; i <= 212; i += 18) printf("%3d ", f2c(i));
  printf("\n");

  jit_destroy_state();
  finish_jit();
  return 0;
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
  char *flag = argv[1];
  char *tempString = argv[2];
  float celcius, farenheit;

  progname = argv[0];
  if (argc < 3) {
    usage();
  }

  if (flag[0] == 'c') {
    if (sscanf(tempString, "%f", &farenheit) != 1) {
      usage();
    }
    printf("%.2f\n", f2c(farenheit));
  } else if (flag[0] == 'f') {
    if (sscanf(tempString, "%f", &celcius) != 1) {
      usage();
    }
    printf("%.2f\n", c2f(celcius));
  } else {
    usage();
  }
  
  return 0;
}
Ejemplo n.º 6
0
int     main(int argc, char **argv){
        double in_tmp;
        char unit;
        if(argc ==2){ // argc begin from program name; default =1
                sscanf(argv[1], "%lf%c", &in_tmp, &unit);
                printf("%lf     %c\n",in_tmp,unit);
                
                if( unit == 'c'){
                        printf("%2.2lf c= %2.2lf f\n",in_tmp, c2f(in_tmp) );
                }
                else if( unit == 'f'){
                        printf("%2.2lf f= %2.2lf c\n",in_tmp, f2c(in_tmp) );
                }
                else{
                        printf("Wrong input format\n");
                }
        }
        else if(argc ==3){
                in_tmp = atof(argv[1]);
                if( *argv[2] == 'c'){
                        printf("%2.2lf c= %2.2lf f\n",in_tmp, c2f(in_tmp) );
                }
                else if( *argv[2] == 'f'){
                        printf("%2.2lf f= %2.2lf c\n",in_tmp, f2c(in_tmp) );
                }
                else{
                        printf("Wrong input format : second argument");
                }
        }
        else{
                printf("Wrong input format\n");
        }

        
        /*
        char input_unit, output_unit;
        double inut_temp, output_temp;
        
        printf("input unit (f/c): ");   scanf("%c", &input_unit);
        printf("output unit (f/c): ");  scanf("%c", &output_unit);
        printf("input temp: ");         scanf("%c". &input_temp);
        
        printf("Convert %lf %c to %c\n", input_temp, input_unit, output_temp);
        */
        
        return 0;
}
Ejemplo n.º 7
0
/**
 * @brief BallClasificationModule::coarse2fine
 * Utiliza metodo de Tong
 * @param blob
 * @return
 */
bool BallClasificationModule::coarse2fine(Blob *blob, int num)
{
//    qDebug() << "Numero Blob: " << num;
    bool isball = true;

    if(num < 1000)
    {
        Rectangle<int> &rect = blob->bbox;
        Mat foreground = QImage2Mat_ROI(m_data->fgImage, rect, CV_8UC1);
        Mat Imagen = QImage2Mat_ROI(m_data->currentImage, rect, CV_8UC3);
        Coarsetofine c2f(blob,Imagen,foreground);
        /** SIZE FILTER **/
        isball = c2f.size_filter(25,25,3,3);
        if(isball)
        {
            /** ECC FILTER **/
            isball = c2f.eccentricity_filter(2.5);
            if(isball)
            {
                /** COLOR FITLER **/
                isball = c2f.color_filter(180,num);
                if(isball)
                {
                    n_ball++;
//                    isball = c2f.grasscontext_filter(30,num, m_data->currentImage);
//                    if(isball)
//                    {
//                        n_ball++;
////                        QString window_name = "PASO" + QString::number(num);
////                        namedWindow(window_name.toStdString(),WINDOW_NORMAL);
////                        imshow(window_name.toStdString(), Imagen);
//                    }
//                    else
//                    {
//                        n_grassctx++;
////                        QString window_name = "NO PASO" + QString::number(num);
////                        namedWindow(window_name.toStdString(),WINDOW_NORMAL);
////                        imshow(window_name.toStdString(), Imagen);
//                    }
                }
                else
                {
                    n_color++;
                }
            }
            else
            {
                n_ecc++;
            }
        }
        else
        {
            n_size++;
        }
//        qDebug() << isball;

    }
    return isball;
}
Ejemplo n.º 8
0
static int xzdSeek(void * cookie, /*@unused@*/ _libio_pos_t pos,
			/*@unused@*/ int whence)
	/*@*/
{
    FD_t fd = c2f(cookie);

    XZDONLY(fd);
    return -2;
}
Ejemplo n.º 9
0
int temp(double temp_in, char temp_in_unit, double *temp_out, char temp_out_unit){
  double tmp_var;
  if(temp_in_unit == 'c'){
    tmp_var = c2f(temp_in);
  }else if( temp_in_unit == 'f'){
    tmp_var = f2c(temp_in);
  }else {
    fprintf(stderr, "Temp unit '%c' is not supported yest\n", temp_in_unit);
    return -1;
  }
  printf("input = %.2lf %c, output = %.2lf %c\n", temp_in, temp_in_unit, tmp_var, temp_out_unit);
  *temp_out = tmp_var; 
  return 0; 
}
Ejemplo n.º 10
0
/*@-globuse@*/
static /*@null@*/ FD_t xzdFdopen(void * cookie, const char * fmode)
	/*@globals fileSystem, internalState @*/
	/*@modifies fileSystem, internalState @*/
{
    FD_t fd = c2f(cookie);
    int fdno = fdFileno(fd);
    XZFILE *xzfile;

assert(fmode != NULL);
    fdSetFdno(fd, -1);          /* XXX skip the fdio close */
    if (fdno < 0) return NULL;
    xzfile = xzdopen(fdno, fmode);
    if (xzfile == NULL) return NULL;
    fdPush(fd, xzdio, xzfile, fdno);
    return fdLink(fd, "xzdFdopen");
}
Ejemplo n.º 11
0
int tempc(double temp_in, char temp_in_unit, double *temp_out, char temp_out_unit){
	double t_out;

	if(temp_in_unit == 'c'){
		t_out = c2f(temp_in);
	}else if(temp_in_unit == 'f'){
		t_out = f2c(temp_in);
	}else{
		fprintf(stderr, "Temperature unit '%c' is not supported yet\n", temp_in_unit);
	}

	printf("input = %lf %c, output = %lf %c\n", temp_in, temp_in_unit, t_out, temp_out_unit);
	
	*temp_out = t_out;

	return 0;

}
Ejemplo n.º 12
0
int
main ()
{
  pdfd c2f, f2c;
  double i;

  codeBuffer = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC,
                    MAP_PRIVATE | MAP_ANON, -1, 0);
  if (codeBuffer == MAP_FAILED) {
    perror("mmap");
    exit(0);
  }

  regs[0] = JIT_FPR0;
  regs[1] = JIT_FPR1;
  regs[2] = JIT_FPR2;
  regs[3] = JIT_FPR3;
  regs[4] = JIT_FPR4;
  regs[5] = JIT_FPR5;

  jit_set_ip (codeBuffer);
  c2f = compile_rpn ("9*5/32+");
  f2c = compile_rpn ("32-5*9/");

#ifndef LIGHTNING_CROSS
  printf ("\nC:");
  for (i = 0; i <= 100; i += 10)
    printf ("%6.1f", i);
  printf ("\nF:");
  for (i = 0; i <= 100; i += 10)
    printf ("%6.1f", c2f (i));
  printf ("\n");

  printf ("\nF:");
  for (i = 32; i <= 212; i += 10)
    printf ("%6.1f", i);
  printf ("\nC:");
  for (i = 32; i <= 212; i += 10)
    printf ("%6.1f", f2c (i));
  printf ("\n");
#endif
  return 0;
}
Ejemplo n.º 13
0
int main(int argc, char* argv[])	{
	if(argc ==  2 && IsDec(argv[1]))	{
		printf("The temperature is %.2f℃\n", f2c(atof(argv[1])));		
	}
	else if(argc == 3 && IsDec(argv[2]))	{
		if( strcmp(argv[1], "f2c")==0 )
			printf("The temperature is %.2f℃\n", f2c(atof(argv[2])));
		else if( strcmp(argv[1], "c2f") ==0 )
			printf("The temperature is %.2f°F\n", c2f(atof(argv[2])));
	}
	else	{
		printf("Usage:\n");
		printf("The second argument is \"c2f\" or \"f2c\"\n");
		printf("And the third argument is a positive real number.\n");
		printf("For example:\n");
		printf("    tempscacov c2f 22\n");
		printf("    tempscacov f2c 72\n");
	}
	return 0;
}
Ejemplo n.º 14
0
gboolean read_sensor(gboolean need_redraw) {
    FILE *file;
    gchar buffer[128];
#ifdef DEBUGFUNCTIONCALL
    START_FUNCTION;
#endif
    if (!(file = fopen(SENSOR, "r")))
        return TRUE;
    memset(buffer, 0, sizeof(buffer));
    if (!fgets(buffer, sizeof(buffer) - 1, file)) {
        fclose(file);
        return TRUE;
    }
    fclose(file);
    app->sensor_data = atof(buffer) / 1000.0f;
    if (app->config->temperature_units == FAHRENHEIT)
        app->sensor_data = c2f(app->sensor_data);
    if (need_redraw)
        redraw_home_window(FALSE);
    return TRUE;
}
Ejemplo n.º 15
0
/*@-globuse@*/
static ssize_t xzdWrite(void * cookie, const char * buf, size_t count)
	/*@globals fileSystem, internalState @*/
	/*@modifies fileSystem, internalState @*/
{
    FD_t fd = c2f(cookie);
    XZFILE *xzfile;
    ssize_t rc = 0;

    if (fd == NULL || fd->bytesRemain == 0) return 0;   /* XXX simulate EOF */

    if (fd->ndigests > 0 && count > 0) fdUpdateDigests(fd, (void *)buf, count);

    xzfile = xzdFileno(fd);

    fdstat_enter(fd, FDSTAT_WRITE);
    rc = xzwrite(xzfile, (void *)buf, count);
DBGIO(fd, (stderr, "==>\txzdWrite(%p,%p,%u) rc %lx %s\n", cookie, buf, (unsigned)count, (unsigned long)rc, fdbg(fd)));
    if (rc < 0) {
	fd->errcookie = "Lzma: encoding error";
    } else if (rc > 0) {
	fdstat_exit(fd, FDSTAT_WRITE, rc);
    }
    return rc;
}
Ejemplo n.º 16
0
Archivo: rpn.c Proyecto: pcpa/lightning
int
main ()
{
  pifi c2f, f2c;
  int i;

  codeBuffer = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC,
                    MAP_PRIVATE | MAP_ANON, -1, 0);
  if (codeBuffer == MAP_FAILED) {
    perror("mmap");
    exit(0);
  }

  jit_set_ip (codeBuffer);
  c2f = compile_rpn ("32 x 9 * 5 / +");
  f2c = compile_rpn ("5 x 32_ + * 9 /");

#ifndef LIGHTNING_CROSS
  printf ("\nC:");
  for (i = 0; i <= 100; i += 10)
    printf ("%3d ", i);
  printf ("\nF:");
  for (i = 0; i <= 100; i += 10)
    printf ("%3d ", c2f (i));
  printf ("\n");

  printf ("\nF:");
  for (i = 32; i <= 212; i += 10)
    printf ("%3d ", i);
  printf ("\nC:");
  for (i = 32; i <= 212; i += 10)
    printf ("%3d ", f2c (i));
  printf ("\n");
#endif
  return 0;
}