Example #1
0
void IFFT::help() {
    pprintf("-ifft performs an inverse dft on the current image, whose values are"
            " complex. The input and output are images with 2*c channels, where"
            " channel 2*i is the real part of the i\'th channel, and channel 2*i+1"
            " is the imaginary part of the i'th channel.\n"
            "\n"
            "Usage: ImageStack -load a.tga -fftcomplex -save freq.tga\n\n");
}
Example #2
0
//  added 28/01/2011 [email protected]
void lcd_printf(char *fmt, ...)
{
	va_list args;

	va_start(args, fmt);
	pprintf(lcd_write, fmt, args);
	va_end(args);
}
Example #3
0
void decl(void) {
    char decl_type[MAXTOKEN];
    decl_type[0] = '\0';
    gettoken();
    type(decl_type);
    dcl();
    pprintf("%s\n", decl_type);
}
Example #4
0
/*
 * asetemail
 *
 * Usage: asetemail player [address]
 *
 *   Sets the email address of the player to the address given.  If the
 *   address is omited, then the player's email address is cleared.  The
 *   person's email address is revealed to them when they use the "finger"
 *   command, but no other users -- except admins -- will have another
 *   player's email address displayed.
 */
int com_asetemail(int p, param_list param)
{
  struct player *pp = &player_globals.parray[p];
  int p1, connected;
  char *oldemail;

  if (!FindPlayer(p, param[0].val.word, &p1, &connected))
    return COM_OK;

  if (!check_admin2(p, p1)) {
    pprintf(p, "You can only set email addr for players below your adminlevel.\n");
    if (!connected)
      player_remove(p1);
    return COM_OK;
  }
  if (player_globals.parray[p1].emailAddress) {
    oldemail = strdup(player_globals.parray[p1].emailAddress);
    free(player_globals.parray[p1].emailAddress);
  } else {
    oldemail = strdup("");
  }

  if (param[1].type == TYPE_NULL) {
    player_globals.parray[p1].emailAddress = NULL;
    pprintf(p, "Email address for %s removed\n", player_globals.parray[p1].name);
    pcommand(p, "addcomment %s Email address removed.\n", player_globals.parray[p1].name);

  } else {
    player_globals.parray[p1].emailAddress = strdup(param[1].val.word);
    pprintf(p, "Email address of %s changed to \"%s\".\n", player_globals.parray[p1].name, param[1].val.word);
    pcommand(p, "addcomment %s Email address changed from %s to %s.\n", player_globals.parray[p1].name, oldemail, player_globals.parray[p1].emailAddress);
  }
  free(oldemail);
  player_save(p1);
  if (connected) {
    if (param[1].type == TYPE_NULL) {
      pprintf_prompt(p1, "\n\n%s has removed your email address.\n\n", pp->name);
    } else {
      pprintf_prompt(p1, "\n\n%s has changed your email address.\n\n", pp->name);
    }
  } else {
    player_remove(p1);
  }
  return COM_OK;
}
Example #5
0
static int
init_linemon(
	     queue_t *q
	     )
{
	register queue_t *dq;
  
	dq = WR(q);
	/*
	 * we ARE doing very bad things down here (basically stealing ISR
	 * hooks)
	 *
	 * so we chase down the STREAMS stack searching for the driver
	 * and if this is a known driver we insert our ISR routine for
	 * status changes in to the ExternalStatus handling hook
	 */
	while (dq->q_next)
	{
		dq = dq->q_next;		/* skip down to driver */
	}

	/*
	 * find appropriate driver dependent routine
	 */
	if (dq->q_qinfo && dq->q_qinfo->qi_minfo)
	{
		register char *dname = dq->q_qinfo->qi_minfo->mi_idname;

		pprintf(DD_INSTALL, "init_linemon: driver is \"%s\"\n", dname);

#ifdef sun
		if (dname && !strcmp(dname, "zs"))
		{
			return init_zs_linemon(dq, q);
		}
		else
#endif
		{
			pprintf(DD_INSTALL, "init_linemon: driver \"%s\" not suitable for CD monitoring\n", dname);
			return 0;
		}
	}
	pprintf(DD_INSTALL, "init_linemon: cannot find driver\n");
	return 0;
}
Example #6
0
void DCT::help() {
    pprintf("-dct performs a real discrete cosine transform on the current"
            " image, over the dimensions given in the argument. The signal is"
            " treated as having reflective symmetry. If no arguments are"
            " given, every dimension is transformed.\n"
            "\n"
            "Usage: ImageStack -load a.png -dct xy -save freq.png\n");

}
Example #7
0
/*
 * asetbug
 *
 * Usage: asetbug handle rating won lost drew RD
 *
 *   This command allows admins to set a user's statistics for Bughouse
 *   games.  The parameters are self-explanatory: rating, # of wins,
 *   # of losses, # of draws, and ratings deviation.
 */
int com_asetbug(int p, param_list param)
{
  int p1, connected;

  if (!FindPlayer(p, param[0].val.word, &p1, &connected))
    return COM_OK;

  if (CheckPFlag(p1, PFLAG_REG)) {
    SetRating(p1, param, &player_globals.parray[p1].bug_stats);
    player_save(p1);
    pprintf(p, "Bughouse rating for %s modified.\n", player_globals.parray[p1].name);
  } else
    pprintf(p, "%s is unregistered. Can't modify rating.\n", player_globals.parray[p1].name);

  if (!connected)
    player_remove(p1);
  return COM_OK;
}
Example #8
0
File: netif.c Project: HarryR/sanos
static int netif_proc(struct proc_file *pf, void *arg) {
  struct netif *netif;
  
  for (netif = netif_list; netif != NULL; netif = netif->next) {
    pprintf(pf, "%s: addr %a mask %a gw %a\n", netif->name, &netif->ipaddr, &netif->netmask, &netif->gw);
  }

  return 0;
}
Example #9
0
void DimensionReduction::help() {
    pprintf("-dimensionreduction takes a dimensionality and projects all points on"
            " the image onto a linear subspace of best fit with that number of"
            " dimensions. It is useful if you know an image should be low"
            " dimensional (eg a sunset is mostly shades or red), and components"
            " orthogonal to that dimension are unwanted (eg chromatic"
            " abberation).\n\n"
            "Usage: ImageStack -load sunset.jpg -dimensionreduction 2 -save fixed.jpg\n\n");
}
Example #10
0
void Equalize::help() {
    pprintf("-equalize flattens out the histogram of an image, while preserving ordering"
            " between pixel brightnesses. It does this independently in each channel. When"
            " given no arguments, it produces an image with values between zero and one. With"
            " one argument, it produces values between zero and that argument. With two"
            " arguments, it produces values between the two arguments. The brightest pixel(s)"
            " will always map to the upper bound and the dimmest to the lower bound.\n\n"
            "Usage: ImageStack -load a.tga -equalize 0.2 0.8 -save out.tga\n\n");
}
Example #11
0
static int sys_converged (equation_system *sys, double *llbak,
			  gretlopt opt, PRN *prn, int *err)
{
    double crit, tol = 0.0;
    int met = 0;

    if (sys->method == SYS_METHOD_SUR || 
	sys->method == SYS_METHOD_WLS) {
	double ll = sur_loglik(sys);

	tol = SYS_LL_TOL;
	crit = ll - *llbak;

	if (opt & OPT_V) {
	    pprintf(prn, "Iteration %3d, ll = %#.8g\n", sys->iters, ll);
	}
	if (crit <= tol) {
	    met = 1;
	} else if (sys->iters < SYS_MAX_ITER) {
	    *llbak = ll;
	} 
    } else if (sys->method == SYS_METHOD_3SLS) {
	tol = SYS_BDIFF_TOL;
	crit = sys->bdiff;
	if (opt & OPT_V) {
	    pprintf(prn, "Iteration %3d, criterion = %g\n", sys->iters, crit);
	}
	if (crit <= tol) {
	    met = 1;
	} 
    }

    if (met && tol > 0 && (opt & OPT_V)) {
	pprintf(prn, "Tolerance of %g is met\n", tol);
    }

    if (!met && sys->iters >= SYS_MAX_ITER) {
	pprintf(prn, "Reached %d iterations without meeting "
		"tolerance of %g\n", sys->iters, tol);
	*err = E_NOCONV;
    }	

    return met;
}
Example #12
0
static void function_noargs_error (const char *s, parser *p)
{
    parser_print_input(p);

    pprintf(p->prn, _("'%s': no argument was given"), s);
    pputc(p->prn, '\n');
    gretl_errmsg_sprintf(_("'%s': no argument was given"), s);

    p->err = E_ARGS;
}
Example #13
0
int gretl_array_print (gretl_array *A, PRN *prn)
{
    if (A != NULL) {
	const char *s = gretl_type_get_name(A->type);

	pprintf(prn, _("Array of %s, length %d\n"), s, A->n);
    }

    return 0;
}
Example #14
0
void ComplexDivide::help() {
    pprintf("-complexdivide divides the top image in the stack by the second image"
            " in the stack, using 2 \"complex\" images as its input - a \"complex\""
            " image is one where channel 2*n is the real part of the nth channel and"
            " channel 2*n + 1 is the imaginary part of the nth channel. Using zero"
            " arguments results in a straight division (a + bi) / (c + di). Using"
            " one argument results in a conjugate division (a - bi) / (c + di).\n"
            "\n"
            "Usage: ImageStack -load a.tga -load b.tga -complexdivide -save out.tga.\n");
}
Example #15
0
void FFTConvolve::help() {
    pprintf("-fftconvolve performs convolution in Fourier space. It is much faster"
            " than -convolve for large kernels. The two arguments are the boundary"
            " condition (zero, clamp, wrap, homogeneous) and the vector-vector"
            " multiplication used (inner, outer, elementwise). The defaults are wrap"
            " and outer respectively. See -convolve for a description of each"
            " option.\n"
            "\n"
            "Usage: ImageStack -load filter.tmp -load im.jpg -fftconvolve zero inner\n");
}
void GPSSensorWriter::Write(Print *p) {
  float lat;
  float lon;
  unsigned long age;
  gps_->f_get_position(&lat, &lon, &age);

  char buf[16]; // No %f in sprintf? What the f**k.
  char buf2[16];
  pprintf(p, "GPS: LAT: %s, LON: %s AGE: %lu\n", strf(buf, lat), strf(buf2, lon), age);
}
Example #17
0
void PatchPCA::help() {
    pprintf("-patchpca treats local Gaussian neighbourhoods of pixel values as vectors"
            " and computes a stack of filters that can be used to reduce"
            " dimensionality and decorrelate the color channels. The two arguments"
            " are the standard deviation of the Gaussian, and the desired number of"
            " output dimensions. Patches near the edge of the image are not"
            " included in the covariance computation.\n"
            "Usage: ImageStack -load a.jpg -patchpca 2 8 -save filters.tmp\n"
            " -pull 1 -convolve zero inner -save reduced.tmp\n");
}
Example #18
0
void print_node(PARAM_NODE *p_node, int ident)
{
  switch(p_node->content_type) {
    case NODE_CONSTANT_INT:
      pprintf("%*cNODE_CONSTANT_INT(%d, 0x%x)",ident*2,' ',p_node->cint,p_node->cint);
      break;    
    case NODE_CONSTANT_FLOAT:
      pprintf("%*cNODE_CONSTANT_FLOAT(%d)",ident*2,' ',p_node->cfloat);
      break;    
    default:
      char *p_token_name = get_token_name(*p_node);
      if(!p_token_name) {
        p_token_name = (char *)"UNKNOWN NODE!";
        assert(0);
      }
      pprintf("%*c%s",ident*2,' ',p_token_name);
      break;
  } 
}
void Poisson::help() {
    pprintf("-poisson assumes the stack contains gradients images in x and y, and"
            " attempts to find the image which fits those gradients best in a least"
            " squares sense. It uses a preconditioned conjugate gradient descent"
            " method. It takes one argument, which is required RMS error of the"
            " result. This defaults to 0.01 if not given.\n"
            "\n"
            "Usage: ImageStack -load dx.tmp dy.tmp \n"
            "                  -poisson 0.0001 -save out.tga\n\n");
}
Example #20
0
File: dev.c Project: HarryR/sanos
static int devices_proc(struct proc_file *pf, void *arg) {
  dev_t devno;
  struct dev *dev;

  pprintf(pf, "devno name     driver           type   unit\n");
  pprintf(pf, "----- -------- ---------------- ------ ------------------------------\n");

  for (devno = 0; devno < num_devs; devno++) {
    dev = devtab[devno];
    pprintf(pf, "%5d %-8s %-16s %-6s ", devno, dev->name, dev->driver->name, devtypenames[dev->driver->type]);
    if (dev->unit) {
      pprintf(pf, "%s unit %d.%d\n", busnames[dev->unit->bus->bustype], dev->unit->bus->busno, dev->unit->unitno);
    } else {
      pprintf(pf, "<none>\n");
    }
  }

  return 0;
}
Example #21
0
/*
 * asethandle
 *
 * Usage: asethandle oldname newname
 *
 *   This command changes the handle of the player from oldname to
 *   newname.  The various player information, messages, logins, comments
 *   and games should be automatically transferred to the new account.
 */
