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>
21 #include "fc_cmdline.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
[])
103 /* This modifies argv! */
104 ui_options
= fcmp_parse_cmdline(argc
, argv
);
106 if (ui_options
!= -1) {
109 for (i
= 1; i
<= ui_options
; i
++) {
110 if (is_option("--help", argv
[i
])) {
112 _("This modpack installer does not support any specific options\n\n"));
114 /* TRANS: No full stop after the URL, could cause confusion. */
115 fc_fprintf(stderr
, _("Report bugs at %s\n"), BUG_URL
);
119 log_error(_("Unknown option '--' '%s'"), argv
[i
]);
125 if (ui_options
!= -1) {
126 const char *rev_ver
= fc_svn_revision();
128 load_install_info_lists(&fcmp
);
130 log_normal(_("Freeciv modpack installer (command line version)"));
132 if (rev_ver
== NULL
) {
133 log_normal("%s%s", word_version(), VERSION_STRING
);
135 rev_ver
= fc_git_revision();
136 if (rev_ver
!= NULL
) {
137 log_normal(_("commit: %s"), rev_ver
);
140 log_normal("%s%s (%s)", word_version(), VERSION_STRING
, rev_ver
);
143 log_normal("%s", "");
145 if (fcmp
.autoinstall
== NULL
) {
146 download_modpack_list(&fcmp
, setup_modpack_list
, msg_callback
);
150 errmsg
= download_modpack(fcmp
.autoinstall
, &fcmp
, msg_callback
, NULL
);
152 if (errmsg
== NULL
) {
153 log_normal(_("Modpack installed successfully"));
155 log_error(_("Modpack install failed: %s"), errmsg
);
159 save_install_info_lists(&fcmp
);
163 cmdline_option_values_free();