Ejemplo n.º 1
0
void create_object(void)
{
    set_short("A boathouse down by the river");
    set_long("You are in a boathouse in the village. The walls in this " +
             "house are covered with nets, lines, holders for oars and " +
             "shelves with boating equipment. There are only three walls " +
             "here, and where the east wall is supposed to be is a big " +
             "opening through which a slide leads straight down into the " +
             "river. The river flows swiftly past this point, and on the " +
             "other side you see the forest.\n");
    set_new_light(10);
    add_property("indoors");

    add_item("boathouse","You are in it. It's a house down by the river " +
             "where boats and boating equipment is kept");
    add_item("wall|walls","They are covered with various fishing equipment");
    add_item("nets","Nets hung up to dry");
    add_item("lines","Ropes and fishing lines");
    add_item("holders","Holders for oars");
    add_func_item("oars","#query_oar_taken",({
                  "Hmm, most of the oars seem to be in pretty bad shape. " +
                  "However, you do spot one oar that may be usable",
                  "The oars are in pretty bad shape, none of them are " +
                  "usable" }));
Ejemplo n.º 2
0
void create_object(void)
{
    set_short("Lallan the apothecary",1);
    set_long("Lallan is a man in his fifties with graying hair and blue " +
             "eyes.\n");
    set_name("apothecary");
    add_id("lallan");
    add_id("man");
    set_level(4);
    set_race("human");
    set_hp(100);
    set_al(200);
    set_gender(1);
    set_wc(6);
    set_ac(1);
    set_unarmed(1);
    add_property("no_flee");
    add_money(200 + random(200));

    load_chat(10,({ "Lallan says: Take my advice, leave while you still " +
                    "can.\n",
                    "Lallan says: If you're staying here, you'll be needing " +
                    "my wares.\n"
                  }));
Ejemplo n.º 3
0
void create_object(void)
{
    set_short("A small, round cave");
    set_long("A small, round cave with a low ceiling. It is difficult to " +
             "stand up straight in here without bumping your head. The " +
             "gray stone walls are rough, and a bit to close to each " +
             "other for you to feel completely at ease. To the northeast " +
             "is another, larger cave. A disgusting smell is coming from " +
             "that direction. South is an opening that will take you out " +
             "into the open air again. The smell and cramped nature of " +
             "this cave makes that opening look very inviting\n");
    set_new_light(0);
    add_property("indoors");
    
    add_item("cave","A small, round cave with rough stone walls, floor and " +
             "ceiling. You feel cramped in here, and you'd rather leave");
    add_item("floor|ceiling","Rough, gray stone");
    add_item("wall|walls","The rough stone walls seem to close in on " +
             "you, giving you a most unpleasant feeling");
    add_item("opening","It will take you back out into the quarry");    
    
    add_exit(ROOM + "stone_quarry","out");
    add_exit(ROOM + "dgcave_dump","northeast");
}
Ejemplo n.º 4
0
void create_object(void)
{
    set_short("The second floor of the sanatarium");
    set_long("You are on the second floor of the sanatarium. This is a " +
             "dark, smelly room with a small barred window on the west " +
             "wall. There is no furniture in this room, only a bed of " +
             "straw in one corner of the room. You shiver when you think " +
             "about what it would be like to get locked inside a room " +
             "like this.\n");
    set_skip_obvious(1);
    set_new_light(10);
    add_property("indoors");

    add_item("window","A small barred window overlooking the road");
    add_item("bars|bar","Strong iron bars");
    add_item("road","You look out the window, but decide that you'd get a " +
             "better look of the road if you'd go down there");
    add_item("bed","Well, it's just a heap of straw, really");
    add_item("heap|straw","A heap of straw. It's a sorry excuse for a bed");
    add_item("%|%urin|%decay|%room","BLAEH! The room reeks of urin and decay");

    (ROOM + "sanatarium4")->load_doors();
    reset(0);
}
Ejemplo n.º 5
0
void
fz_match_css_at_page(fz_context *ctx, fz_css_match *match, fz_css_rule *css)
{
	fz_css_rule *rule;
	fz_css_selector *sel;
	fz_css_property *prop;

	for (rule = css; rule; rule = rule->next)
	{
		sel = rule->selector;
		while (sel)
		{
			if (sel->name && !strcmp(sel->name, "@page"))
			{
				for (prop = rule->declaration; prop; prop = prop->next)
					add_property(match, prop->name, prop->value, selector_specificity(sel, prop->important));
				break;
			}
			sel = sel->next;
		}
	}

	sort_properties(match); /* speed up subsequent value_from_raw_property lookups */
}
Ejemplo n.º 6
0
int
safeputprop(dbref obj, dbref perms, char *buf, char *val)
{
    char *ptr;
    if (!buf) return 0;
    while (*buf == PROPDIR_DELIMITER) buf++;
    if (!*buf) return 0;

    /* disallow CR's and :'s in prop names. */
    for (ptr = buf; *ptr; ptr++)
        if (*ptr == '\r' || *ptr == PROP_DELIMITER) return 0;

    if (!Wizperms(perms)) {
        if (Prop_Hidden(buf)) return 0;
        if (Prop_SeeOnly(buf)) return 0;
	if (string_prefix(buf, "_msgmacs/")) return 0;
    }
    if (!val) {
        remove_property(obj, buf);
    } else {
	add_property(obj, buf, val, 0);
    }
    return 1;
}
Ejemplo n.º 7
0
  void
create_sizebbox(worldptr world)
{
  vfeptr thisvfe;
  evfptr thisevf;
  fveptr thisfve;
  ;
  /* scalebbox_obj is a global object that gets copied when primary */
  /* world objects get picked, so that they can be scaled.  */
  
  scalebbox_obj = create_cube(environment_world,100.0,100.0,100.0);

  scalebbox_obj->drawtechnique = normal_draw_technique;
  scalebbox_obj->selectechnique = set_scalebbox_selectable;
  set_object_name(scalebbox_obj,"Sizebbox");
  add_property((featureptr) scalebbox_obj, transparent_prop);

  add_property((featureptr) scalebbox_obj, noshadow_prop);

  add_property((featureptr) scalebbox_obj, scalebbox_prop);
  del_property((featureptr) scalebbox_obj, visible_prop);
  thisvfe = First_obj_vfe(scalebbox_obj);
  while (thisvfe != Nil)
  {
    add_property((featureptr) thisvfe, scalebbox_prop);
    thisvfe = thisvfe->next;
  }
  thisevf = First_obj_evf(scalebbox_obj);
  while (thisevf != Nil)
  {
    add_property((featureptr) thisevf, scalebbox_prop);
    thisevf = thisevf->next;
  }
  thisfve = First_obj_fve(scalebbox_obj);
  while (thisfve != Nil)
  {
    add_property((featureptr) thisfve, scalebbox_prop);
    thisfve = thisfve->next;
  }
}
Ejemplo n.º 8
0
static void
add_shorthand_border(fz_css_match *match, fz_css_value *value, int spec, int T, int R, int B, int L)
{
	while (value)
	{
		if (value->type == CSS_HASH)
		{
			if (T) add_property(match, "border-top-color", value, spec);
			if (R) add_property(match, "border-right-color", value, spec);
			if (B) add_property(match, "border-bottom-color", value, spec);
			if (L) add_property(match, "border-left-color", value, spec);
		}
		else if (value->type == CSS_KEYWORD)
		{
			if (keyword_in_list(value->data, border_width_kw, nelem(border_width_kw)))
			{
				if (T) add_property(match, "border-top-width", value, spec);
				if (R) add_property(match, "border-right-width", value, spec);
				if (B) add_property(match, "border-bottom-width", value, spec);
				if (L) add_property(match, "border-left-width", value, spec);
			}
			else if (keyword_in_list(value->data, border_style_kw, nelem(border_style_kw)))
			{
				if (T) add_property(match, "border-top-style", value, spec);
				if (R) add_property(match, "border-right-style", value, spec);
				if (B) add_property(match, "border-bottom-style", value, spec);
				if (L) add_property(match, "border-left-style", value, spec);
			}
			else if (keyword_in_list(value->data, color_kw, nelem(color_kw)))
			{
				if (T) add_property(match, "border-top-color", value, spec);
				if (R) add_property(match, "border-right-color", value, spec);
				if (B) add_property(match, "border-bottom-color", value, spec);
				if (L) add_property(match, "border-left-color", value, spec);
			}
		}
		else
		{
			if (T) add_property(match, "border-top-width", value, spec);
			if (R) add_property(match, "border-right-width", value, spec);
			if (B) add_property(match, "border-bottom-width", value, spec);
			if (L) add_property(match, "border-left-width", value, spec);
		}
		value = value->next;
	}
}
Ejemplo n.º 9
0
static void
add_shorthand_trbl(fz_css_match *match, fz_css_value *value, int spec,
	const char *name_t, const char *name_r, const char *name_b, const char *name_l)
{
	int n = count_values(value);

	if (n == 1)
	{
		add_property(match, name_t, value, spec);
		add_property(match, name_r, value, spec);
		add_property(match, name_b, value, spec);
		add_property(match, name_l, value, spec);
	}

	if (n == 2)
	{
		fz_css_value *a = value;
		fz_css_value *b = value->next;

		add_property(match, name_t, a, spec);
		add_property(match, name_r, b, spec);
		add_property(match, name_b, a, spec);
		add_property(match, name_l, b, spec);
	}

	if (n == 3)
	{
		fz_css_value *a = value;
		fz_css_value *b = value->next;
		fz_css_value *c = value->next->next;

		add_property(match, name_t, a, spec);
		add_property(match, name_r, b, spec);
		add_property(match, name_b, c, spec);
		add_property(match, name_l, b, spec);
	}

	if (n == 4)
	{
		fz_css_value *a = value;
		fz_css_value *b = value->next;
		fz_css_value *c = value->next->next;
		fz_css_value *d = value->next->next->next;

		add_property(match, name_t, a, spec);
		add_property(match, name_r, b, spec);
		add_property(match, name_b, c, spec);
		add_property(match, name_l, d, spec);
	}
}
Ejemplo n.º 10
0
void reset(int arg) {
  ::reset(arg);
  if(arg) return;
  add_property("no_clean_up");
} /* reset */
Ejemplo n.º 11
0
static void
add_shorthand_border(fz_css_match *match, fz_css_value *value, int spec)
{
	while (value)
	{
		if (value->type == CSS_COLOR)
		{
			add_property(match, "border-color", value, spec);
		}
		else if (value->type == CSS_KEYWORD)
		{
			if (keyword_in_list(value->data, border_width_kw, nelem(border_width_kw)))
			{
				add_property(match, "border-width-top", value, spec);
				add_property(match, "border-width-right", value, spec);
				add_property(match, "border-width-bottom", value, spec);
				add_property(match, "border-width-left", value, spec);
			}
			else if (keyword_in_list(value->data, border_style_kw, nelem(border_style_kw)))
			{
				add_property(match, "border-style", value, spec);
			}
			else if (keyword_in_list(value->data, color_kw, nelem(color_kw)))
			{
				add_property(match, "border-color", value, spec);
			}
		}
		else
		{
			add_property(match, "border-width-top", value, spec);
			add_property(match, "border-width-right", value, spec);
			add_property(match, "border-width-bottom", value, spec);
			add_property(match, "border-width-left", value, spec);
		}
		value = value->next;
	}
}
Ejemplo n.º 12
0
void
reflist_del(dbref obj, const char *propname, dbref todel)
{
    PropPtr ptr;
    const char *temp;
    const char *list;
    int count = 0;
    int charcount = 0;
    char buf[BUFFER_LEN];
    char outbuf[BUFFER_LEN];

    ptr = get_property(obj, propname);
    if (ptr) {
        const char *pat = NULL;

#ifdef DISKBASE
        propfetch(obj, ptr);
#endif
        switch (PropType(ptr)) {
            case PROP_STRTYP:
                *outbuf = '\0';
                list = temp = PropDataUNCStr(ptr);
                sprintf(buf, "%d", todel);
                while (*temp) {
                    if (*temp == '#') {
                        pat = buf;
                        count++;
                        charcount = temp - list;
                    } else if (pat) {
                        if (!*pat) {
                            if (!*temp || *temp == ' ') {
                                break;
                            }
                            pat = NULL;
                        } else if (*pat != *temp) {
                            pat = NULL;
                        } else {
                            pat++;
                        }
                    }
                    temp++;
                }
                if (pat && !*pat) {
                    if (charcount > 0) {
                        strncpy(outbuf, list, charcount - 1);
                        outbuf[charcount - 1] = '\0';
                    }
                    strcat(outbuf, temp);
                    for (temp = outbuf; isspace(*temp); temp++) ;
                    add_property(obj, propname, temp, 0);
                }
                break;
            case PROP_REFTYP:
                if (PropDataRef(ptr) == todel) {
                    add_property(obj, propname, "", 0);
                }
                break;
            default:
                break;
        }
    }
}
Ejemplo n.º 13
0
void create() {
    ::create();
    add_property("no_telein");
}
Ejemplo n.º 14
0
int zmq::null_mechanism_t::next_handshake_command (msg_t *msg_)
{
    if (ready_command_sent || error_command_sent) {
        errno = EAGAIN;
        return -1;
    }
    if (zap_connected && !zap_reply_received) {
        if (zap_request_sent) {
            errno = EAGAIN;
            return -1;
        }
        send_zap_request ();
        zap_request_sent = true;
        const int rc = receive_and_process_zap_reply ();
        if (rc != 0)
            return -1;
        zap_reply_received = true;
    }

    if (zap_reply_received
            &&  strncmp (status_code, "200", sizeof status_code) != 0) {
        const int rc = msg_->init_size (6 + 1 + sizeof status_code);
        zmq_assert (rc == 0);
        unsigned char *msg_data =
            static_cast <unsigned char *> (msg_->data ());
        memcpy (msg_data, "\5ERROR", 6);
        msg_data [6] = sizeof status_code;
        memcpy (msg_data + 7, status_code, sizeof status_code);
        error_command_sent = true;
        return 0;
    }

    unsigned char *const command_buffer = (unsigned char *) malloc (512);
    alloc_assert (command_buffer);

    unsigned char *ptr = command_buffer;

    //  Add mechanism string
    memcpy (ptr, "\5READY", 6);
    ptr += 6;

    //  Add socket type property
    const char *socket_type = socket_type_string (options.type);
    ptr += add_property (ptr, "Socket-Type", socket_type, strlen (socket_type));

    //  Add identity property
    if (options.type == ZMQ_REQ
            ||  options.type == ZMQ_DEALER
            ||  options.type == ZMQ_ROUTER)
        ptr += add_property (ptr, "Identity", options.identity, options.identity_size);

    const size_t command_size = ptr - command_buffer;
    const int rc = msg_->init_size (command_size);
    errno_assert (rc == 0);
    memcpy (msg_->data (), command_buffer, command_size);
    free (command_buffer);

    ready_command_sent = true;

    return 0;
}
void setup() {

    set_name( "worker" );
    // The big burly sort that does cat calls
    set_short( "construction worker" );
    add_property( "determinate", "a " );
    add_adjective( "construction" );
    add_property( "unique", 1 );
    setup_nationality( "/std/nationality/agatean", "Bes Pelargic" );    
    basic_setup( "human", "warrior", 30 );
    set_gender( 1 );
    
    set_long("This is a construction worker.  You can use him to "
        "decorate surfaces in player housing to the exact specifications "
        "that you will set later in this file.  He is slightly grubby, "
        "is covered in dust and paint, and likes to do wolf whistles.\n");
    
    // Adding the place property ensures that the decorator will
    // charge the correct currency when the player needs to pay.
    // If you don't add a place property, the default currency 
    // will be provincial.
    
    add_property( "place", "Counterweight Continent" );
       
   
   
    // Add_allowed_surface() adds surfaces to the NPC that they are allowed to
    // decorate.  You can decorate floors, ceilings and walls.
    
    // Note that just adding "wall" will include all of the walls in the 
    // room (north, south, east and west).  
    
    add_allowed_surface( "floor" ); 
    add_allowed_surface( "wall" );  
        
    
    
    // The following bit is what adds items to the NPC's stock list.  
    
    // The first argument in add_fitted_surface() is the short description 
    // of the decoration that you want to add.  This could be 
    // "wood panelling", "rough wooden beams", "neon yellow carpet",
    // or any other type of decoration that would make sense with the 
    // surfaces you've described above in add_allowed_surface().
    
    // The second argument is the long description that will be installed in
    // the room itself.  For example, the room would look like: The floor is         
    // covered with plush yellow carpet and the other surfaces are blah blah 
    // blah.
    
    // The third argument is the cost of the decoration and its installation.  
    // The type of currency the player is charged in is determined by the 
    // "add_property( "place", <location> );" that you defined above.  In 
    // this example, the player will be charged in Rhinu since the 
    // place is the Counterweight Continent.
        
    add_fitted_surface( "plush green carpet", "covered with plush "
        "green carpet", 1000 );
    add_fitted_surface( "plush red carpet", "covered with plush "
        "red carpet", 1000 );
    add_fitted_surface( "plush yellow carpet", "covered with plush "
        "yellow carpet", 1000 );
    add_fitted_surface( "plush blue carpet", "covered with plush "
        "blue carpet", 1000 );
    
    
        
    // The following function defines what the surface will look like while 
    // it is being decorated.  Note that if the worker is killed in the middle
    // of his job, the surface will retain this message until the player hires
    // him again and he completes the work.  The default message is:
    // "covered in dust and dirt".
    
    set_under_construction_mess( "covered in dust, plaster and carpet bits" );


    
    // This adds a domain which the NPC will freely wander around.  
    
    // In this example, if the file name of the room is anywhere 
    // in /w/una or anywhere in /d/cwc/Bes_Pelargic, the NPC will happily 
    // follow a player around.  
    
    // However, if they follow a player out of this file structure into 
    // another area,  (say they are in Bes Pelargic and walk onto 
    // the T-shop, which is in /d/underworld), the NPC will be moved
    // to the rubbish room and will then attempt to move themselves 
    // to the "good room" they were in.  If they can't move themselves 
    // into the last "good room" within a few seconds, they will be 
    // dested in the rubbish room.
    
    add_allowed_domain( "/w/una" );
    add_allowed_domain( "/d/cwc/Bes_Pelargic" );
    
    
    
    // You need to set some customised responses for the NPC so they don't 
    // sound like they have a stick up their arse, too. :)  In this example,
    // we will continue with the carpet theme used above and add a spicy 
    // Morporkian spicy pirate flavour to his new custom responses!
    
    set_responses( ({
        
        // This is what he will say if the player requests a type of 
        // surface you haven't added in add_allowed_surface().
        "'I don't fit those kinds of surfaces matey!",
        
        // This is what he will say if the player requests a type of 
        // carpet short that you have not listed in add_fitted_surface().
        "'I've never heard of those sort of carpets, arrrrr.",
        
        // This is what he will say if the player is not the owner of 
        // (or allowed by the owner) the house they are asking the worker
        // to decorate.
        "'Arr, you don't own this place, mister!",
        
        // This is what he will say if the room he is in when the player
        // asks him to decorate is not a player-housing room with decoratable
        // surfaces.
        "'I can't be decoratin' these here surfaces, shogun!  You should "
        "take me to a house!",
        
        // This is what he will say if something goes bizarrely wrong and 
        // the code needs to bail before he decorates the room.
        "'Arr matey, something went horribly wrong!",
        
        // This is what he will say when he is done the job.
        "'Arrrr matey, all done!",
        
        // This is what he will say if the player doesn't have enough money 
        // to pay for the decoration they have requested.  Leave in $decor$
        // and $amount$ - they are already replaced in the inherit by 
        // what the player has chosen and its price.
        "'You don't have enough money to pay for the $decor$!  It "
        "will cost you $amount$, guv!",
        
        // This is what he will say when you ask him to list his goods.
        "'I can fit $allowed$ with any of the following:",
        
        // This is what he will say if he hasn't got any stock.
        "'Cor blimey mister, I haven't got any stock.",
        
        // This is what he will say when he starts the job.
        "'Okey doke, I'll have it done in a jiffy guv'nor!",
        
        // This is what he will say if he can't see the person that's speaking
        // to him.
        "'What?  Who sed dat?",
        
        // This is what he will say if he's already following someone and 
        // another person tries to hire him.  $employer$ is replaced by the 
        //person who has hired him.
        "'I've already got this great job with $employer$, mate!",
        
        // This is what he will say when you hire his services.
        "'Righty-o, you just take me to the room you want spiffied "
        "up and ask me to fit something!",
        
        // This is what he will say if you try to take him out of an area he 
        // is not allowed to go out of.  You set this area with         
        // add_allowed_domain(), as shown above.
        "'Sorry matey, bad karma over that way."
        
    }) );  
Ejemplo n.º 16
0
/******************************************************************************
Given a file pointer, get ready to read PLY data from the file.

Entry:
  fp - the given file pointer

Exit:
  nelems     - number of elements in object
  elem_names - list of element names
  returns a pointer to a PlyFile, used to refer to this file, or NULL if error
******************************************************************************/
PlyFile *ply_read(FILE *fp, int *nelems, char ***elem_names)
{
    int i,j;
    PlyFile *plyfile;
    int nwords;
    char **words;
    //int found_format = 0;
    char **elist;
    PlyElement *elem;
    char *orig_line;

    // check for NULL file pointer
    assert(fp != NULL);

    // create record for this object

    plyfile = (PlyFile *) myalloc (sizeof (PlyFile));
    plyfile->nelems = 0;
    plyfile->comments = NULL;
    plyfile->num_comments = 0;
    plyfile->obj_info = NULL;
    plyfile->num_obj_info = 0;
    plyfile->fp = fp;
    //plyfile->other_elems = NULL;

    // read and parse the file's header
    words = get_words(plyfile->fp, &nwords, &orig_line);
    assert(words && (strncmp(words[0], "ply", sizeof("ply ")) == 0));

    while (words) {
        // parse words

        if (strncmp(words[0], "format", sizeof("format")) == 0) {
            if (nwords != 3) {
                return (NULL);
            }
            if (strncmp(words[1], "ascii", sizeof("ascii")) == 0) {
                plyfile->file_type = PLY_ASCII;
            } else {
                return (NULL);
            }
            plyfile->version = atof (words[2]);
            //found_format = 1;
        } else if (strncmp(words[0], "element", sizeof("element")) == 0) {
            add_element (plyfile, words, nwords);
        } else if (strncmp(words[0], "property", sizeof("property")) == 0) {
            add_property (plyfile, words, nwords);
        } else if (strncmp(words[0], "comment", sizeof("comment")) == 0) {
            add_comment (plyfile, orig_line);
        } else if (strncmp(words[0], "obj_info", sizeof("obj_info")) == 0) {
            add_obj_info (plyfile, orig_line);
        } else if (strncmp(words[0], "end_header", sizeof("end_header")) == 0) {
            break;
        }

        // free up words space
        free (words);

        words = get_words (plyfile->fp, &nwords, &orig_line);
    }

    // create tags for each property of each element, to be used
    // later to say whether or not to store each property for the user

    for (i = 0; i < plyfile->nelems; i++) {
        elem = plyfile->elems[i];
        elem->store_prop = (char *) myalloc (sizeof (char) * elem->nprops);
        for (j = 0; j < elem->nprops; j++) {
            elem->store_prop[j] = DONT_STORE_PROP;
        }
        elem->other_offset = NO_OTHER_PROPS; // no "other" props by default
    }

    // set return values about the elements

    elist = (char **) myalloc (sizeof (char *) * plyfile->nelems);
    for (i = 0; i < plyfile->nelems; i++) {
        elist[i] = strdup (plyfile->elems[i]->name);
    }

    *elem_names = elist;
    *nelems = plyfile->nelems;

    // return a pointer to the file's information

    return (plyfile);
}
Ejemplo n.º 17
0
void 
fill_window_data()
{
	ASWindowData *wd;
	INT32 encoding;
	char *name, *names[5];
	static char buf[4096], buf2[4096];
	ASRawHints    raw ;
	ASDatabaseRecord db_rec ;

	wd = fetch_window_by_id( MyArgs.src_window );
	LOCAL_DEBUG_OUT( "src_window = %lX, wd = %p", MyArgs.src_window, wd );
	encoding = AS_Text_ASCII ;
	name = get_window_name(wd, ASN_Name, &encoding );
	   
	add_property( "Window name:", name, encoding, True );
	name = get_window_name(wd, ASN_NameMatched, &encoding );
	add_property( "Window name matched:", name, encoding, True );
	name = get_window_name(wd, ASN_IconName, &encoding );
	add_property( "Icon name:", name, encoding, True );		
	name = get_window_name(wd, ASN_ResClass, &encoding );
	add_property( "Resource class:", name, encoding, False );
	name = get_window_name(wd, ASN_ResName, &encoding );
	add_property( "Resource name:", name, encoding, False );

	sprintf( buf, "0x%lX ( %ld )", wd->client, wd->client );
	add_property("Client Window ID:", buf, AS_Text_ASCII, False);
	sprintf( buf, "0x%lX ( %ld )", wd->frame, wd->frame );
	add_property("Frame Window ID:", buf, AS_Text_ASCII, False);
	sprintf( buf, "%ldx%ld%+ld%+ld", wd->frame_rect.width, wd->frame_rect.height, wd->frame_rect.x, wd->frame_rect.y );
	add_property("Frame Geometry:", buf, AS_Text_ASCII, False);

#define SHOW_FLAG(flags,flg)   \
	do{ if( get_flags( flags, AS_##flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)
#define SHOW_WM_FLAG(flags,flg)   \
	do{ if( get_flags( flags, flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)
#define SHOW_MWM_FLAG(flags,type,flg)   \
	do{ if( get_flags( flags, MWM_##type##_##flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)
#define SHOW_EXTWM_FLAG(flags,type,flg)   \
	do{ if( get_flags( flags, EXTWM_##type##flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)
#define SHOW_GNOME_FLAG(flags,type,flg)   \
	do{ if( get_flags( flags, WIN_##type##_##flg)){ if( buf[0] != '\0' ) strcat( buf, ", "); strcat( buf, #flg );}}while(0)

	buf[0] = '\0' ;
	if( (wd->state_flags & (AS_MaximizedX|AS_MaximizedY)) == (AS_MaximizedX|AS_MaximizedY) )
	{
		strcpy( buf, "Maximized"); 
	}else
	{
		SHOW_FLAG(wd->state_flags,MaximizedX);
		SHOW_FLAG(wd->state_flags,MaximizedY);    
	}
	SHOW_FLAG(wd->state_flags,Iconic);
	SHOW_FLAG(wd->state_flags,Fullscreen);    
	SHOW_FLAG(wd->state_flags,Sticky);    
	SHOW_FLAG(wd->state_flags,Shaded);        
	SHOW_FLAG(wd->state_flags,Withdrawn);
	SHOW_FLAG(wd->state_flags,Dead);     
	SHOW_FLAG(wd->state_flags,Mapped);
	SHOW_FLAG(wd->state_flags,IconMapped);
	SHOW_FLAG(wd->state_flags,Hidden);
	SHOW_FLAG(wd->state_flags,Shaped);
	SHOW_FLAG(wd->state_flags,ShapedDecor);
	SHOW_FLAG(wd->state_flags,ShapedIcon);
	SHOW_FLAG(wd->state_flags,Urgent);
		   
	add_property("Current state flags:", buf, AS_Text_ASCII, True);
	
	buf[0] = '\0' ;
	SHOW_FLAG(wd->flags,Iconic);
	SHOW_FLAG(wd->flags,Transient);
	SHOW_FLAG(wd->flags,AcceptsFocus);
	SHOW_FLAG(wd->flags,ClickToFocus);
	SHOW_FLAG(wd->flags,Titlebar);
	SHOW_FLAG(wd->flags,VerticalTitle);
	SHOW_FLAG(wd->flags,Border);
	SHOW_FLAG(wd->flags,Handles);
	SHOW_FLAG(wd->flags,Frame);		
	SHOW_FLAG(wd->flags,SkipWinList); 
	SHOW_FLAG(wd->flags,DontCirculate); 
	SHOW_FLAG(wd->flags,AvoidCover);          
	SHOW_FLAG(wd->flags,IconTitle);
	SHOW_FLAG(wd->flags,Icon);          
	SHOW_FLAG(wd->client_icon_flags,ClientIcon);
	SHOW_FLAG(wd->client_icon_flags,ClientIconPixmap);    
	SHOW_FLAG(wd->client_icon_flags,ClientIconPosition);
	SHOW_FLAG(wd->flags,FocusOnMap);          
	SHOW_FLAG(wd->flags,ShortLived);
	SHOW_FLAG(wd->flags,Module);
	SHOW_FLAG(wd->flags,IgnoreConfigRequest);
	SHOW_FLAG(wd->flags,IgnoreRestackRequest);
	SHOW_FLAG(wd->flags,WMDockApp);
	
	add_property("Current hints flags:", buf, AS_Text_ASCII, True);
	
	buf[0] = '\0' ;
	SHOW_FLAG(wd->flags,Windowbox);           
	SHOW_FLAG(wd->flags,Aspect);
	SHOW_FLAG(wd->flags,PID);
	SHOW_FLAG(wd->flags,MinSize);
	SHOW_FLAG(wd->flags,MaxSize);
	SHOW_FLAG(wd->flags,SizeInc);
	SHOW_FLAG(wd->flags,BaseSize);
	SHOW_FLAG(wd->flags,Gravity);
	
	add_property("Specified hint values:", buf, AS_Text_ASCII, True);

    if( collect_hints( ASDefaultScr, wd->client, HINT_ANY, &raw ) )
	{
		ExtendedWMHints *eh = &(raw.extwm_hints);
		GnomeHints *gh = &(raw.gnome_hints);
		
		if (raw.wm_hints)
		{
			if( raw.wm_hints->flags != 0 ) 
			{
				buf[0] = '\0' ;
				SHOW_WM_FLAG(raw.wm_hints->flags,UrgencyHint );
				SHOW_WM_FLAG(raw.wm_hints->flags,InputHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,StateHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,IconPixmapHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,IconWindowHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,IconPositionHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,IconMaskHint);
				SHOW_WM_FLAG(raw.wm_hints->flags,WindowGroupHint);
				add_property("WM Hints flags:", buf, AS_Text_ASCII, True);
				if( get_flags (raw.wm_hints->flags, WindowGroupHint) )
				{
					sprintf( buf, "0x%lX ( %ld )", raw.wm_hints->window_group, raw.wm_hints->window_group );
					add_property("WM Group leader:", buf, AS_Text_ASCII, True);
				}
			}
		}
		if (raw.wm_normal_hints)
		{
			if( raw.wm_normal_hints->flags != 0 ) 
			{
				buf[0] = '\0' ;
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,USPosition );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,USSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PPosition );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PMinSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PMaxSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PResizeInc );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PAspect );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PBaseSize );
				SHOW_WM_FLAG(raw.wm_normal_hints->flags,PWinGravity );
				add_property("WM Size Hints flags:", buf, AS_Text_ASCII, True);
			}
			if( get_flags(raw.wm_normal_hints->flags, PWinGravity ) && 
				raw.wm_normal_hints->win_gravity >= 0 && raw.wm_normal_hints->win_gravity <= StaticGravity ) 
			{
				static char *gravity_types[] = 
					{"Forget","NorthWest","North","NorthEast","West",
					 "Center","East","SouthWest","South","SouthEast",
					 "Static" };

					add_property("Gravity:", gravity_types[raw.wm_normal_hints->win_gravity], AS_Text_ASCII, True);
			}
		}
		if( raw.transient_for)
		{
			sprintf( buf, "0x%lX", raw.transient_for->flags );
			add_property("flags:", buf, AS_Text_ASCII, False);
			sprintf( buf, "0x%lX ( %ld )", raw.transient_for->parent, raw.transient_for->parent );
			add_property("Transient For:", buf, AS_Text_ASCII, False);
			sprintf( buf, "%+d%+d", raw.transient_for->viewport_x, raw.transient_for->viewport_y);
			add_property("Transient viewport:", buf, AS_Text_ASCII, False);
			sprintf( buf, "%d", raw.transient_for->desktop );
			add_property("Transient desktop:", buf, AS_Text_ASCII, False);
		}
		if (raw.motif_hints)
		{
			buf[0] = '\0' ;
			if (get_flags (raw.motif_hints->flags, MWM_HINTS_INPUT_MODE))
			{
				INT32 input_mode = raw.motif_hints->inputMode;
					  
				if (input_mode == MWM_INPUT_SYSTEM_MODAL)
					add_property("Motif Input mode:", "System modal", AS_Text_ASCII, False);
				else if (input_mode == MWM_INPUT_FULL_APPLICATION_MODAL)
					add_property("Motif Input mode:", "Full application modal", AS_Text_ASCII, False);
			}

 			check_motif_hints_sanity( raw.motif_hints );

			if (get_flags (raw.motif_hints->flags, MWM_HINTS_FUNCTIONS))
			{	
				ASFlagType funcs = raw.motif_hints->functions;
				buf[0] = '\0' ;
				SHOW_MWM_FLAG(funcs,FUNC,RESIZE);
				SHOW_MWM_FLAG(funcs,FUNC,MOVE);
				SHOW_MWM_FLAG(funcs,FUNC,MINIMIZE);
				SHOW_MWM_FLAG(funcs,FUNC,MAXIMIZE);
				SHOW_MWM_FLAG(funcs,FUNC,CLOSE);
				add_property("Motif Functionality hints:", buf, AS_Text_ASCII, False);
			}
			if (get_flags (raw.motif_hints->flags, MWM_HINTS_DECORATIONS))
			{	
				ASFlagType decor = raw.motif_hints->decorations;
				buf[0] = '\0' ;
				SHOW_MWM_FLAG(decor,DECOR,BORDER);
				SHOW_MWM_FLAG(decor,DECOR,RESIZEH);
				SHOW_MWM_FLAG(decor,DECOR,TITLE);
				SHOW_MWM_FLAG(decor,DECOR,MENU);
				SHOW_MWM_FLAG(decor,DECOR,MINIMIZE);
				SHOW_MWM_FLAG(decor,DECOR,MAXIMIZE);
				add_property("Motif decor hints:", buf, AS_Text_ASCII, False);
			}
		}	 
		/* window state hints : */
		if (get_flags (eh->state_flags, EXTWM_StateEverything))
		{
			buf[0] = '\0' ;
			SHOW_EXTWM_FLAG(eh->state_flags,State,Modal );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Sticky );
			SHOW_EXTWM_FLAG(eh->state_flags,State,MaximizedV );
			SHOW_EXTWM_FLAG(eh->state_flags,State,MaximizedH );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Shaded );
			SHOW_EXTWM_FLAG(eh->state_flags,State,SkipTaskbar );
			SHOW_EXTWM_FLAG(eh->state_flags,State,SkipPager );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Fullscreen );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Above );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Below );
			SHOW_EXTWM_FLAG(eh->state_flags,State,Hidden );
			SHOW_EXTWM_FLAG(eh->state_flags,State,DemandsAttention );
			
			add_property("Extended WM status flags:", buf, AS_Text_ASCII, True);
		}
		/* window type hints : */
		if (get_flags (eh->type_flags, EXTWM_TypeEverything))
		{
			buf[0] = '\0' ;
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Desktop);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Dock);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Toolbar);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Menu);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Dialog);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Normal);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Utility);
			SHOW_EXTWM_FLAG(eh->type_flags,Type,Splash);
			add_property("Extended WM type flags:", buf, AS_Text_ASCII, True);
		}
		
		if (get_flags (eh->flags, EXTWM_PID))
		{
			sprintf( buf, "%d", (int)eh->pid );
			add_property("Extended WM PID:", buf, AS_Text_ASCII, False);
		}

		if (get_flags (eh->flags, EXTWM_DoesWMPing))
			add_property("Extended WM protocols:", "DoesWMPing", AS_Text_ASCII, False);
		
		if (get_flags (eh->flags, EXTWM_WINDOW_OPACITY))
		{
			sprintf( buf, "%d", (int)eh->window_opacity );
			add_property("ExtWM Window Opacity :",  buf, AS_Text_ASCII, False);
		}
		
		if (get_flags (eh->flags, EXTWM_DESKTOP))
		{
			if (eh->desktop == 0xFFFFFFFF)
				strcpy(buf, "sticky");
			else
				sprintf( buf, "%d", (int)eh->desktop );
			add_property("Extended WM desktop:", buf, AS_Text_ASCII, False);
		}

		if (get_flags (gh->flags, GNOME_LAYER))
		{
			sprintf( buf, "%d", (int)gh->layer );
			add_property("Gnome hints layer:", buf, AS_Text_ASCII, False);
		}
		if (get_flags (gh->flags, GNOME_WORKSPACE))
		{
			sprintf( buf, "%d", (int)gh->workspace );
			add_property("Gnome hints desktop:", buf, AS_Text_ASCII, False);
		}
		if (get_flags (gh->flags, GNOME_STATE) && gh->state != 0)
		{
			buf[0] = '\0' ;
			SHOW_GNOME_FLAG(gh->state,STATE,STICKY);
			SHOW_GNOME_FLAG(gh->state,STATE,MINIMIZED);
			SHOW_GNOME_FLAG(gh->state,STATE,MAXIMIZED_VERT);
			SHOW_GNOME_FLAG(gh->state,STATE,MAXIMIZED_HORIZ);
			SHOW_GNOME_FLAG(gh->state,STATE,SHADED);
			add_property("Gnome state flags:", buf, AS_Text_ASCII, False);
		}

		if (get_flags (gh->flags, GNOME_HINTS) && gh->hints != 0)
		{	
			buf[0] = '\0' ;
			SHOW_GNOME_FLAG(gh->state,HINTS,SKIP_FOCUS);
			SHOW_GNOME_FLAG(gh->state,HINTS,SKIP_WINLIST);
			SHOW_GNOME_FLAG(gh->state,HINTS,SKIP_TASKBAR);
			SHOW_GNOME_FLAG(gh->state,HINTS,FOCUS_ON_CLICK);
			add_property("Gnome hints flags:", buf, AS_Text_ASCII, False);
		}
	}

	names[0] = get_window_name(wd, ASN_NameMatched, &encoding );
	names[1] = get_window_name(wd, ASN_IconName, &encoding );
	names[2] = get_window_name(wd, ASN_ResClass, &encoding );
	names[3] = get_window_name(wd, ASN_ResName, &encoding );
	names[4] = NULL ;

#define APPEND_DBSTYLE_TEXT(text) 	\
			do { if( !first ) strcat( buf, ", "); else first = False ; strcat( buf, text); } while(0)

	if ( fill_asdb_record (Database, names, &db_rec, False) != NULL )
	{
		int i ;
		add_property("Matched Styles:", "", AS_Text_ASCII, True);
		for( i = 0 ; Database->match_list[i] >= 0 ; ++i )
		{
			ASDatabaseRecord *dr = 	get_asdb_record (Database, Database->match_list[i]);
			int f ;
			Bool first = True ;
			if( is_default_asdb_record(Database, dr) ) 
				sprintf(buf, "\"*\" \t");
			else if( dr->regexp ) 
				sprintf( buf, "\"%s\" \t", dr->regexp->raw );
			else
				sprintf( buf, "\"(none)\" \t" );

			for( f = 0 ; DatabaseFlagsList[f].name_set != NULL ; ++f ) 
			{	
				if( get_flags( dr->set_flags, DatabaseFlagsList[f].flag ) ) 
				{	
					name = get_flags( dr->flags, DatabaseFlagsList[f].flag )?
									DatabaseFlagsList[f].name_set : DatabaseFlagsList[f].name_unset ;
					APPEND_DBSTYLE_TEXT(name);
				}
			}	

			if( get_flags( dr->set_data_flags, STYLE_ICON ) )
			{	
				sprintf( buf2, "Icon \"%s\"", dr->icon_file );
				APPEND_DBSTYLE_TEXT(buf2);
			}
#if 1			
			if( get_flags( dr->set_data_flags, STYLE_STARTUP_DESK ) )
			{	
				sprintf( buf2, "StartsOnDesk %d", dr->desk );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_BORDER_WIDTH ) )
			{	
				sprintf( buf2, "BorderWidth %d", dr->border_width );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_HANDLE_WIDTH ) )
			{	
				sprintf( buf2, "HandleWidth %d", dr->resize_width );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_DEFAULT_GEOMETRY ) )
			{	
				sprintf( buf2, "DefaultGeometry %dx%d%+d%+d", dr->default_geometry.width, dr->default_geometry.height, dr->default_geometry.x, dr->default_geometry.y );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_VIEWPORTX ) )
			{	
				sprintf( buf2, "ViewportX %d", dr->viewport_x );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_VIEWPORTY ) )
			{	
				sprintf( buf2, "ViewportY %d", dr->viewport_y );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_GRAVITY ) )
			{	
				sprintf( buf2, "OverrideGravity %s", Gravity2text[dr->gravity] );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_LAYER ) )
			{	
				sprintf( buf2, "Layer %d", dr->layer );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_FRAME ) )
			{	
				sprintf( buf2, "Frame \"%s\"", dr->frame_name );
				APPEND_DBSTYLE_TEXT(buf2);
			}
			if( get_flags( dr->set_data_flags, STYLE_WINDOWBOX ) )
			{	
				sprintf( buf2, "WindowBox \"%s\"", dr->windowbox_name );
				APPEND_DBSTYLE_TEXT(buf2);
			}