int com_asethandle(int p, param_list param)
{
  char *player = param[0].val.word;
  char *newplayer = param[1].val.word;
  char playerlower[MAX_LOGIN_NAME], newplayerlower[MAX_LOGIN_NAME];
  int p1;

  strcpy(playerlower, player);
  stolower(playerlower);
  strcpy(newplayerlower, newplayer);
  stolower(newplayerlower);
  if (player_find_bylogin(playerlower) >= 0) {
    pprintf(p, "A player by that name is logged in.\n");
    return COM_OK;
  }
  if (player_find_bylogin(newplayerlower) >= 0) {
    pprintf(p, "A player by that new name is logged in.\n");
    return COM_OK;
  }
  p1 = player_new();
  if (player_read(p1, playerlower)) {
    pprintf(p, "No player by the name %s is registered.\n", player);
    player_remove(p1);
    return COM_OK;
  } else {
	  if (!check_admin2(p, p1)) {
		  pprintf(p, "You can't set handles for an admin with a level higher than or equal to yourself.\n");
		  player_remove(p1);
		  return COM_OK;
	  }
  }
  player_remove(p1);

  p1 = player_new();
  if ((!player_read(p1, newplayerlower)) && (strcmp(playerlower, newplayerlower))) {
    pprintf(p, "Sorry that handle is already taken.\n");
    player_remove(p1);
    return COM_OK;
  }
  player_remove(p1);

  if ((!player_rename(playerlower, newplayerlower)) && (!player_read(p1, newplayerlower))) {
    pprintf(p, "Player %s renamed to %s.\n", player, newplayer);
    free(player_globals.parray[p1].name);
    player_globals.parray[p1].name = strdup(newplayer);
    player_save(p1);
    /*if (player_globals.parray[p1].s_stats.rating > 0)
      UpdateRank(TYPE_STAND, newplayer, &player_globals.parray[p1].s_stats, player);
    if (player_globals.parray[p1].z_stats.rating > 0)
      UpdateRank(TYPE_CRAZYHOUSE, newplayer, &player_globals.parray[p1].z_stats, player);
    if (player_globals.parray[p1].w_stats.rating > 0)
      UpdateRank(TYPE_WILD, newplayer, &player_globals.parray[p1].w_stats, player);*/
  } else {
    pprintf(p, "Asethandle failed.\n");
  }
  player_remove(p1);
  return COM_OK;
}
Example #22
0
/*
   force a server reload
*/
int com_areload(int p, param_list param)
{
	extern unsigned chessd_reload_flag;

	chessd_reload_flag = 1;

	pprintf(p, "Server reload started\n");

	return COM_OK;
}
Example #23
0
void FFT::help() {
    pprintf("-fft performs a fast dft on the current image, whose values"
            " are interpreted as complex. The input is an image with 2*c channels,"
            " where channel 2*i is the real part of the i\'th channel, and channel"
            " 2*i+1 is the imaginary part of the i'th channel. The output image is"
            " laid out the same way.\n"
            "\n"
            "Usage: ImageStack -load a.tmp -fftcomplex -save freq.tmp\n\n");
    
}
Example #24
0
static int output_json_node_value (JsonNode *node,
				   PRN *prn)
{
    GType type = 0;
    int err = 0;

    if (null_node(node)) {
	gretl_errmsg_set("jsonget: got a null node");
	return E_DATA;
    }

    type = json_node_get_value_type(node);

#if 0
    fprintf(stderr, "jsonget: node type %s\n", g_type_name(type));
#endif    
    
    if (!handled_type(type)) {
	gretl_errmsg_sprintf("jsonget: unhandled object type '%s'", 
			     g_type_name(type));
	err = E_DATA;
    } else if (type == G_TYPE_STRING) {
	const gchar *s = json_node_get_string(node);

	if (s != NULL) {
	    pputs(prn, s);
	} else {
	    err = E_DATA;
	}	
    } else if (type == G_TYPE_DOUBLE) {
	double x = json_node_get_double(node);

	pprintf(prn, "%.15g", x);
    } else {
	gint64 k = json_node_get_int(node);
	double x = (double) k;

	pprintf(prn, "%.15g", x);
    }

    return err;
}
Example #25
0
/*
 * asetadmin
 *
 * Usage: asetadmin player AdminLevel
 *
 *   Sets the admin level of the player with the following restrictions.
 *   1. You can only set the admin level of players lower than yourself.
 *   2. You can only set the admin level to a level that is lower than
 *      yourself.
 */
