Esempio n. 1
0
/* copy Business_t to Business ,and
 * state code and ZIP code to filter locations by, or NULL
 * to include all states.
 */
struct Business* copy_filte_business( struct Business_t* business, char* state, char* zip_code, FILE* file ) {
	int i;
	struct Business* ret;
	struct Location_t *loc_t;
	
	ret = (struct Business*)malloc( sizeof(struct Business) );
	ret->name = copy_str(business->name);
	ret->locations = NULL;
	ret->num_locations = 0;
	
	for( i=0 ; i<business->num_locations ; i++ ) {
		loc_t = &(business->locations[i]);
		if( (state==NULL || !strcmp(state, loc_t->state)) &&
			(zip_code==NULL || !strcmp(zip_code, loc_t->zip_code)) ) {	// Using state and ZIP_code to filter locations by
				ret->locations = (struct Location*)realloc( ret->locations, (ret->num_locations+1)*sizeof(struct Location) );
				ret->locations[ ret->num_locations ] = *copy_location( loc_t, file );
				ret->num_locations ++;
		}
	}
	/*
	struct Business* bis = ret;
	printf( "num_locations = %d\n" , bis->num_locations );
	for( int i=0 ; i<bis->num_locations ; i++ ) {
		printf( "location = %s\n", bis->locations[i].address );
	}printf( "\n" );
	*/

	return ret;
}
Esempio n. 2
0
Asset& Asset::operator=(Asset &asset)
{
printf("Asset::operator=\n");
	copy_location(&asset);
	copy_format(&asset, 1);
	return *this;
}
Esempio n. 3
0
File: task.c Progetto: ezc/elinks
/** If @a loaded_in_frame is set, this was called just to indicate a move inside
 * a frameset, and we basically just reset the appropriate frame's view_state in
 * that case. When clicking on a link inside a frame, the frame URI is somehow
 * updated and added to the files-to-load queue, then ses_forward() is called
 * with @a loaded_in_frame unset, duplicating the whole frameset's location,
 * then later the file-to-load callback calls it for the particular frame with
 * @a loaded_in_frame set. */
struct view_state *
ses_forward(struct session *ses, int loaded_in_frame)
{
	struct location *loc = NULL;
	struct view_state *vs;

	if (!loaded_in_frame) {
		free_files(ses);
		mem_free_set(&ses->search_word, NULL);
	}

x:
	if (!loaded_in_frame) {
		loc = mem_calloc(1, sizeof(*loc));
		if (!loc) return NULL;
		copy_struct(&loc->download, &ses->loading);
	}

	if (ses->task.target.frame && *ses->task.target.frame) {
		struct frame *frame;

		assertm(have_location(ses), "no location yet");
		if_assert_failed return NULL;

		if (!loaded_in_frame) {
			copy_location(loc, cur_loc(ses));
			add_to_history(&ses->history, loc);
		}

		frame = ses_find_frame(ses, ses->task.target.frame);
		if (!frame) {
			if (!loaded_in_frame) {
				del_from_history(&ses->history, loc);
				destroy_location(loc);
			}
			mem_free_set(&ses->task.target.frame, NULL);
			goto x;
		}

		vs = &frame->vs;
		if (!loaded_in_frame) {
			destroy_vs(vs, 1);
			init_vs(vs, ses->loading_uri, vs->plain);
		} else {
			done_uri(vs->uri);
			vs->uri = get_uri_reference(ses->loading_uri);
			if (vs->doc_view) {
				/* vs->doc_view itself will get detached in
				 * render_document_frames(), but that's too
				 * late for us. */
				vs->doc_view->vs = NULL;
				vs->doc_view = NULL;
			}
#ifdef CONFIG_ECMASCRIPT
			vs->ecmascript_fragile = 1;
#endif
		}

	} else {
Esempio n. 4
0
Character::Character(const Character & character)
{
    if(!character.name)
        name = NULL; 
    else
    {
        name = new char[strlen(character.name) + 1];
        strcpy(name, character.name);
    }
    //health
    health = character.health;
    //weaps
    copy_weapons(character.weaps);
    //powers
    copy_powers(character.pwrs);
    //location
    if(!location)
        location = new Location();
    copy_location(character.location);

}
Esempio n. 5
0
Asset& Asset::operator=(Asset &asset)
{
	copy_location(&asset);
	copy_format(&asset, 1);
	return *this;
}
Esempio n. 6
0
void Asset::copy_from(Asset *asset, int do_index)
{
	copy_location(asset);
	copy_format(asset, do_index);
}