示例#1
0
//
// main:
int main(int argc, char *argv[])
{
	printf("Commander is a command line parsing module writed by L. Maddalena\n");

	t_commander *cmd = makecommander();
	addparam(cmd, "source");
	addparam(cmd, "destination");
	addoption(cmd, "f", "foo", "the foo parameter", 0, "value");
	addoption(cmd, "g", "gas", "the gas parameter", 0, NULL);
	addoption(cmd, "b", "bar", "the bar parameter", 1, "1|2|3");
	addoption(cmd, "z", "baz", "the baz parameter", 1, "name");
	addoption(cmd, "h", "help", "output usage information", 0, NULL);

	int p = parseargs(cmd, argc, argv);
	
	if(argc == 1)
	{
		showusage(argv[0], cmd);
		return 0;		
	}

	if(p == 0 || strcmp(getoptionbysname("h", cmd)->value, "1") == 0)
	{
		showhelp(argv[0], cmd);
		return 0;		
	}
	
	showreport(cmd);
}
示例#2
0
T3DObjectStarGlobe::T3DObjectStarGlobe(T3DScene *iscene) : T3DGeoObject(iscene)
{
	renderback->copyfrom(true);
	enablelight->copyfrom(false);

	blendtype->fromint(BlendTransparent);
	depthmask->fromint(DepthMaskDisable);


	radius=addparam(_qstr("Radius"),SC_valname_scalar)->content.G_content_scalar();
	starsize=addparam(_qstr("StarSize"),SC_valname_scalar)->content.G_content_scalar();
	starsize->copyfrom(0.01);

	conlinesize=addparam(_qstr("LineSize"),SC_valname_scalar)->content.G_content_scalar();conlinesize->copyfrom(0.0);
	conlinecolor=G_valuecontent<TSC_color>(&addparam(_qstr("LineColor"),SC_valname_color)->content);conlinecolor->copyfrom(0,0,1,0.5);



	calculated=false;

/*	isclosed=addparam(_qstr("IsClosed"),SC_valname_boolean)->content.G_content_boolean();
	isclosed->copyfrom(false);*/

//	curverendertype=&addparam(SC_valname_curverendertype,SC_valname_curverendertype)->content;

}
示例#3
0
T3DObjectRectangle::T3DObjectRectangle(T3DScene *iscene) : T3DGeoObjectPreCalcMesh(iscene)
{
	axis1=G_valuecontent<Tvector>(&addparam(_qstr("Axis1"),SC_valname_vector)->content);
	axis2=G_valuecontent<Tvector>(&addparam(_qstr("Axis2"),SC_valname_vector)->content);
	axis1->copyfrom(1,0,0);
	axis2->copyfrom(0,1,0);
}
示例#4
0
文件: vpnoptions.c 项目: Deanzou/ppp
// ----------------------------------------------------------------------------
//	addintparam
// ----------------------------------------------------------------------------
void addintparam(char **arg, u_int32_t *argi, char *param, u_int32_t val)
{
    char	str[32];
    
    addparam(arg, argi, param);
    snprintf(str, sizeof(str), "%d", val);
    addparam(arg, argi, str);
}
示例#5
0
T3DObjectBar::T3DObjectBar(T3DScene *iscene) : T3DGeoObjectPreCalcMesh(iscene)
{
	addparam(_qstr("SizeX"),SC_valname_scalar);
	addparam(_qstr("SizeY"),SC_valname_scalar);
	addparam(_qstr("SizeZ"),SC_valname_scalar);
	param_setvalue(_qstr("SizeX"),1.0);
	param_setvalue(_qstr("SizeY"),1.1);
	param_setvalue(_qstr("SizeZ"),1.23);
}
示例#6
0
T3DControl_Frame::T3DControl_Frame(T3DScene *iscene, bool addtocontrols) : T3DControl(iscene,addtocontrols)
{
	sizex=addparam(_qstr("SizeX"),SC_valname_scalar)->content.G_content_scalar();
	sizey=addparam(_qstr("SizeY"),SC_valname_scalar)->content.G_content_scalar();

/*	color->Set_R(0.15);
	color->Set_G(0.15);
	color->Set_B(0.15);*/
}
示例#7
0
T3DGeoObjectPreCalcMesh::T3DGeoObjectPreCalcMesh(T3DScene *iscene) : T3DGeoObject(iscene)
{
	iscalculated=false;
	canbuffer=addparam(_qstr("CanBuffer"),SC_valname_boolean,false,_text("Uses Vertex Buffer Objects (accelerates for complex objects)"),_text("Optimization"))->content.G_content_boolean();
	canbuffer->copyfrom(false);

	calcedges=addparam(_qstr("CalculateEdges"),SC_valname_boolean,false,_text("Determines whether or not the edges are calculated (needed for volume shadows)"),_text("Optimization"))->content.G_content_boolean();

}
示例#8
0
T3DControl_Menu::T3DControl_Menu(T3DScene *iscene, bool addtocontrols) : T3DControl(iscene,addtocontrols) , root(NULL)
{
	sizex=addparam(_qstr("SizeX"),SC_valname_scalar)->content.G_content_scalar();
	selectid=addparam(_qstr("SelectID"),SC_valname_string)->content.G_content_string();

	addparam(_qstr("Texture"),SC_valname_string,false,_text(""),PARAMSUBCLASS_APPEARANCE);

	root.cursubsel=0;

}
示例#9
0
T3DObject3DText::T3DObject3DText(T3DScene *iscene) : T3DGeoObject(iscene)
{
	content=addparam(_qstr("Content"),SC_valname_string)->content.G_content_string();
	depth=addparam(_qstr("Depth"),SC_valname_scalar)->content.G_content_scalar();
	unitdirx=G_valuecontent<Tvector>(&addparam(_qstr("UnitX"),SC_valname_vector)->content);
	unitdiry=G_valuecontent<Tvector>(&addparam(_qstr("UnitY"),SC_valname_vector)->content);
	*unitdirx=Tvector(1,0,0);
	*unitdiry=Tvector(0,1,0);
	cancache->copyfrom(false);
}
示例#10
0
T3DObjectSolidArrow::T3DObjectSolidArrow(T3DScene *iscene) : T3DGeoObjectPreCalcMesh(iscene)
{
	axis1=G_valuecontent<Tvector>(&addparam(_qstr("Axis"),SC_valname_vector)->content);
	axis2=G_valuecontent<Tvector>(&addparam(_qstr("NormAxis"),SC_valname_vector)->content);
	axis1->copyfrom(1,0,0);
	axis2->copyfrom(0,1,0);

	width=addparam(_qstr("Width"),SC_valname_scalar)->content.G_content_scalar();
	thick=addparam(_qstr("Thickness"),SC_valname_scalar)->content.G_content_scalar();

}
示例#11
0
T3DObjectCylinder::T3DObjectCylinder(T3DScene *iscene) : T3DGeoObjectPreCalcMesh(iscene)
{
	radius=addparam(_qstr("Radius"),SC_valname_scalar)->content.G_content_scalar();
	radiuschange=addparam(_qstr("RadiusChange"),SC_valname_scalar)->content.G_content_scalar();
	axis=G_valuecontent<Tvector>(&addparam(_qstr("Axis"),SC_valname_vector)->content);
	resolution=addparam(_qstr("Resolution"),SC_valname_scalar)->content.G_content_scalar();
	isclosed=addparam(_qstr("IsClosed"),SC_valname_boolean)->content.G_content_boolean();
	radius->copyfrom(1);radiuschange->copyfrom(1);
	resolution->copyfrom(20);
	axis->copyfrom(1,0,0);
}
示例#12
0
T3DObject::T3DObject(T3DScene *iscene)
{
	parentframe=NULL;
	scene=iscene;
	cosmos=&T3DCosmos::Get();
	isobjvisible=addparam(_qstr("Visible"),SC_valname_boolean)->content.G_content_boolean();

	showlefteye=addparam(_qstr("ShowLeftEye"),SC_valname_boolean)->content.G_content_boolean();
	showrighteye=addparam(_qstr("ShowRightEye"),SC_valname_boolean)->content.G_content_boolean();

	centerpos=G_valuecontent<Tvertex>(&addparam(_qstr("Center"),SC_valname_vertex)->content);

}
示例#13
0
T3DControl_List::T3DControl_List(T3DScene *iscene, bool addtocontrols) : T3DControl(iscene,addtocontrols)
{
	sizex=addparam(_qstr("SizeX"),SC_valname_scalar)->content.G_content_scalar();

	list=G_valuecontent<TSC_list>(&addparam(_qstr("List"),SC_valname_list)->content);

	selectidx=addparam(_qstr("SelectIdx"),SC_valname_scalar)->content.G_content_scalar();
	selectidx->copyfrom(0.0);

	county=addparam(_qstr("CountY"),SC_valname_scalar)->content.G_content_scalar();
	county->copyfrom(4);

	offset=0;

}
示例#14
0
bool xRedisClient::sadd(const RedisDBIdx& dbi,     const string& key, const VALUES& vValue, int64_t& count) {
    VDATA vCmdData;
    vCmdData.push_back("SADD");
    vCmdData.push_back(key);
    addparam(vCmdData, vValue);
    return commandargv_integer(dbi, vCmdData, count);
}
示例#15
0
bool xRedisClient::srem(const RedisDBIdx& dbi,  const KEY& key, const VALUES& vmembers, int64_t& count) {
    VDATA vCmdData;
    vCmdData.push_back("SREM");
    vCmdData.push_back(key);
    addparam(vCmdData, vmembers);
    return commandargv_integer(dbi, vCmdData, count);
}
示例#16
0
bool xRedisClient::hmset(const RedisDBIdx& dbi,    const string& key, const VDATA& vData){
    VDATA vCmdData;
    vCmdData.push_back("HMSET");
    vCmdData.push_back(key);
    addparam(vCmdData, vData);
    SETDEFAULTIOTYPE(MASTER);
    return commandargv_status(dbi, vCmdData);
}
示例#17
0
bool xRedisClient::hmget(const RedisDBIdx& dbi,    const string& key, const KEYS& field, ArrayReply& array){
    VDATA vCmdData;
    vCmdData.push_back("HMGET");
    vCmdData.push_back(key);
    addparam(vCmdData, field);
    SETDEFAULTIOTYPE(SLAVE);
    return commandargv_array(dbi, vCmdData, array);
}
示例#18
0
bool xRedisClient::hdel(const RedisDBIdx& dbi,    const string& key, const KEYS& vfiled, int64_t& count) {
    VDATA vCmdData;
    vCmdData.push_back("HDEL");
    vCmdData.push_back(key);
    addparam(vCmdData, vfiled);
    SETDEFAULTIOTYPE(MASTER);
    return commandargv_integer(dbi, vCmdData, count);
}
bool xRedisClient::zadd(const RedisDBIdx& dbi, const KEY& key,   const VALUES& vValues, int64_t& count){
    VDATA vCmdData;
    vCmdData.push_back("ZADD");
    vCmdData.push_back(key);
    addparam(vCmdData, vValues);
    SETDEFAULTIOTYPE(MASTER);
    return commandargv_integer(dbi, vCmdData, count);
}
示例#20
0
T3DControl::T3DControl(T3DScene *iscene, bool addtocontrols) : T3DObject(iscene)
{
	position=G_valuecontent<Tvertex>(&addparam(_qstr("Position"),SC_valname_vertex)->content);

	sizeunit=addparam(_qstr("Size"),SC_valname_scalar)->content.G_content_scalar();
	sizeunit->copyfrom(0.05);

	color=G_valuecontent<TSC_color>(&addparam(_qstr("Color"),SC_valname_color)->content);
	color->copyfrom(1,1,1,1);
	if (addtocontrols) G_3DCosmos().controls_add(this);

	wasmodified=addparam(_qstr("WasModified"),SC_valname_boolean)->content.G_content_boolean();
	wasmodified->copyfrom(false);

	isdefault=addparam(_qstr("IsDefault"),SC_valname_boolean)->content.G_content_boolean();
	isdefault->copyfrom(false);

}
示例#21
0
bool xRedisClient::srem(const RedisDBIdx& dbi,  const KEY& key, const VALUES& vmembers, int64_t& count) {
	if (0 == key.length()) {
		return false;
	}
	SETDEFAULTIOTYPE(MASTER);
	VDATA vCmdData;
	vCmdData.push_back("SREM");
	vCmdData.push_back(key);
	addparam(vCmdData, vmembers);
	return commandargv_integer(dbi, vCmdData, count);
}
示例#22
0
bool xRedisClient::lpush(const RedisDBIdx& dbi,    const string& key, const VALUES& vValue, int64_t& length) {
	if (0 == key.length()) {
		return false;
	}
	VDATA vCmdData;
	vCmdData.push_back("LPUSH");
	vCmdData.push_back(key);
	addparam(vCmdData, vValue);
	SETDEFAULTIOTYPE(MASTER);
	return commandargv_integer(dbi, vCmdData, length);
}
示例#23
0
T3DControl_Scalar::T3DControl_Scalar(T3DScene *iscene, bool addtocontrols) : T3DControl(iscene,addtocontrols)
{
	sizex=addparam(_qstr("SizeX"),SC_valname_scalar)->content.G_content_scalar();
	rangesizex=addparam(_qstr("RangeSizeX"),SC_valname_scalar)->content.G_content_scalar();

	value=addparam(_qstr("Value"),SC_valname_scalar)->content.G_content_scalar();
	vmin=addparam(_qstr("Min"),SC_valname_scalar)->content.G_content_scalar();vmin->copyfrom(0.0);
	vmax=addparam(_qstr("Max"),SC_valname_scalar)->content.G_content_scalar();vmax->copyfrom(100.0);
	vstep=addparam(_qstr("Step"),SC_valname_scalar)->content.G_content_scalar();vstep->copyfrom(2.0);
	decimalcount=addparam(_qstr("DecimalCount"),SC_valname_scalar)->content.G_content_scalar();
}
示例#24
0
/* ----------------------------------------------------------------------------- 
    l2tpvpn_get_pppd_args
----------------------------------------------------------------------------- */
int l2tpvpn_get_pppd_args(struct vpn_params *params)
{

    CFStringRef	string;
    
    if (params->serverRef) {			
        /* arguments from the preferences file */
        addstrparam(params->exec_args, &params->next_arg_index, "l2tpmode", "answer");

        string = get_cfstr_option(params->serverRef, kRASEntL2TP, kRASPropL2TPTransport);
        if (string && CFEqual(string, kRASValL2TPTransportIP)) {
            addparam(params->exec_args, &params->next_arg_index, "l2tpnoipsec");
            opt_noipsec = 1;
        }

        string = get_cfstr_option(params->serverRef, kRASEntL2TP, kRASPropL2TPIPSecSharedSecret);
        if (string) {
            CFStringGetCString(string, opt_ipsecsharedsecret, sizeof(opt_ipsecsharedsecret), kCFStringEncodingUTF8);
        }

        string = get_cfstr_option(params->serverRef, kRASEntL2TP, kRASPropL2TPIPSecSharedSecretEncryption);
        if (string) {
            if (CFEqual(string, kRASValL2TPIPSecSharedSecretEncryptionKey))
                opt_ipsecsharedsecrettype = "key";
            else if (CFEqual(string, kRASValL2TPIPSecSharedSecretEncryptionKeychain))
                opt_ipsecsharedsecrettype = "keychain";
        }

    } else {
        /* arguments from command line */
        if (opt_noipsec)
            addparam(params->exec_args, &params->next_arg_index, "l2tpnoipsec");
    }

    return 0;
}
示例#25
0
T3DObjectSphere::T3DObjectSphere(T3DScene *iscene) : T3DGeoObjectPreCalcMesh(iscene)
{
	addparam(_qstr("Radius"),SC_valname_scalar);param_setvalue(_qstr("Radius"),1.0);
	addparam(_qstr("Resolution"),SC_valname_scalar);param_setvalue(_qstr("Resolution"),20);

	addparam(_qstr("Angle1Min"),SC_valname_scalar);param_setvalue(_qstr("Angle1Min"),0.0);
	addparam(_qstr("Angle1Max"),SC_valname_scalar);param_setvalue(_qstr("Angle1Max"),2*Pi);

	addparam(_qstr("Angle2Min"),SC_valname_scalar);param_setvalue(_qstr("Angle2Min"),0.0);
	addparam(_qstr("Angle2Max"),SC_valname_scalar);param_setvalue(_qstr("Angle2Max"),Pi);

	addparam(_qstr("Flattening"),SC_valname_scalar);param_setvalue(_qstr("Flattening"),1.0);

}
示例#26
0
T3DObjectPie::T3DObjectPie(T3DScene *iscene) : T3DGeoObjectPreCalcMesh(iscene)
{

	radius1=addparam(_qstr("Radius1"),SC_valname_scalar)->content.G_content_scalar();
	radius2=addparam(_qstr("Radius2"),SC_valname_scalar)->content.G_content_scalar();
	height=addparam(_qstr("Height"),SC_valname_scalar)->content.G_content_scalar();
	axis1=G_valuecontent<Tvector>(&addparam(_qstr("Axis1"),SC_valname_vector)->content);
	axis2=G_valuecontent<Tvector>(&addparam(_qstr("Axis2"),SC_valname_vector)->content);
	otherdir=addparam(_qstr("InvertDir"),SC_valname_boolean)->content.G_content_boolean();
	otherdir->copyfrom(false);
	resolution=addparam(_qstr("Resolution"),SC_valname_scalar)->content.G_content_scalar();
	radius1->copyfrom(0.5);radius2->copyfrom(1.0);
	resolution->copyfrom(20);
	axis1->copyfrom(1,0,0);
	axis2->copyfrom(0,1,0);
	height->copyfrom(1.0);
}
示例#27
0
文件: 3dclock.cpp 项目: pvaut/Z-Flux
T3DObjectClock::T3DObjectClock(T3DScene *iscene) : T3DGeoObject(iscene)
{
	clocktype=&addparam(_qstr("Type"),SC_valname_ClockType)->content;
	size=addparam(_qstr("Size"),SC_valname_scalar)->content.G_content_scalar();
	timeshift=addparam(_qstr("TimeShift"),SC_valname_scalar)->content.G_content_scalar();

	hasowntime=addparam(_qstr("HasOwnTime"),SC_valname_boolean)->content.G_content_boolean();
	hasowntime->copyfrom(false);

	disptime=G_valuecontent<TSC_time>(&addparam(_qstr("Time"),SC_valname_time)->content);

	axis1=G_valuecontent<Tvector>(&addparam(_qstr("Axis1"),SC_valname_vector)->content);
	axis2=G_valuecontent<Tvector>(&addparam(_qstr("Axis2"),SC_valname_vector)->content);

	monthnames=G_valuecontent<TSC_list>(&addparam(_qstr("Monthnames"),SC_valname_list)->content);

	TSC_value val;
	val.settype(GetTSCenv().G_datatype(SC_valname_string));

	val.fromstring(_TRL(_text("January")));monthnames->add(&val);
	val.fromstring(_TRL(_text("February")));monthnames->add(&val);
	val.fromstring(_TRL(_text("March")));monthnames->add(&val);
	val.fromstring(_TRL(_text("April")));monthnames->add(&val);
	val.fromstring(_TRL(_text("May")));monthnames->add(&val);
	val.fromstring(_TRL(_text("June")));monthnames->add(&val);
	val.fromstring(_TRL(_text("July")));monthnames->add(&val);
	val.fromstring(_TRL(_text("August")));monthnames->add(&val);
	val.fromstring(_TRL(_text("September")));monthnames->add(&val);
	val.fromstring(_TRL(_text("October")));monthnames->add(&val);
	val.fromstring(_TRL(_text("November")));monthnames->add(&val);
	val.fromstring(_TRL(_text("December")));monthnames->add(&val);

	size->copyfrom(1.0);
	timeshift->copyfrom(0.0);
	axis1->copyfrom(1,0,0);
	axis2->copyfrom(0,1,0);
}
示例#28
0
T3DObjectStarMap::T3DObjectStarMap(T3DScene *iscene) : T3DGeoObject(iscene)
{
	renderback->copyfrom(true);
	enablelight->copyfrom(false);

	blendtype->fromint(BlendTransparent);
	depthmask->fromint(DepthMaskDisable);


	sizex=addparam(_qstr("SizeX"),SC_valname_scalar)->content.G_content_scalar();
	sizey=addparam(_qstr("SizeY"),SC_valname_scalar)->content.G_content_scalar();

	offsetanglex=addparam(_qstr("OffsetAngleX"),SC_valname_scalar)->content.G_content_scalar();

	starsize=addparam(_qstr("StarSize"),SC_valname_scalar)->content.G_content_scalar();
	starsize->copyfrom(0.01);

	conlinesize=addparam(_qstr("LineSize"),SC_valname_scalar)->content.G_content_scalar();conlinesize->copyfrom(0.0);
	conlinecolor=G_valuecontent<TSC_color>(&addparam(_qstr("LineColor"),SC_valname_color)->content);conlinecolor->copyfrom(0,0,1,0.5);

	singleconstellationname=addparam(_qstr("SingleConstellationName"),SC_valname_string)->content.G_content_string();singleconstellationname->fromstring(_qstr(""));

	calculated=false;
}
示例#29
0
文件: sur552.c 项目: mildred/Varkon
       DBstatus   varkon_vda_rsur2 (

/*-------------- Argument declarations -----------------------------*/
/*                                                                  */
/* In:                                                              */
/*                                                                  */
   FILE    *f_vda,       /* Input VDA-FS file                 (ptr) */
   char    rest[],       /* Substring with possible parameter values*/
   DBint    nu,          /* Number of patches in U direction  (ptr) */
   DBint    nv,          /* Number of patches in V direction  (ptr) */
   DBPatch *p_pat )      /* Topological patch data            (ptr) */
