Author: cazfi Date: Fri Sep 25 19:42:30 2015 New Revision: 29965 URL: http://svn.gna.org/viewcvs/freeciv?rev=29965&view=rev Log: Support relative URL to modpack in the modpack.list and in the dependencies of another modpack.
See patch #6200 Modified: trunk/tools/download.c trunk/tools/download.h Modified: trunk/tools/download.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/tools/download.c?rev=29965&r1=29964&r2=29965&view=diff ============================================================================== --- trunk/tools/download.c (original) +++ trunk/tools/download.c Fri Sep 25 19:42:30 2015 @@ -224,12 +224,24 @@ if (needed) { const char *msg; + char dep_URL_full[2048]; if (mcb != NULL) { mcb(_("Download dependency modpack")); } - msg = download_modpack_recursive(dep_URL, fcmp, mcb, pbcb, recursion + 1); + if (dep_URL[0] == '.') { + char URLstart[start_idx]; + + strncpy(URLstart, URL, start_idx - 1); + URLstart[start_idx - 1] = '\0'; + fc_snprintf(dep_URL_full, sizeof(dep_URL_full), "%s%s", + URLstart, dep_URL + 1); + } else { + strncpy(dep_URL_full, dep_URL, sizeof(dep_URL_full)); + } + + msg = download_modpack_recursive(dep_URL_full, fcmp, mcb, pbcb, recursion + 1); if (msg != NULL) { return msg; @@ -353,11 +365,18 @@ int modpack_count; const char *msg; const char *mp_name; + int start_idx; list_file = netfile_get_section_file(fcmp->list_url, nf_cb, mcb); if (list_file == NULL) { return _("Cannot fetch and parse modpack list"); + } + + for (start_idx = strlen(fcmp->list_url); + start_idx > 0 && fcmp->list_url[start_idx - 1] != '/'; + start_idx--) { + /* Nothing */ } list_capstr = secfile_lookup_str(list_file, "info.options"); @@ -411,7 +430,9 @@ "modpacks.list%d.notes", modpack_count); if (mp_name != NULL && mpURL != NULL) { + char mpURL_full[2048]; enum modpack_type type = modpack_type_by_name(mp_type_str, fc_strcasecmp); + if (!modpack_type_is_valid(type)) { log_error("Illegal modpack type \"%s\"", mp_type_str ? mp_type_str : "NULL"); } @@ -421,7 +442,19 @@ if (mp_subtype == NULL) { mp_subtype = "-"; } - cb(mp_name, mpURL, mpver, mplic, type, _(mp_subtype), mp_notes); + + if (mpURL[0] == '.') { + char URLstart[start_idx]; + + strncpy(URLstart, fcmp->list_url, start_idx - 1); + URLstart[start_idx - 1] = '\0'; + fc_snprintf(mpURL_full, sizeof(mpURL_full), "%s%s", + URLstart, mpURL + 1); + } else { + strncpy(mpURL_full, mpURL, sizeof(mpURL_full)); + } + + cb(mp_name, mpURL_full, mpver, mplic, type, _(mp_subtype), mp_notes); } modpack_count++; } while (mp_name != NULL); Modified: trunk/tools/download.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/tools/download.h?rev=29965&r1=29964&r2=29965&view=diff ============================================================================== --- trunk/tools/download.h (original) +++ trunk/tools/download.h Fri Sep 25 19:42:30 2015 @@ -22,8 +22,8 @@ #define MODPACK_SUFFIX ".modpack" -#define MODPACK_CAPSTR "+Freeciv-modpack-Devel-2014.Apr.13" -#define MODLIST_CAPSTR "+Freeciv-modlist-Devel-2014.Jan.03" +#define MODPACK_CAPSTR "+Freeciv-modpack-Devel-2015.Sep.25" +#define MODLIST_CAPSTR "+Freeciv-modlist-Devel-2015.Sep.25" #define FCMP_CONTROLD ".control" _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits