void Actor::pushItems(Tile* tile) { //We can not use iterators here since we can push the item to another tile //which will invalidate the iterator. //start from the end to minimize the amount of traffic uint32_t moveCount = 0; uint32_t removeCount = 0; int32_t downItemCount = tile->items_downCount(); for(int32_t i = downItemCount - 1; i >= 0; --i){ assert(i >= 0 && i < downItemCount); Item* item = tile->items_get(i); if(item && item->isMoveable() && (item->blockPathFind() || item->blockSolid() ) ){ if(moveCount < 20 && pushItem(item, 1)){ moveCount++; } else if(g_game.internalRemoveItem(this, item) == RET_NOERROR){ ++removeCount; } } } if(removeCount > 0){ g_game.addMagicEffect(tile->getPosition(), MAGIC_EFFECT_PUFF); } }
void Monster::pushItems(Tile* tile) { TileItemVector* items = tile->getItemList(); if(!items) return; //We cannot use iterators here since we can push the item to another tile //which will invalidate the iterator. //start from the end to minimize the amount of traffic int32_t moveCount = 0, removeCount = 0, downItemsSize = tile->getDownItemCount(); Item* item = NULL; for(int32_t i = downItemsSize - 1; i >= 0; --i) { assert(i >= 0 && i < downItemsSize); if((item = items->at(i)) && item->hasProperty(MOVEABLE) && (item->hasProperty(BLOCKPATH) || item->hasProperty(BLOCKSOLID))) { if(moveCount < 20 && pushItem(item, 1)) moveCount++; else if(g_game.internalRemoveItem(this, item) == RET_NOERROR) ++removeCount; } } if(removeCount > 0) g_game.addMagicEffect(tile->getPosition(), MAGIC_EFFECT_POFF); }
/* Pulls all items from list which match this prefix * note: they are removed from the original list an returned in a new one */ struct keyval *getMatches(struct keyval *head, const char *name) { struct keyval *out = NULL; struct keyval *p; if (!head) return NULL; out = malloc(sizeof(struct keyval)); if (!out) return NULL; initList(out); p = head->next; while(p != head) { struct keyval *next = p->next; if (!strncmp(p->key, name, strlen(name))) { p->next->prev = p->prev; p->prev->next = p->next; pushItem(out, p); } p = next; } if (listHasData(out)) return out; free(out); return NULL; }
void QgsMessageBar::popItem( QgsMessageBarItem *item ) { Q_ASSERT( item ); if ( item != mCurrentItem && !mList.contains( item ) ) return; if ( item == mCurrentItem ) { if ( mCurrentItem ) { mLayout->removeWidget( mCurrentItem->widget() ); mCurrentItem->widget()->hide(); mCurrentItem = 0; } if ( !mList.isEmpty() ) { pushItem( mList.first() ); } else { hide(); } } else { mList.removeOne( item ); } emit widgetRemoved( item->widget() ); }
void Monster::pushItems(Tile* tile) { //We can not use iterators here since we can push the item to another tile //which will invalidate the iterator. //start from the end to minimize the amount of traffic if(TileItemVector* items = tile->getItemList()){ uint32_t moveCount = 0; uint32_t removeCount = 0; int32_t downItemSize = tile->getDownItemCount(); for(int32_t i = downItemSize - 1; i >= 0; --i){ assert(i >= 0 && i < downItemSize); Item* item = items->at(i); if(item && item->hasProperty(MOVEABLE) && (item->hasProperty(BLOCKPATH) || item->hasProperty(BLOCKSOLID))){ if(moveCount < 20 && pushItem(item, 1)){ moveCount++; } else if(g_game.internalRemoveItem(item) == RET_NOERROR){ ++removeCount; } } } if(removeCount > 0){ g_game.addMagicEffect(tile->getPosition(), NM_ME_PUFF); } } }
void QgsMessageBar::pushWidget( QWidget *widget, const QString &styleSheet ) { if ( !widget ) return; // avoid duplicated widget popWidget( widget ); pushItem( new QgsMessageBarItem( widget, styleSheet ) ); }
void push(int* data, int step, int movedDisc) { /*printf("\nPUSH\n");*/ StackItem* stackItem; stackItem = (StackItem*) malloc(sizeof(* stackItem)); stackItem->data = data; stackItem->next = NULL; stackItem->i = 0; stackItem->j = 0; stackItem->movedDisc = movedDisc; pushItem(stackItem, step); }
QgsMessageBarItem* QgsMessageBar::pushWidget( QWidget *widget , QgsMessageBar::MessageLevel level, int duration ) { QgsMessageBarItem *item; item = dynamic_cast<QgsMessageBarItem*>( widget ); if ( item ) { item->setLevel( level )->setDuration( duration ); } else { item = new QgsMessageBarItem( widget, level, duration ); } pushItem( item ); return item; }
void QgsMessageBar::pushMessage( const QString &title, const QString &text, QgsMessageBar::MessageLevel level, int duration ) { QgsMessageBarItem *item = new QgsMessageBarItem( title, text, level, duration ); pushItem( item ); }
static int split_tags(struct keyval *tags, unsigned int flags, struct keyval *names, struct keyval *places, struct keyval *extratags, int* admin_level, struct keyval ** housenumber, struct keyval ** street, char ** isin, struct keyval ** postcode, struct keyval ** countrycode) { int placehouse = 0; int placebuilding = 0; int placeadmin = 0; struct keyval *landuse; struct keyval *place; struct keyval *item; struct keyval *conscriptionnumber; struct keyval *streetnumber; *admin_level = ADMINLEVEL_NONE; *housenumber = 0; *street = 0; *isin = 0; int isinsize = 0; *postcode = 0; *countrycode = 0; landuse = 0; place = 0; conscriptionnumber = 0; streetnumber = 0; /* Initialise the result lists */ initList(names); initList(places); initList(extratags); /* Loop over the tags */ while ((item = popItem(tags)) != NULL) { /* If this is a name tag, add it to the name list */ if (strcmp(item->key, "ref") == 0 || strcmp(item->key, "int_ref") == 0 || strcmp(item->key, "nat_ref") == 0 || strcmp(item->key, "reg_ref") == 0 || strcmp(item->key, "loc_ref") == 0 || strcmp(item->key, "old_ref") == 0 || strcmp(item->key, "ncn_ref") == 0 || strcmp(item->key, "rcn_ref") == 0 || strcmp(item->key, "lcn_ref") == 0 || strcmp(item->key, "iata") == 0 || strcmp(item->key, "icao") == 0 || strcmp(item->key, "pcode:1") == 0 || strcmp(item->key, "pcode:2") == 0 || strcmp(item->key, "pcode:3") == 0 || strcmp(item->key, "un:pcode:1") == 0 || strcmp(item->key, "un:pcode:2") == 0 || strcmp(item->key, "un:pcode:3") == 0 || strcmp(item->key, "name") == 0 || (strncmp(item->key, "name:", 5) == 0) || strcmp(item->key, "int_name") == 0 || (strncmp(item->key, "int_name:", 9) == 0) || strcmp(item->key, "nat_name") == 0 || (strncmp(item->key, "nat_name:", 9) == 0) || strcmp(item->key, "reg_name") == 0 || (strncmp(item->key, "reg_name:", 9) == 0) || strcmp(item->key, "loc_name") == 0 || (strncmp(item->key, "loc_name:", 9) == 0) || strcmp(item->key, "old_name") == 0 || (strncmp(item->key, "old_name:", 9) == 0) || strcmp(item->key, "alt_name") == 0 || (strncmp(item->key, "alt_name:", 9) == 0) || strcmp(item->key, "official_name") == 0 || (strncmp(item->key, "official_name:", 14) == 0) || strcmp(item->key, "commonname") == 0 || (strncmp(item->key, "commonname:", 11) == 0) || strcmp(item->key, "common_name") == 0 || (strncmp(item->key, "common_name:", 12) == 0) || strcmp(item->key, "place_name") == 0 || (strncmp(item->key, "place_name:", 11) == 0) || strcmp(item->key, "short_name") == 0 || (strncmp(item->key, "short_name:", 11) == 0) || strcmp(item->key, "operator") == 0) /* operator is a bit of an oddity */ { if (strcmp(item->key, "name:prefix") == 0) { pushItem(extratags, item); } else { pushItem(names, item); } } else if (strcmp(item->key, "aerialway") == 0 || strcmp(item->key, "aeroway") == 0 || strcmp(item->key, "amenity") == 0 || strcmp(item->key, "boundary") == 0 || strcmp(item->key, "bridge") == 0 || strcmp(item->key, "craft") == 0 || strcmp(item->key, "emergency") == 0 || strcmp(item->key, "highway") == 0 || strcmp(item->key, "historic") == 0 || strcmp(item->key, "leisure") == 0 || strcmp(item->key, "military") == 0 || strcmp(item->key, "natural") == 0 || strcmp(item->key, "office") == 0 || strcmp(item->key, "railway") == 0 || strcmp(item->key, "shop") == 0 || strcmp(item->key, "tourism") == 0 || strcmp(item->key, "tunnel") == 0 || strcmp(item->key, "waterway") == 0 ) { if (strcmp(item->value, "no")) { pushItem(places, item); if (strcmp(item->key, "boundary") == 0 && strcmp(item->value, "administrative") == 0) { placeadmin = 1; } } else { freeItem(item); } } else if (strcmp(item->key, "place") == 0) { place = item; } else if (strcmp(item->key, "addr:housename") == 0) { pushItem(names, item); placehouse = 1; } else if (strcmp(item->key, "landuse") == 0) { if (strcmp(item->value, "cemetery") == 0) pushItem(places, item); else landuse = item; } else if (strcmp(item->key, "postal_code") == 0 || strcmp(item->key, "post_code") == 0 || strcmp(item->key, "postcode") == 0 || strcmp(item->key, "addr:postcode") == 0 || strcmp(item->key, "tiger:zip_left") == 0 || strcmp(item->key, "tiger:zip_right") == 0) { if (*postcode) freeItem(item); else *postcode = item; } else if (strcmp(item->key, "addr:street") == 0) { *street = item; } else if ((strcmp(item->key, "country_code_iso3166_1_alpha_2") == 0 || strcmp(item->key, "country_code_iso3166_1") == 0 || strcmp(item->key, "country_code_iso3166") == 0 || strcmp(item->key, "country_code") == 0 || strcmp(item->key, "iso3166-1:alpha2") == 0 || strcmp(item->key, "iso3166-1") == 0 || strcmp(item->key, "ISO3166-1") == 0 || strcmp(item->key, "iso3166") == 0 || strcmp(item->key, "is_in:country_code") == 0 || strcmp(item->key, "addr:country") == 0 || strcmp(item->key, "addr:country_code") == 0) && strlen(item->value) == 2) { *countrycode = item; } else if (strcmp(item->key, "addr:housenumber") == 0) { /* house number can be far more complex than just a single house number - leave for postgresql to deal with */ if (*housenumber) freeItem(item); else { *housenumber = item; placehouse = 1; } } else if (strcmp(item->key, "addr:conscriptionnumber") == 0) { if (conscriptionnumber) freeItem(item); else { conscriptionnumber = item; placehouse = 1; } } else if (strcmp(item->key, "addr:streetnumber") == 0) { if (streetnumber) freeItem(item); else { streetnumber = item; placehouse = 1; } } else if (strcmp(item->key, "addr:interpolation") == 0) { /* house number can be far more complex than just a single house number - leave for postgresql to deal with */ if (*housenumber) { freeItem(item); } else { *housenumber = item; addItem(places, "place", "houses", 1); } } else if (strcmp(item->key, "is_in") == 0 || (strncmp(item->key, "is_in:", 5) == 0) || strcmp(item->key, "addr:country")== 0 || strcmp(item->key, "addr:county")== 0 || strcmp(item->key, "tiger:county")== 0 || strcmp(item->key, "addr:city") == 0 || strcmp(item->key, "addr:state_code") == 0 || strcmp(item->key, "addr:state") == 0) { *isin = realloc(*isin, isinsize + 2 + strlen(item->value)); *(*isin+isinsize) = ','; strcpy(*isin+1+isinsize, item->value); isinsize += 1 + strlen(item->value); freeItem(item); } else if (strcmp(item->key, "admin_level") == 0) { *admin_level = atoi(item->value); freeItem(item); } else if (strcmp(item->key, "tracktype") == 0 || strcmp(item->key, "traffic_calming") == 0 || strcmp(item->key, "service") == 0 || strcmp(item->key, "cuisine") == 0 || strcmp(item->key, "capital") == 0 || strcmp(item->key, "dispensing") == 0 || strcmp(item->key, "religion") == 0 || strcmp(item->key, "denomination") == 0 || strcmp(item->key, "sport") == 0 || strcmp(item->key, "internet_access") == 0 || strcmp(item->key, "lanes") == 0 || strcmp(item->key, "surface") == 0 || strcmp(item->key, "smoothness") == 0 || strcmp(item->key, "width") == 0 || strcmp(item->key, "est_width") == 0 || strcmp(item->key, "incline") == 0 || strcmp(item->key, "opening_hours") == 0 || strcmp(item->key, "food_hours") == 0 || strcmp(item->key, "collection_times") == 0 || strcmp(item->key, "service_times") == 0 || strcmp(item->key, "smoking_hours") == 0 || strcmp(item->key, "disused") == 0 || strcmp(item->key, "wheelchair") == 0 || strcmp(item->key, "sac_scale") == 0 || strcmp(item->key, "trail_visibility") == 0 || strcmp(item->key, "mtb:scale") == 0 || strcmp(item->key, "mtb:description") == 0 || strcmp(item->key, "wood") == 0 || strcmp(item->key, "drive_thru") == 0 || strcmp(item->key, "drive_in") == 0 || strcmp(item->key, "access") == 0 || strcmp(item->key, "vehicle") == 0 || strcmp(item->key, "bicyle") == 0 || strcmp(item->key, "foot") == 0 || strcmp(item->key, "goods") == 0 || strcmp(item->key, "hgv") == 0 || strcmp(item->key, "motor_vehicle") == 0 || strcmp(item->key, "motor_car") == 0 || (strncmp(item->key, "access:", 7) == 0) || (strncmp(item->key, "contact:", 8) == 0) || (strncmp(item->key, "drink:", 6) == 0) || strcmp(item->key, "oneway") == 0 || strcmp(item->key, "date_on") == 0 || strcmp(item->key, "date_off") == 0 || strcmp(item->key, "day_on") == 0 || strcmp(item->key, "day_off") == 0 || strcmp(item->key, "hour_on") == 0 || strcmp(item->key, "hour_off") == 0 || strcmp(item->key, "maxweight") == 0 || strcmp(item->key, "maxheight") == 0 || strcmp(item->key, "maxspeed") == 0 || strcmp(item->key, "disused") == 0 || strcmp(item->key, "toll") == 0 || strcmp(item->key, "charge") == 0 || strcmp(item->key, "population") == 0 || strcmp(item->key, "description") == 0 || strcmp(item->key, "image") == 0 || strcmp(item->key, "attribution") == 0 || strcmp(item->key, "fax") == 0 || strcmp(item->key, "email") == 0 || strcmp(item->key, "url") == 0 || strcmp(item->key, "website") == 0 || strcmp(item->key, "phone") == 0 || strcmp(item->key, "tel") == 0 || strcmp(item->key, "real_ale") == 0 || strcmp(item->key, "smoking") == 0 || strcmp(item->key, "food") == 0 || strcmp(item->key, "camera") == 0 || strcmp(item->key, "brewery") == 0 || strcmp(item->key, "locality") == 0 || strcmp(item->key, "wikipedia") == 0 || (strncmp(item->key, "wikipedia:", 10) == 0) ) { pushItem(extratags, item); } else if (strcmp(item->key, "building") == 0) { placebuilding = 1; freeItem(item); } else if (strcmp(item->key, "mountain_pass") == 0) { pushItem(places, item); } else { freeItem(item); } } /* Handle Czech/Slovak addresses: - if we have just a conscription number or a street number, just use the one we have as a house number - if we have both of them, concatenate them so users may search by any of them */ if (conscriptionnumber || streetnumber) { if (*housenumber) { freeItem(*housenumber); } if (!conscriptionnumber) { addItem(tags, "addr:housenumber", streetnumber->value, 0); freeItem(streetnumber); *housenumber = popItem(tags); } if (!streetnumber) { addItem(tags, "addr:housenumber", conscriptionnumber->value, 10); freeItem(conscriptionnumber); *housenumber = popItem(tags); } if (conscriptionnumber && streetnumber) { char * completenumber = strdup(conscriptionnumber->value); size_t completenumberlength = strlen(completenumber); completenumber = realloc(completenumber, completenumberlength + 2 + strlen(streetnumber->value)); *(completenumber + completenumberlength) = '/'; strcpy(completenumber + completenumberlength + 1, streetnumber->value); freeItem(conscriptionnumber); freeItem(streetnumber); addItem(tags, "addr:housenumber", completenumber, 0); *housenumber = popItem(tags); free(completenumber); } } if (place) { if (placeadmin) { pushItem(extratags, place); } else { pushItem(places, place); } } if (placehouse && !listHasData(places)) { addItem(places, "place", "house", 1); } /* Fallback place types - only used if we didn't create something more specific already */ if (placebuilding && !listHasData(places) && (listHasData(names) || *housenumber || *postcode)) { addItem(places, "building", "yes", 1); } if (landuse) { if (!listHasData(places)) { pushItem(places, landuse); } else { freeItem(item); } } if (*postcode && !listHasData(places)) { addItem(places, "place", "postcode", 1); } /* Try to convert everything to an area */ return 1; }
/* Go through the given tags and determine the union of flags. Also remove * any tags from the list that we don't know about */ static unsigned int tagtransform_c_filter_basic_tags(enum OsmType type, struct keyval *tags, int *polygon, int * roads) { int i, filter = 1; int flags = 0; int add_area_tag = 0; enum OsmType export_type; const char *area; struct keyval *item; struct keyval temp; initList(&temp); if (type == OSMTYPE_RELATION) {export_type = OSMTYPE_WAY;} else {export_type = type;} /* We used to only go far enough to determine if it's a polygon or not, but now we go through and filter stuff we don't need */ while ((item = popItem(tags)) != NULL ) { if (type == OSMTYPE_RELATION && !strcmp("type", item->key)) { pushItem(&temp, item); item = NULL; filter = 0; continue; } /* Allow named islands to appear as polygons */ if (!strcmp("natural", item->key) && !strcmp("coastline", item->value)) { add_area_tag = 1; } /* Discard natural=coastline tags (we render these from a shapefile instead) */ if (!options->keep_coastlines && !strcmp("natural", item->key) && !strcmp("coastline", item->value)) { freeItem(item); item = NULL; continue; } for (i = 0; i < exportListCount[export_type]; i++) { if (wildMatch(exportList[export_type][i].name, item->key)) { if (exportList[export_type][i].flags & FLAG_DELETE) { freeItem(item); item = NULL; break; } filter = 0; flags |= exportList[export_type][i].flags; pushItem(&temp, item); item = NULL; break; } } /** if tag not found in list of exports: */ if (i == exportListCount[export_type]) { if (options->enable_hstore) { /* with hstore, copy all tags... */ pushItem(&temp, item); /* ... but if hstore_match_only is set then don't take this as a reason for keeping the object */ if (!options->hstore_match_only && strcmp("osm_uid", item->key) && strcmp("osm_user", item->key) && strcmp("osm_timestamp", item->key) && strcmp("osm_version", item->key) && strcmp("osm_changeset", item->key)) filter = 0; } else if (options->n_hstore_columns) { /* does this column match any of the hstore column prefixes? */ int j; for (j = 0; j < options->n_hstore_columns; j++) { char *pos = strstr(item->key, options->hstore_columns[j]); if (pos == item->key) { pushItem(&temp, item); /* ... but if hstore_match_only is set then don't take this as a reason for keeping the object */ if (!options->hstore_match_only && strcmp("osm_uid", item->key) && strcmp("osm_user", item->key) && strcmp("osm_timestamp", item->key) && strcmp("osm_version", item->key) && strcmp("osm_changeset", item->key)) filter = 0; break; } } /* if not, skip the tag */ if (j == options->n_hstore_columns) { freeItem(item); } } else { freeItem(item); } item = NULL; } } /* Move from temp list back to original list */ while ((item = popItem(&temp)) != NULL ) pushItem(tags, item); *polygon = flags & FLAG_POLYGON; /* Special case allowing area= to override anything else */ if ((area = getItem(tags, "area"))) { if (!strcmp(area, "yes") || !strcmp(area, "true") || !strcmp(area, "1")) *polygon = 1; else if (!strcmp(area, "no") || !strcmp(area, "false") || !strcmp(area, "0")) *polygon = 0; } else { /* If we need to force this as a polygon, append an area tag */ if (add_area_tag) { addItem(tags, "area", "yes", 0); *polygon = 1; } } if (!filter && (type == OSMTYPE_WAY)) { add_z_order(tags,roads); } return filter; }
static int split_tags(struct keyval *tags, unsigned int flags, struct keyval *names, struct keyval *places, int* admin_level, char ** housenumber, char ** street, char ** isin, char ** postcode, char ** countrycode) { int area = 0; int placehouse = 0; struct keyval *item; *admin_level = ADMINLEVEL_NONE; *housenumber = 0; *street = 0; *isin = 0; int isinsize = 0; *postcode = 0; *countrycode = 0; /* Initialise the result lists */ initList(names); initList(places); /* Loop over the tags */ while ((item = popItem(tags)) != NULL) { // fprintf(stderr, "%s\n", item->key); /* If this is a name tag, add it to the name list */ if (strcmp(item->key, "ref") == 0 || strcmp(item->key, "iata") == 0 || strcmp(item->key, "icao") == 0 || strcmp(item->key, "pcode:1") == 0 || strcmp(item->key, "pcode:2") == 0 || strcmp(item->key, "pcode:3") == 0 || strcmp(item->key, "un:pcode:1") == 0 || strcmp(item->key, "un:pcode:2") == 0 || strcmp(item->key, "un:pcode:3") == 0 || strcmp(item->key, "name") == 0 || (strncmp(item->key, "name:", 5) == 0) || strcmp(item->key, "int_name") == 0 || (strncmp(item->key, "int_name:", 9) == 0) || strcmp(item->key, "nat_name") == 0 || (strncmp(item->key, "nat_name:", 9) == 0) || strcmp(item->key, "reg_name") == 0 || (strncmp(item->key, "reg_name:", 9) == 0) || strcmp(item->key, "loc_name") == 0 || (strncmp(item->key, "loc_name:", 9) == 0) || strcmp(item->key, "old_name") == 0 || (strncmp(item->key, "old_name:", 9) == 0) || strcmp(item->key, "alt_name") == 0 || (strncmp(item->key, "alt_name:", 9) == 0) || strcmp(item->key, "official_name") == 0 || (strncmp(item->key, "official_name:", 14) == 0) || strcmp(item->key, "commonname") == 0 || (strncmp(item->key, "commonname:", 11) == 0) || strcmp(item->key, "common_name") == 0 || (strncmp(item->key, "common_name:", 12) == 0) || strcmp(item->key, "place_name") == 0 || (strncmp(item->key, "place_name:", 11) == 0) || strcmp(item->key, "short_name") == 0 || (strncmp(item->key, "short_name:", 11) == 0)) { pushItem(names, item); } else if (strcmp(item->key, "addr:housename") == 0) { pushItem(names, item); placehouse = 1; } else if (strcmp(item->key, "postal_code") == 0 || strcmp(item->key, "post_code") == 0 || strcmp(item->key, "postcode") == 0 || strcmp(item->key, "addr:postcode") == 0) { *postcode = item->value; addItem(places, "place", "postcode", 1); } else if (strcmp(item->key, "addr:street") == 0) { *street = item->value; } else if ((strcmp(item->key, "country_code_iso3166_1_alpha_2") == 0 || strcmp(item->key, "country_code_iso3166_1") == 0 || strcmp(item->key, "country_code_iso3166") == 0 || strcmp(item->key, "country_code") == 0 || strcmp(item->key, "iso3166-1") == 0 || strcmp(item->key, "ISO3166-1") == 0 || strcmp(item->key, "iso3166") == 0 || strcmp(item->key, "is_in:country_code") == 0 || strcmp(item->key, "addr:country") == 0 || strcmp(item->key, "addr:country_code") == 0) && strlen(item->value) == 2) { *countrycode = item->value; } else if (strcmp(item->key, "addr:housenumber") == 0) { // house number can be far more complex than just a single house number - leave for postgresql to deal with *housenumber = item->value; placehouse = 1; } else if (strcmp(item->key, "addr:interpolation") == 0) { // house number can be far more complex than just a single house number - leave for postgresql to deal with *housenumber = item->value; addItem(places, "place", "houses", 1); } else if (strcmp(item->key, "is_in") == 0 || (strncmp(item->key, "is_in:", 5) == 0) || strcmp(item->key, "addr:country")== 0 || strcmp(item->key, "addr:county")== 0 || strcmp(item->key, "addr:city") == 0|| strcmp(item->key, "addr:state") == 0) { *isin = realloc(*isin, isinsize + 2 + strlen(item->value)); *(*isin+isinsize) = ','; strcpy(*isin+1+isinsize, item->value); isinsize += 1 + strlen(item->value); } else if (strcmp(item->key, "admin_level") == 0) { *admin_level = atoi(item->value); } else { const struct taginfo *t; /* If this is a tag we want then add it to the place list */ for (t = taginfo; t->name != NULL; t++) { if ((t->flags & flags) != 0) { if (strcmp(t->name, item->key) == 0 && (t->value == NULL || strcmp(t->value, item->value) == 0)) { if ((t->flags & TAGINFO_AREA) != 0) area = 1; pushItem(places, item); break; } } } /* Free the tag if we didn't want it */ if (t->name == NULL) freeItem(item); } } if (placehouse) { addItem(places, "place", "house", 1); } return area; }
int main(){ int options; printf("\nWelcome to The Song Database."); while (options != 5) { options = intro(); if (options == 1) { char* artist; char* album; char* song_title; char* date; char* song_time_char; int song_time; artist = malloc (MAX_SIZE); album = malloc (MAX_SIZE); song_title = malloc (MAX_SIZE); date = malloc (MAX_SIZE); song_time_char = malloc (MAX_SIZE); printf ("\nPlease enter the artist name: "); fgets (artist, MAX_SIZE, stdin); if ((strlen(artist)>0) && (artist[strlen (artist) - 1] == '\n')) artist[strlen (artist) - 1] = '\0'; printf ("Please enter the album name: "); fgets (album, MAX_SIZE, stdin); if ((strlen(album)>0) && (album[strlen (album) - 1] == '\n')) album[strlen (album) - 1] = '\0'; printf("Please enter the song title: "); fgets (song_title, MAX_SIZE, stdin); if ((strlen(song_title)>0) && (song_title[strlen (song_title) - 1] == '\n')) song_title[strlen (song_title) - 1] = '\0'; printf("Please enter the date: "); fgets (date, MAX_SIZE, stdin); if ((strlen(date)>0) && (date[strlen (date) - 1] == '\n')) date[strlen (date) - 1] = '\0'; printf("Please enter song time: "); fgets(song_time_char, MAX_SIZE, stdin); if ((strlen(song_time_char)>0) && (song_time_char[strlen (song_time_char) - 1] == '\n')) song_time_char[strlen (song_time_char) - 1] = '\0'; song_time = atoi(song_time_char); pushItem(artist, album, song_title, date, song_time); free(artist); free(album); free(song_title); free(date); free(song_time_char); } else if (options == 2) { delete_artist(); } else if (options == 3) { if (head == NULL) { printf("\nNo entries found\n"); } else { printf("\nPrinting it forward:\n"); print_forward(head); } } else if (options == 4) { if (head == NULL) { printf("\nNo entries found\n"); } else { printf("\nPrinting it backward\n"); print_backward(tail); } } else if (options == 5) { freeEverything(head); printf("\nGoodbye.\n"); break; } else { printf("\nNo Valid Input\n"); } } return 0; }