/*                                                                  */
/* Out:                                                             */
/*                                                                  */
/*                                                                  */
/* Data to                                                          */
/*                                                                  */
/*-----------------------------------------------------------------!*/

/*!New-Page--------------------------------------------------------!*/

{ /* Start of function */

/*!New-Page--------------------------------------------------------!*/

/*!--------------- Internal variables ------------------------------*/
/*                                                                  */
   DBint   max_l;        /* Maximum number of lines in input file   */
   DBint   i_l;          /* Loop index line in input file           */
   DBint   iu;           /* Loop index U patch                      */
   DBint   iv;           /* Loop index V patch                      */
   DBPatch *p_t;         /* Current patch                     (ptr) */
/*                                                                  */
/*-----------------------------------------------------------------!*/

   DBint   i_p;          /* Loop index parameter value              */
   DBfloat comptol;      /* Computer tolerance (accuracy)           */
   char    rad[133];     /* One line in the VDA-FS file             */
   DBint   status;       /* Error code from a called function       */
   char    errbuf[80];   /* String for error message fctn erpush    */

/*--------------end-of-declarations---------------------------------*/

/*!                                                                 */
/* Algorithm                                                        */
/* =========                                                        */
/*                                                                 !*/

/*!                                                                 */
/* Check of input data and initializations                          */
/*                                                                 !*/

#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC),"sur552*Enter*  \n");
fflush(dbgfil(SURPAC)); /* To file from buffer      */
}
#endif