int com_asetadmin(int p, param_list param)
{
  struct player *pp = &player_globals.parray[p];
  int p1, connected, oldlevel;

  if (!FindPlayer(p, param[0].val.word,&p1, &connected))
    return COM_OK;

  if (!check_admin2(p, p1)) {
    pprintf(p, "You can only set adminlevel for players below your adminlevel.\n");
    if (!connected)
      player_remove(p1);
    return COM_OK;
  }
  if (!strcmp(player_globals.parray[p1].login, pp->login)) {
    pprintf(p, "You can't change your own adminlevel.\n");
    return COM_OK;
  }
  if (!check_admin(p, param[1].val.integer+1)) {
    pprintf(p, "You can't promote someone to or above your adminlevel.\n");
    if (!connected)
      player_remove(p1);
    return COM_OK;
  }
  if (param[1].val.integer < 0)
  {
    pprintf(p, "Level must be positive.\n");
    if (!connected)
      player_remove(p1);
    return COM_OK;
  }
  oldlevel = player_globals.parray[p1].adminLevel;
  player_globals.parray[p1].adminLevel = param[1].val.integer;
  pprintf(p, "Admin level of %s set to %d.\n", player_globals.parray[p1].name, player_globals.parray[p1].adminLevel);
  player_save(p1);
  if (connected) {
    pprintf_prompt(p1, "\n\n%s has set your admin level to %d.\n\n", pp->name, player_globals.parray[p1].adminLevel);
  } else {
    player_remove(p1);
  }
  return COM_OK;
}
Example #26
0
static int gui_parse_object_request (const char *line, 
				     char *objname, char **param,
				     void **pptr, GretlObjType *type,
				     PRN *prn)
{
    char word[MAXSAVENAME] = {0};
    int action;

    /* get object name (if any) and dot param */
    parse_object_command(line, word, param);

    /* if no dot param, nothing doing, pass through */
    if (*param == NULL) {
	return OBJ_ACTION_NONE;
    }

    if (gretl_is_bundle(word)) {
	return OBJ_ACTION_NONE;
    }    

    /* see if there's an object associated with the name */
    *pptr = get_session_object_by_name(word, type);

    if (*pptr == NULL) {
	/* no matching object */
	if (*param) {
	    pprintf(prn, _("%s: no such object\n"), word);
	}
	return OBJ_ACTION_INVALID;
    }

    action = match_object_command(*param);

    if (action == OBJ_ACTION_INVALID) {
	pprintf(prn, _("command '%s' not recognized"), *param);
	pputc(prn, '\n');
    } else {
	strcpy(objname, word);
    } 

    return action;
}
Example #27
0
void ComplexMultiply::help() {
    pprintf("-complexmultiply multiplies the top image in the stack by the second"
            " image in the stack, using 2 \"complex\" images as its input - a"
            " \"complex\" image is one where channel 2*n is the real part of the nth"
            " channel and channel 2*n + 1 is the imaginary part of the nth"
            " channel. Using zero arguments results in a straight multiplication"
            " (a + bi) * (c + di), using one argument results in a conjugate"
            " multiplication (a - bi) * (c + di).\n"
            "\n"
            "Usage: ImageStack -load a.tga -load b.tga -complexmultiply -save out.tga.\n");
}
Example #28
0
void CreateTmp::help() {
    pprintf("-createtmp creates a zero filled floating point .tmp file of the specified"
            " dimensions. It can be used to create tmp files larger than can fit in"
            " memory. The five arguments are the filename, width, height, frames and"
            " channels. If only four arguments are specified, frames is assumed to"
            " be one.\n\n"
            "The following example creates a giant volume, and fills some of it with noise:\n"
            "ImageStack -createtmp volume.tmp 1024 1024 1024 1 \\\n"
            "           -push 256 256 256 1 -noise \\\n"
            "           -saveblock volume.tmp 512 512 512 0 \n\n");
}
Example #29
0
/*
 * asetstd
 *
 * Usage: asetstd handle rating won lost drew RD
 *
 *   This command allows admins to set a user's statistics for Standard games.
 *   The parameters are self-explanatory: rating, # of wins, # of losses, # of
 *   draws, and ratings deviation.
 */
