static const char * _moduleNameToLibrary(const char *moduleName) { char *result = NULL; assertNotNull(moduleName, "module name must not be null"); const char *module = _strtoupper(moduleName); PARCBufferComposer *composer = parcBufferComposer_Create(); if (composer != NULL) { parcBufferComposer_Format(composer, "%s%s%s", LIBRARY_MODULE_PREFIX, module, LIBRARY_MODULE_SUFFIX); PARCBuffer *tempBuffer = parcBufferComposer_ProduceBuffer(composer); parcBufferComposer_Release(&composer); result = parcBuffer_ToString(tempBuffer); parcBuffer_Release(&tempBuffer); } parcMemory_Deallocate(&module); return result; }
int sharetool_geo_create(char *place_str) { static const char **places; shnum_t lat, lon; shgeo_t geo; shloc_t loc; int err; int n; int i; memset(&geo, 0, sizeof(geo)); n = sscanf(place_str, "geo:%Lf,%Lf", &lat, &lon); if (n != 2) return (SHERR_INVAL); memset(&loc, 0, sizeof(loc)); shgeo_set(&geo, lat, lon, 0); if (0 == shgeodb_loc(&geo, &loc)) { fprintf(sharetool_fout, "Error: Location already exists at latitude %Lf and longitude %Lf.\n", lat, lon); return (SHERR_EXIST); } memset(&loc, 0, sizeof(loc)); sharetool_geo_input("Location Name", loc.loc_name, sizeof(loc.loc_name)-1); sharetool_geo_input("Country Abreviation [US]", loc.loc_locale, sizeof(loc.loc_locale)-1); if (strlen(loc.loc_locale) != 2) { if (loc.loc_locale[0]) { printf("Warning: Unknown country abeviation \"%s\" -- defaulting to \"US\".\n", loc.loc_locale); } strcpy(loc.loc_locale, "US"); } sharetool_geo_input("State/Provice []", loc.loc_zone, sizeof(loc.loc_zone)-1); /* list codes */ printf("\n"); if (!places) places = shgeo_place_codes(); if (places) { for (i = 0; places[i]; i++) { printf("%-12.12s ", places[i]); if (5 == (i % 6)) printf("\n"); } printf("\n"); } sharetool_geo_input("Enter location type [AREA]", loc.loc_type, sizeof(loc.loc_type)); _strtoupper(loc.loc_type); if (!*loc.loc_type) strcpy(loc.loc_type, "AREA"); sharetool_geo_input("Enter an optional description []", loc.loc_summary, sizeof(loc.loc_summary)); err = shgeodb_loc_set(&geo, &loc); if (err) { fprintf(sharetool_fout, "Error: Unable to set location \"geo:%Lf,%Lf\": %s [sherr %d].", lat, lon, sherrstr(err), err); return (err); } fprintf(sharetool_fout, "Created new location \"geo:%Lf,%Lf\".\n", lat, lon); return (0); }