#endif		
			add_property("Style:", buf, AS_Text_ASCII, True);
		}	 
	}	 
	{
		ASDesktopEntry *de = fetch_desktop_entry( CombinedCategories, names[2]);
		if( de == NULL ) 
			de = fetch_desktop_entry( CombinedCategories, names[3]);				  
		if( de ) 
		{	
			char *categories = make_desktop_entry_categories( de );
			add_property("Categories:", categories?categories:"<none>", AS_Text_ASCII, False);
			destroy_string( &categories ) ;
			add_property(".desktop Entry Name:", de->Name, AS_Text_ASCII, False);
			add_property(".desktop Entry Comment:", de->Comment, AS_Text_ASCII, True);
			add_property(".desktop Entry Icon:", de->Icon, AS_Text_ASCII, True);
		}
	}
}
Ejemplo n.º 18
0
void smart_object::load()
{
    std::ifstream object_file(file_name);//access file by name
    if(object_file.bad())//make sure the file is there
    {
        std::cerr<<"bad file name\n";
        return;
    }
    object_file.precision(3);
    object_file.setf(std::ios::fixed);
    //load basic object properties
    object_file>>position.x>>position.y;
    object_file>>rotation;
    object_file>>width>>height;
    object_file>>fill_color.r>>fill_color.g>>fill_color.b;
    object_file>>marker_color.r>>marker_color.g>>marker_color.b;
    object_file>>border_color.r>>border_color.g>>border_color.b;
    object_file>>filled;
    object_file>>bordered;
    object_file>>textured;
    object_file>>masked;
    object_file>>visible;
    object_file>>selected;
    object_file>>muted;
    object_file>>texture;
    object_file>>mask;
    char first_char=' ';
     //load custom properties
    while(first_char>0)//not newline or out of bounds
    {
        std::string name;
        int value;
        object_file.get();//eat the null character
        first_char=object_file.peek();//check the first character of the line
        if(first_char=='\n')
            break;
        object_file>>name>>value;
        add_property(name,value);
    }
    //load mobile object properties
    object_file>>movement_sound;
    object_file>>speed;
    object_file>>degrees_rotated;
    object_file>>rally_set;
    object_file>>moving_forward;
    object_file>>moving_backward;
    object_file>>moving_left;
    object_file>>moving_right;
    object_file>>turning_right;
    object_file>>turning_left;
    first_char=' ';
    while(first_char>0)//not newline or out of bounds
    {
        //load the cued actions
        object_file.get();//eat the null character
        first_char=object_file.peek();//check the first character of the line
        if(first_char=='\n')
            break;
        std::array<int,3> action;
        object_file>>action[0]>>action[1]>>action[2];//add action number, times to do, and  times performed
        action_cue.push(action);//add action to the cue
    }
    //load smart object properties
    object_file>>touched_side[0];
    object_file>>touched_side[1];
    object_file>>touched_side[2];
    object_file>>touched_side[3];
    object_file>>collided;
    object_file>>collision_sound;
    std::clog<<"object#"<<number<<"(smart object)"<<" loaded.\n";
}
Ejemplo n.º 19
0
int 
init_game(const char *infile, const char *outfile)
{
    FILE   *f;

    if ((f = fopen(MACRO_FILE, "r")) == NULL)
	log_status("INIT: Macro storage file %s is tweaked.\n", MACRO_FILE);
    else {
	macroload(f);
	fclose(f);
    }

    in_filename = (char *)string_dup(infile);
    if ((input_file = fopen(infile, "r")) == NULL)
	return -1;

#ifdef DELTADUMPS
    if ((delta_outfile = fopen(DELTAFILE_NAME, "w")) == NULL)
	return -1;

    if ((delta_infile = fopen(DELTAFILE_NAME, "r")) == NULL)
	return -1;
#endif

    db_free();
    init_primitives();                 /* init muf compiler */
#ifdef MPI
    mesg_init();                       /* init mpi interpreter */
#endif
    SRANDOM(getpid());                 /* init random number generator */
    tune_load_parmsfile(NOTHING);      /* load @tune parms from file */

    /* ok, read the db in */
    log_status("LOAD: %s\n", infile);
    fprintf(stderr, "LOAD: %s\n", infile);
    if (db_read(input_file) < 0)
	return -1;
    log_status("LOAD: %s (done)\n", infile);
    fprintf(stderr, "LOAD: %s (done)\n", infile);

#ifndef DISKBASE
    /* everything ok */
    fclose(input_file);
#endif

    tune_load_parmsfile(NOTHING);      /* load @tune parms from file */
    /* set up dumper */
    if (dumpfile)
	free((void *) dumpfile);
    dumpfile = alloc_string(outfile);

    if (!db_conversion_flag) {
	/* initialize the ~sys/startuptime property */
	add_property((dbref)0, "~sys/startuptime", NULL,
		     (int)time((time_t *) NULL));
	add_property((dbref)0, "~sys/maxpennies", NULL, tp_max_pennies);
	add_property((dbref)0, "~sys/dumpinterval", NULL, tp_dump_interval);
	add_property((dbref)0, "~sys/max_connects", NULL, 0);
#ifdef ALLOW_OLD_TRIGGERS
	add_property((dbref)0, "_sys/startuptime", NULL,
		     (int)time((time_t *) NULL));
	add_property((dbref)0, "_sys/maxpennies", NULL, tp_max_pennies);
	add_property((dbref)0, "_sys/dumpinterval", NULL, tp_dump_interval);
	add_property((dbref)0, "_sys/max_connects", NULL, 0);
#endif
    }

    return 0;
}
Ejemplo n.º 20
0
void
prim_addprop(PRIM_PROTOTYPE)
{
	CHECKOP(4);
	oper1 = POP();
	oper2 = POP();
	oper3 = POP();
	oper4 = POP();
	if (oper1->type != PROG_INTEGER)
		abort_interp("Non-integer argument (4)");
	if (oper2->type != PROG_STRING)
		abort_interp("Non-string argument (3)");
	if (oper3->type != PROG_STRING)
		abort_interp("Non-string argument (2)");
	if (!oper3->data.string)
		abort_interp("Empty string argument (2)");
	if (!valid_object(oper4))
		abort_interp("Non-object argument (1)");
	CHECKREMOTE(oper4->data.objref);

	if ((mlev < 2) && (!permissions(ProgUID, oper4->data.objref)))
		abort_interp("Permission denied.");

	if (!prop_write_perms(ProgUID, oper4->data.objref, oper3->data.string->data, mlev))
		abort_interp("Permission denied.");

	{
		const char *temp;
		char *tmpe;
		char tname[BUFFER_LEN];
		int len = oper3->data.string->length;

		temp = (oper2->data.string ? oper2->data.string->data : 0);
		tmpe = oper3->data.string->data;
		while (*tmpe && *tmpe != '\r')
			tmpe++;
		if (*tmpe)
			abort_interp("CRs not allowed in propname");

		strcpyn(tname, sizeof(tname), oper3->data.string->data);
		while (len-- > 0 && tname[len] == PROPDIR_DELIMITER) {
			tname[len] = '\0';
		}

		/* if ((temp) || (oper1->data.number)) */
		{
			add_property(oper4->data.objref, tname, temp, oper1->data.number);

#ifdef LOG_PROPS
			log2file("props.log", "#%d (%d) ADDPROP: o=%d n=\"%s\" s=\"%s\" v=%d",
					 program, pc->line, oper4->data.objref, tname, temp, oper1->data.number);
#endif

			ts_modifyobject(oper4->data.objref);
		}
	}
	CLEAR(oper1);
	CLEAR(oper2);
	CLEAR(oper3);
	CLEAR(oper4);
}
Ejemplo n.º 21
0
int zmq::curve_client_t::produce_initiate (msg_t *msg_)
{
    uint8_t vouch_nonce [crypto_box_NONCEBYTES];
    uint8_t vouch_plaintext [crypto_box_ZEROBYTES + 64];
    uint8_t vouch_box [crypto_box_BOXZEROBYTES + 80];

    //  Create vouch = Box [C',S](C->S')
    memset (vouch_plaintext, 0, crypto_box_ZEROBYTES);
    memcpy (vouch_plaintext + crypto_box_ZEROBYTES, cn_public, 32);
    memcpy (vouch_plaintext + crypto_box_ZEROBYTES + 32, server_key, 32);

    memcpy (vouch_nonce, "VOUCH---", 8);
    randombytes (vouch_nonce + 8, 16);

    int rc = crypto_box (vouch_box, vouch_plaintext,
                         sizeof vouch_plaintext,
                         vouch_nonce, cn_server, secret_key);
    zmq_assert (rc == 0);

    //  Assume here that metadata is limited to 256 bytes
    uint8_t initiate_nonce [crypto_box_NONCEBYTES];
    uint8_t initiate_plaintext [crypto_box_ZEROBYTES + 128 + 256];
    uint8_t initiate_box [crypto_box_BOXZEROBYTES + 144 + 256];

    //  Create Box [C + vouch + metadata](C'->S')
    memset (initiate_plaintext, 0, crypto_box_ZEROBYTES);
    memcpy (initiate_plaintext + crypto_box_ZEROBYTES,
            public_key, 32);
    memcpy (initiate_plaintext + crypto_box_ZEROBYTES + 32,
            vouch_nonce + 8, 16);
    memcpy (initiate_plaintext + crypto_box_ZEROBYTES + 48,
            vouch_box + crypto_box_BOXZEROBYTES, 80);

    //  Metadata starts after vouch
    uint8_t *ptr = initiate_plaintext + crypto_box_ZEROBYTES + 128;

    //  Add socket type property
    const char *socket_type = socket_type_string (options.type);
    ptr += add_property (ptr, "Socket-Type", socket_type, strlen (socket_type));

    //  Add identity property
    if (options.type == ZMQ_REQ
    ||  options.type == ZMQ_DEALER
    ||  options.type == ZMQ_ROUTER)
        ptr += add_property (ptr, "Identity", options.identity, options.identity_size);

    const size_t mlen = ptr - initiate_plaintext;

    memcpy (initiate_nonce, "CurveZMQINITIATE", 16);
    put_uint64 (initiate_nonce + 16, cn_nonce);

    rc = crypto_box (initiate_box, initiate_plaintext,
                     mlen, initiate_nonce, cn_server, cn_secret);
    zmq_assert (rc == 0);

    rc = msg_->init_size (113 + mlen - crypto_box_BOXZEROBYTES);
    errno_assert (rc == 0);

    uint8_t *initiate = static_cast <uint8_t *> (msg_->data ());

    memcpy (initiate, "\x08INITIATE", 9);
    //  Cookie provided by the server in the WELCOME command
    memcpy (initiate + 9, cn_cookie, 96);
    //  Short nonce, prefixed by "CurveZMQINITIATE"
    memcpy (initiate + 105, initiate_nonce + 16, 8);
    //  Box [C + vouch + metadata](C'->S')
    memcpy (initiate + 113, initiate_box + crypto_box_BOXZEROBYTES,
            mlen - crypto_box_BOXZEROBYTES);
    cn_nonce++;

    return 0;
}
Ejemplo n.º 22
0
Retcode
generic_install_flash(Environ *e, Flash_methods *methods)
{
	Retcode ret;
	Package *pkg;
	Byte *prop;
	Flash *f;
	Int plen = 0;
	Self self;
	int i;

	DPRINTF(("generic_install_flash: e=%#x\n", e));

	memset(&self, 0, sizeof self);
	self.meths = methods;
	self.width = methods->width;
	self.buf = (uByte *)malloc(4 * self.width);

	if (self.buf == NULL)
		return NO_ERROR;

	for (i = methods->unitcells - 1; i >= 0; i--)
		PUSH(e, methods->unit[i]);

	PUSH(e, methods->size);
	DPRINTF(("generic_install_flash: about to map-in\n", ret));
	ret = execute_static_method_name(e, e->root, "map-in", CSTR);
	DPRINTF(("generic_install_flash: map-in returns %d\n", ret));

	if (ret != NO_ERROR)
		return ret;

	POPT(e, self.addr, void *);
	DPRINTF(("generic_install_flash: self.addr %p\n", self.addr));

	if (self.addr == (void *)0)
	{
		DPRINTF(("generic_install_flash: unable to map-in\n"));
		return E_NO_DEVICE;
	}

	/* show the mapping */
	//PUSH(e, (Cell)self.addr);
	//f_mapq(e);

	f = flash_probe(e, &self);
	DPRINTF(("flash_probe: ret=%p\n", f));
	free((void *)self.buf);
	PUSH(e, self.addr);
	PUSH(e, methods->size);
	ret = execute_static_method_name(e, e->root, "map-out", CSTR);
	DPRINTF(("generic_install_flash: map-out returns %d\n", ret));

	if (!f)
		return E_NO_DEVICE;

	IFCKSP(e, 0, 3);
	pkg = new_pkg_name(e->currpkg, "flash");

	if (pkg == NULL)
		return E_OUT_OF_MEMORY;

	pkg->self = (struct pself*)methods;

	/* set the type of this device */
	prop_set_str(pkg->props, "device_type", CSTR, "block", CSTR);

	/* encode "reg" property for unit address */
	prop = prop_alloc(e, methods->unitcells * 2 * sizeof (Int));

	if (prop == NULL)
		return E_OUT_OF_MEMORY;

	for (i = 0; i < methods->unitcells; i++)
		prop_encode_int(prop + plen, &plen, methods->unit[i]);

	for (i = 0; i < methods->unitcells - 1; i++)
		prop_encode_int(prop + plen, &plen, 0);

	prop_encode_int(prop + plen, &plen, f->size * (methods->width / f->width));

	ret = add_property(pkg->props, "reg", CSTR, prop, plen);

	/* add device specific information */
	prop_set_str(pkg->props, "manufacture", CSTR, f->manufname, CSTR);
	prop_set_str(pkg->props, "device", CSTR, f->devname, CSTR);
	prop_set_int(pkg->props, "id", CSTR, (f->manufid << 16) | f->devid);
	prop_set_int(pkg->props, "bias", CSTR, methods->bias);

	if (ret == NO_ERROR)
		ret = init_entries(e, pkg->dict, flash_methods);

	return ret;
}