1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
15 #include <fc_config.h>
32 #include "mpcmdline.h"
37 struct fcmp_params fcmp
= {
38 .list_url
= MODPACK_LIST_URL
,
43 /**************************************************************************
44 Progress indications from downloader
45 **************************************************************************/
46 static void msg_callback(const char *msg
)
48 log_normal("%s", msg
);
51 /**************************************************************************
52 Build main modpack list view
53 **************************************************************************/
54 static void setup_modpack_list(const char *name
, const char *URL
,
55 const char *version
, const char *license
,
56 enum modpack_type type
, const char *subtype
,
63 if (modpack_type_is_valid(type
)) {
64 type_str
= _(modpack_type_name(type
));
66 /* TRANS: Unknown modpack type */
70 if (license
!= NULL
) {
73 /* TRANS: License of modpack is not known */
74 lic_str
= Q_("?license:Unknown");
77 inst_str
= get_installed_version(name
, type
);
78 if (inst_str
== NULL
) {
79 inst_str
= _("Not installed");
83 log_normal(_("Name=\"%s\""), name
);
84 log_normal(_("Version=\"%s\""), version
);
85 log_normal(_("Installed=\"%s\""), inst_str
);
86 log_normal(_("Type=\"%s\" / \"%s\""), type_str
, subtype
);
87 log_normal(_("License=\"%s\""), lic_str
);
88 log_normal(_("URL=\"%s\""), URL
);
90 log_normal(_("Comment=\"%s\""), notes
);
94 /**************************************************************************
95 Entry point of the freeciv-modpack program
96 **************************************************************************/
97 int main(int argc
, char *argv
[])
99 int loglevel
= LOG_NORMAL
;
104 /* This modifies argv! */
105 ui_options
= fcmp_parse_cmdline(argc
, argv
);
107 if (ui_options
!= -1) {
110 for (i
= 1; i
<= ui_options
; i
++) {
111 if (is_option("--help", argv
[i
])) {
113 _("This modpack installer does not support any specific options\n\n"));
115 /* TRANS: No full stop after the URL, could cause confusion. */
116 fc_fprintf(stderr
, _("Report bugs at %s\n"), BUG_URL
);
120 log_error(_("Unknown option '--' '%s'"), argv
[i
]);
126 if (ui_options
!= -1) {
127 const char *rev_ver
= fc_svn_revision();
129 load_install_info_lists(&fcmp
);
131 log_normal(_("Freeciv modpack installer (command line version)"));
133 if (rev_ver
== NULL
) {
134 log_normal("%s%s", word_version(), VERSION_STRING
);
136 rev_ver
= fc_git_revision();
137 if (rev_ver
!= NULL
) {
138 log_normal(_("commit: %s"), rev_ver
);
141 log_normal("%s%s (%s)", word_version(), VERSION_STRING
, rev_ver
);
144 if (fcmp
.autoinstall
== NULL
) {
145 download_modpack_list(&fcmp
, setup_modpack_list
, msg_callback
);
149 errmsg
= download_modpack(fcmp
.autoinstall
, &fcmp
, msg_callback
, NULL
);
151 if (errmsg
== NULL
) {
152 log_normal(_("Modpack installed successfully"));
154 log_error(_("Modpack install failed: %s"), errmsg
);
158 save_install_info_lists(&fcmp
);