/*!                                                                 */
/* Number parameter values:                                         */
   n_param = nu + 1 + nv +1;
/*                                                                 !*/

/*!                                                                 */
/* Computer tolerance. Call of varkon_comptol (sur753).             */
/*                                                                 !*/

   comptol=varkon_comptol();

   n_retrieved = 0;
   n_upar      = 0;
   n_vpar      = 0;


/*!                                                                 */
/* Loop for all lines in the input VDA-FS file. There is a maximum  */
/* of max_l= nu*nv+2 as a program check.                            */
/* First get parameters from the input (part of the) previous line  */
/*                                                                 !*/

  status= addparam( rest, nu, nv );
  if (status<0) 
    return(status);

max_l   = nu*nv+2;
i_l     =     0;

while ( fgets(rad,132,f_vda)  != NULL )
  {
/*!                                                                 */
/*      i. Check that number of interations not is exceeded         */
/*                                                                 !*/
  i_l = i_l + 1;
  if ( i_l > max_l )
    {
    sprintf(errbuf,"read not OK%%sur552");
    return(varkon_erpush("SU2993",errbuf));
    }

    status= addparam( rad, nu, nv );
    if (status<0) 
      return(status);

    if ( n_retrieved >= n_param ) goto allpar;

  }                /* End while */


  sprintf(errbuf,"n_param>n_retrieved%%sur552");
  return(varkon_erpush("SU2993",errbuf));