int com_asetstd(int p, param_list param)
{
  int p1, connected;

  if (!FindPlayer(p, param[0].val.word, &p1, &connected))
    return COM_OK;

  if (CheckPFlag(p1, PFLAG_REG)) {
    SetRating(p1, param, &player_globals.parray[p1].s_stats);
    player_save(p1);
    UpdateRank(TYPE_STAND, player_globals.parray[p1].name, &player_globals.parray[p1].s_stats,
	     player_globals.parray[p1].name);
    pprintf(p, "Standard rating for %s modified.\n", player_globals.parray[p1].name);
  } else
    pprintf(p, "%s is unregistered. Can't modify rating.\n", player_globals.parray[p1].name);

  if (!connected)
    player_remove(p1);
  return COM_OK;
}
Example #30
0
static void tester3(long a0, void* a1){
    int	i = 0, ret;
    char pbuffer[SBUFSZ];
    pprintf("tester3 starts\n");
    
    while (i < 1)
    {
        i ++;
        /*
            uthread_mtx_lock(&mtx1);
            uthread_mtx_lock(&mtx3);
        */
        pprintf("test3 about to broadcast\n");
        uthread_cond_broadcast(&cond);

        sprintf(pbuffer, "thread 3: broadcast ends\n");  
        ret = write(STDOUT_FILENO, pbuffer, strlen(pbuffer));
        if (ret < 0) 
        {
            perror("uthreads_test");
            /* XXX: we should really cleanup here */
            exit(1);
        }
        
        /*  
        uthread_mtx_unlock(&mtx1);
        uthread_mtx_unlock(&mtx3);
        */       
    }

    sprintf(pbuffer, "thread 3 exiting.\n");  
    ret = write(STDOUT_FILENO, pbuffer, strlen(pbuffer));
    if (ret < 0) 
    {
        perror("uthreads_test");
        /* XXX: we should really cleanup here */
        exit(1);
    }

    uthread_exit(a0);
}