allpar:; /*! Label: All parameter values retrieved                 !*/

/*!                                                                 */
/* Check that there is no extra data is on the last line            */
/*                                                                 !*/

  if  ( n_param != n_retrieved )
    {
    sprintf(errbuf,"n_param!=n_retrieved%%sur552");
    return(varkon_erpush("SU2993",errbuf));
    }
    
/* Temporarely for Michael No check !!!!!  */
/*!                                                                 */
/* Only programmed for 0-1 parameter intervals. Check !             */
/*                                                                 !*/
/*
  for ( i_p = 1; i_p < n_upar; ++i_p )
    {
    if  (  fabs(all_u[i_p]-all_u[i_p-1]-1.0) > 10.0*comptol )
      {
      sprintf(errbuf,"not 0-1 U value%%sur552");
      return(varkon_erpush("SU2993",errbuf));
      }
    }

  for ( i_p = 1; i_p < n_vpar; ++i_p )
    {
    if  (  fabs(all_v[i_p]-all_v[i_p-1]-1.0) > 10.0*comptol )
      {
      sprintf(errbuf,"not 0-1 V value%%sur552");
      return(varkon_erpush("SU2993",errbuf));
      }
    }
*/
/*!                                                                 */
/* Parameter values to the topological patches.                     */
/*                                                                 !*/


for ( iv=0; iv<nv; ++iv )                /* Start loop V patches    */
  {
  for ( iu=0; iu<nu; ++iu )              /* Start loop U patches    */
    {

    p_t           = p_pat  + iu*nv + iv; 

    p_t->iu_pat   = (short)(iu + 1);
    p_t->iv_pat   = (short)(iv + 1);
    p_t->us_pat   = (DBfloat)iu+1.0;
    p_t->ue_pat   = (DBfloat)iu+2.0-comptol;
    p_t->vs_pat   = (DBfloat)iv+1.0;
    p_t->ve_pat   = (DBfloat)iv+2.0-comptol;

     }
   }


#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC),
"sur552 n_upar %d n_vpar %d\n",(short)n_upar,(short)n_vpar);
fflush(dbgfil(SURPAC));
}
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC),
"sur552 Exit*varkon_vda_rsur2 * i_l %d n_param %d n_retrieved %d\n", 
                  (short)i_l, (short)n_param, (short)n_retrieved );
fflush(dbgfil(SURPAC));
}
#endif

    return(SUCCED);

  }
示例#30
0
文件: scot.c 项目: eddyc/csound
static                          /* reads from one $instrument to the next */
void readinstsec(Inst *inst,
                 Nextp **nextlist,
                 Rat *grpmul,
                 Rat *timesig,
                 Rat *curtime,
                 Rat *lastbar,
                 Rat *lastnote,
                 Note **notetop,
                 Note **ln,
                 Tempo **tempop,
                 int *accidentals,
                 int *octaves,
                 int *vertical,
                 int *key, int *barkey, int *transpose, char *endchar)
{
    static Rat durdiv = { 4L, 1L };

    int     c, z, lastpitchclass;
    char    s[128], *sp;
    Rat     ratstack, rattmp;
    Note   *pn, *nn, *pn2 = NULL;
    Strlist *ps;
    Nextp  *nextpp;

#ifdef DEBUG
    printf("Reading instrument section: %s\n", inst->name);
#endif

    pn = (*notetop);
    for (;;) {
      findchar(&c);
      if (strchr(endchar, c))
        break;

#ifdef DEBUG
      printf("Processing char: %c\n", c);
#endif

      switch (c) {
      case 't':
        if (findint(&c)) {
          scoterror(Str("Tempo must be specified"));
          break;
        }
        if ((*tempop)->next) {
          scoterror(Str("Redefinition of tempo"));
          break;
        }
        (*tempop)->next = (Tempo *) malloc(sizeof(Tempo));
        *tempop = (*tempop)->next;
        (*tempop)->next = NULL;
        ratass(&((*tempop)->time), curtime);
        (*tempop)->val = c;
        break;
      case '!':
        efindword(s);
        if ((c = strlen(s)) < 2)
          scoterror(Str("Must specify 2 or more letters of keyword"));
        if (!strncmp(s, "accidentals", c)) {
          if (findonoff(accidentals))
            scoterror(Str("Must be \"on\" or \"off\""));

#ifdef DEBUG
          printf(" accidentals %s\n", accidentals ? "on" : "off");
#endif

        }
        else if (!strncmp(s, "octaves", c)) {
          if (findonoff(octaves))
            scoterror(Str("Must be \"on\" or \"off\""));

#ifdef DEBUG
          printf(" ocatves %s\n", *octaves ? "on" : "off");
#endif

        }
        else if (!strncmp(s, "vertical", c)) {
          if (findonoff(vertical))
            scoterror(Str("Must be \"on\" or \"off\""));

#ifdef DEBUG
          printf(" vertical %s\n", *vertical ? "on" : "off");
#endif

        }
        else if (!strncmp(s, "timesignature", c)) {
          efindword(s);

          if ((sscanf(s, "%lu/%lu", &timesig->num, &timesig->denom) != 2)
              ||
              (&(timesig->denom) == 0) ) {
            scoterror(Str("Invalid time signature"));
            timesig->num = 0;
            timesig->denom = 1;
          }

#ifdef DEBUG
          printf(" time sig=%lu/%lu\n", timesig->num, timesig->denom);
#endif

          ratstack.num = 4;
          ratstack.denom = 1;
          ratmul(timesig, timesig, &ratstack);

#ifdef DEBUG
          printf(" measure length=%f\n", ratval(timesig));
#endif

        }
        else if (!strncmp(s, "key", c)) {
          int     y;

          efindword(s);
          for (z = 0; z < PITCHCLASSES; z++)
            key[z] = 0;
          c = y = 0;
          for (z = 0; s[z] != (char) 0; z++)
            switch ((int) s[z]) {
            case '#':
              c = y + 1;
              y++;
              break;
            case '-':
              c = y - 1;
              y--;
              break;
            default:
              if (!isalpha(s[z]))
                scoterror(Str("Bad key signature"));
              key[letterval((int) s[z])] = c;
              y = 0;
            }
          for (z = 0; z < PITCHCLASSES; z++)
            barkey[z] = key[z];
        }
        else if (!strncmp(s, "transpose", c)) {
          efindword(s);
          *transpose = 0;
          for (z = 0; s[z]; z++) {
            switch (s[z]) {
            case ',':
              (*transpose) -= NOTESPEROCT;
              break;
            case '\'':
              (*transpose) += NOTESPEROCT;
              break;
            case '=':
              (*transpose) = 0;
              break;
            case '#':
              (*transpose)++;
              break;
            case '-':
              (*transpose)--;
              break;
            default:
              (*transpose) += naturals[letterval((int) s[z])];
            }
          }
        }
        else if (!strncmp(s, "next", c)) {
          efindword(s);
          if (sscanf(s, "p%d", &c) != 1) {
            scoterror(Str("Invalid field"));
            efindword(s);
            break;
          }
          efindword(s);
          if (sscanf(s, "p%d", &z) != 1) {
            scoterror(Str("Invalid field"));
            break;
          }
          if (*nextlist == NULL) {
            *nextlist = (Nextp *) malloc(sizeof(Nextp));
            nextpp = (*nextlist);
            nextpp->next = NULL;
          }
          else {
            nextpp = (*nextlist);
            if ((c == nextpp->dst) || (z == nextpp->src))
              scoterror(Str("Nested next-parameter passing"));
            while (nextpp->next) {
              nextpp = nextpp->next;
              if ((c == nextpp->dst) || (z == nextpp->src))
                scoterror(Str("Nested next-parameter passing"));
            }
            nextpp->next = (Nextp *) malloc(sizeof(Nextp));
            nextpp = nextpp->next;
            nextpp->next = NULL;
          }
          nextpp->src = c;
          nextpp->dst = z;
        }
        else
          scoterror(Str("Unrecognised keyword"));
        break;
      case '{':
        findint(&c);
        expectchar(':');
        if (!c) {
          ratstack.num = 2L;
          ratstack.denom = 3L;
        }
        else {
          ratstack.denom = (unsigned long) c;
          findint(&c);
          if (!c) {
            for (z = 1; (unsigned long) z < ratstack.denom; z *= 2);
            z /= 2;
            ratstack.num = (unsigned long) z;
          }
          else
            ratstack.num = (unsigned long) c;
          expectchar(':');
        }
        ratmul(grpmul, grpmul, &ratstack);
        readinstsec(inst, nextlist, grpmul, timesig, curtime,
                    lastbar, lastnote, notetop, ln, tempop, accidentals,
                    octaves, vertical, key, barkey, transpose, ":");
        ratdiv(grpmul, grpmul, &ratstack);
        expectchar(':');
        expectchar('}');
        break;
      case '(':
        ratass(&ratstack, curtime);
        if (pn == (*notetop)) {
          readinstsec(inst, nextlist, grpmul, timesig, curtime,
                      lastbar, lastnote, notetop, ln, tempop, accidentals,
                      octaves, vertical, key, barkey, transpose, ")");
          pn = (*notetop);
        }
        else {
          readinstsec(inst, nextlist, grpmul, timesig, curtime,
                      lastbar, lastnote, &pn2->next, ln, tempop, accidentals,
                      octaves, vertical, key, barkey, transpose, ")");
          pn = pn2->next;
        }
        expectchar(')');
        ratass(lastnote, &ratstack);
        break;
      case '/':
        ratadd(lastbar, lastbar, timesig);
        if ((timesig->num) && (ratcmp(lastbar, curtime))) {
          scoterror(Str("Wrong number of beats in bar"));
          ratass(lastbar, curtime);
        }
        for (z = 0; z < PITCHCLASSES; z++)
          barkey[z] = key[z];
        break;
      case '<':
        if (pn == NULL) {
          scoterror(Str("Syntax error: cannot back up"));
          break;
        }
        if (pn->next == NULL) {
          pn->next = (Note *) malloc(sizeof(Note));
          initnote(pn->next);
          pn->next->instrum = pn->instrum + 0.01;
        }
        pn2 = pn;
        pn = pn->next;
        ratass(curtime, lastnote);
        break;
      default:

#ifdef DEBUG
        printf("Reading note\n");
        printf(" time=%lu/%lu\n", curtime->num, curtime->denom);
        printf(" =%f\n", ratval(curtime));
#endif

        scotungetc();
        nn = (Note *) malloc(sizeof(Note));
        nn->p = NULL;
        nn->written = FALSE;
        if (*notetop == NULL) {
          pn = (*ln) = (*notetop) = (Note *) malloc(sizeof(Note));
          initnote(*notetop);
          (*notetop)->instrum = (double) inst->number + 0.01;
        }
        else if (ratcmp(curtime, lastnote))
          pn = (*notetop);
        nn->instrum = pn->instrum;

#ifdef DEBUG
        printf(" instrument #%f\n", nn->instrum);
#endif

        if (*vertical)
          strlistcopy(&nn->carryp, &(*ln)->carryp);
        else
          strlistcopy(&nn->carryp, &pn->carryp);
        for (nextpp = (*nextlist); nextpp; nextpp = nextpp->next) {
          sp = findparam(nextpp->dst, &nn->carryp);
          if (!strcmp(sp, "."))
            strcpy(sp, NEXTP);
        }
        ratass(&nn->start, curtime);
        if (!findint(&c)) {
          ratstack.num = (unsigned long) c;
          ratstack.denom = 1L;
          ratdiv(&nn->dur, &durdiv, &ratstack);
          ratass(&ratstack, &nn->dur);
          rattmp.num = 1L;
          rattmp.denom = 2L;
          for (;;) {
            findchar(&c);
            if (c != '.')
              break;
            ratmul(&ratstack, &ratstack, &rattmp);
            ratadd(&nn->dur, &nn->dur, &ratstack);
          }
        }
        else {
          if (*vertical)
            ratass(&nn->dur, &((*ln)->lastdur));
          else
            ratass(&nn->dur, &pn->lastdur);
          findchar(&c);
        }
        ratass(&nn->lastdur, &nn->dur);
        ratmul(&nn->dur, &nn->dur, grpmul);

#ifdef DEBUG
        printf(" duration=%f\n", ratval(&nn->dur));
        printf(" c=%c\n", c);
#endif

        if (c == '=') {
          nn->octave = 8;
          lastpitchclass = 0;
        }
        else {
          nn->octave = pn->octave;
          lastpitchclass = pn->pitchclass;
          scotungetc();
        }
        for (;;) {
          findchar(&c);
          if (c == '\'')
            nn->octave++;
          else if (c == ',')
            nn->octave--;
          else
            break;
        }
        if (c == 'r') {
          ratass(lastnote, curtime);
          ratmul(&rattmp, &nn->lastdur, grpmul);
          ratadd(curtime, curtime, &rattmp);
          ratass(&(*ln)->lastdur, &nn->lastdur);
          ratass(&pn->lastdur, &nn->lastdur);
          freenote(nn);
          break;
        }
        else {
          nn->pitchclass = letterval(c);
          if (*octaves) {
            c = nn->pitchclass - lastpitchclass;
            if (c < -(PITCHCLASSES / 2))
              nn->octave++;
            else if (c > PITCHCLASSES / 2)
              nn->octave--;
          }
        }
        nn->accid = 0;
        nn->accmod = FALSE;
        for (;;) {
          findchar(&c);
          if (c == '#') {
            nn->accid++;
            nn->accmod = TRUE;
          }
          else if (c == '-') {
            nn->accid--;
            nn->accmod = TRUE;
          }
          else if (c == 'n') {
            nn->accid = 0;
            nn->accmod = TRUE;
          }
          else
            break;
        }
        if (!nn->accmod)
          nn->accid = barkey[nn->pitchclass];
        else if (*accidentals)
          barkey[nn->pitchclass] = nn->accid;

#ifdef DEBUG
        printf(" transpose=%d\n", *transpose);
        printf(" octave=%d pitchclass=%d accid=%d transpose=%d pitch=%f\n",
               nn->octave, nn->pitchclass, nn->accid, *transpose,
               pitchval(nn->octave, nn->pitchclass, nn->accid, *transpose));
#endif

        if (c == '_') {
          findchar(&c);
          if (c == '_') {
            nn->tie = TRUE;
            nn->slur = 0;
            findchar(&c);
          }
          else {
            nn->slur = 1;
            nn->tie = FALSE;
          }
        }
        else {
          nn->slur = 0;
          nn->tie = FALSE;
        }
        if (pn->slur & 1)
          nn->slur += 2;

#ifdef DEBUG
        printf(" slur=%d tie=%d\n", nn->slur, nn->tie);
#endif

        if (pn->tie) {
          ratadd(&rattmp, &pn->start, &pn->dur);
          if (ratcmp(&rattmp, curtime))
            scoterror(Str("Improper tie"));
          if (((nn->octave != pn->octave) ||
               (nn->pitchclass != pn->pitchclass) ||
               ((nn->accid != pn->accid) && (nn->accmod))) &&
              (pitchval(nn->octave, nn->pitchclass, nn->accid, *transpose) !=
               pitchval(pn->octave, pn->pitchclass, pn->accid, *transpose)))
            scoterror(Str("Tie between different pitches"));
          ratadd(&pn->dur, &pn->dur, &nn->dur);
          ratass(&pn->lastdur, &nn->lastdur);
          pn->slur += nn->slur;
          pn->tie = nn->tie;
          freenote(nn);
          nn = pn;
          if (c == (char) '[')
            scoterror(Str("Warning: params changed on tie"));
        }
        else {
          ps = nn->p = (Strlist *) malloc(sizeof(Strlist));
          for (z = 0; z < 4; z++) {
            ps->next = (Strlist *) malloc(sizeof(Strlist));
            ps = ps->next;
          }
          ps->next = NULL;
        }
        ps = nn->p;
        sprintf(ps->str, "%.02f", nn->instrum);
        ps = ps->next;
        sprintf(ps->str, "%g", ratval(&nn->start));
        ps = ps->next;
        sprintf(ps->str, "%g", ratval(&nn->dur));
        ps = ps->next;
        sprintf(ps->str, "%d", nn->slur);
        ps = ps->next;
        sprintf(ps->str, "%.02f",
                pitchval(nn->octave, nn->pitchclass, nn->accid, *transpose));
        if (c == '[') {
          char   *pars;
          int     pnum;

          pars = readparams(inst);

#ifdef DEBUG
          printf("Params: %s\n", pars);
#endif

          z = 0;
          pnum = 6;
          while (strchr(" \t\r\n", (int) pars[z]))
            z++;
          for (;;) {
            if (pars[z] == (char) ']')
              break;
            c = 0;
            while (!strchr(" \t\r\n:]", (int) pars[z]))
              s[c++] = pars[z++];
            s[c] = (char) 0;

#ifdef DEBUG
            printf("Read: %s\n", s);
#endif

            while (strchr(" \t\r\n", (int) pars[z]))
              z++;
            if (pars[z] == (char) ':') {
              pnum = atoi(s);
              if (pnum < 6)
                scoterror(Str("Parameter number out of range"));
              z++;
              while (strchr(" \t\r\n", (int) pars[z]))
                z++;
              continue;
            }

#ifdef DEBUG
            printf("Param #%d: %s\n", pnum, s);
#endif

            if (s[0] == (char) '\'') {
              addparam(pnum, &s[1], &nn->p);
              addparam(pnum, ".", &nn->carryp);
            }
            else {
              addparam(pnum, s, &nn->p);
              addparam(pnum, s, &nn->carryp);
            }
            pnum++;
          }
          free(pars);
        }
        else
          scotungetc();
        if ((nn != pn) && (!pn->written)) {

#ifdef DEBUG
          printf("  doing nextp stuff:\n");
#endif

          for (nextpp = (*nextlist); nextpp; nextpp = nextpp->next) {

#ifdef DEBUG
            printf("   carrying p%d to p%d?\n", nextpp->src, nextpp->dst);
#endif

            if (!strcmp(findparam(nextpp->dst, &pn->carryp), NEXTP)) {
              sp = findparam(nextpp->dst, &pn->p);
              if (!strcmp(sp, ".")) {
                char   *sp2;

                sp2 = findparam(nextpp->src, &nn->p);
                if (!strcmp(sp2, "."))
                  sp2 = findparam(nextpp->src, &nn->carryp);
                strcpy(sp, sp2);

#ifdef DEBUG
                printf("   Yes.\n");
#endif

              }
            }
          }
          writenote(pn);
        }
        if ((!(*nextlist)) && (!nn->tie))
          writenote(nn);
        if (nn != pn) {
          if (!pn->written)
            scoterror(Str("Lost previous note: not written"));

#ifdef DEBUG
          if (pn->next == nn)
            printf("* pn->next==nn\n");
#endif

          nn->next = pn->next;

#ifdef DEBUG
          if (pn2 == nn)
            printf("* pn2==nn\n");
#endif

          if (pn == *notetop)
            *notetop = nn;
          else
            pn2->next = nn;
          freenote(pn);
          pn = nn;

#ifdef DEBUG
          if (nn->next == nn)
            printf("* Circular list created\n");
#endif

        }

#ifdef DEBUG
        printf(" nn linked into note list\n");
        printf(" curtime=%lu/%lu\n", curtime->num, curtime->denom);
        printf(" nn->dur=%lu/%lu\n", nn->dur.num, nn->dur.denom);
#endif

        *ln = nn;
        ratass(lastnote, curtime);
        ratmul(&rattmp, &nn->lastdur, grpmul);
        ratadd(curtime, curtime, &rattmp);

#ifdef DEBUG
        printf(" curtime=%lu/%lu\n", curtime->num, curtime->denom);
        printf(" Done with note\n");
#endif

      }
    }
    scotungetc();
}