Freeciv-3.4
Loading...
Searching...
No Matches
mpcli.c
Go to the documentation of this file.
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)
6 any later version.
7
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***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdlib.h>
19
20/* utility */
21#include "executable.h"
22#include "fc_cmdline.h"
23#include "fciconv.h"
24#include "fcintl.h"
25#include "log.h"
26#include "mem.h"
27
28/* common */
29#include "version.h"
30
31/* modinst */
32#include "download.h"
33#include "mpcmdline.h"
34#include "mpdb.h"
35
36#include "modinst.h"
37
38struct fcmp_params fcmp = {
40 .inst_prefix = NULL,
41 .autoinstall = NULL
42};
43
44/**********************************************************************/
47static void msg_callback(const char *msg)
48{
49 log_normal("%s", msg);
50}
51
52/**********************************************************************/
55static void setup_modpack_list(const char *name, const char *URL,
56 const char *version, const char *license,
57 enum modpack_type type, const char *subtype,
58 const char *notes)
59{
60 const char *type_str;
61 const char *lic_str;
62 const char *inst_str;
63
66 } else {
67 /* TRANS: Unknown modpack type */
68 type_str = _("?");
69 }
70
71 if (license != NULL) {
73 } else {
74 /* TRANS: License of modpack is not known */
75 lic_str = Q_("?license:Unknown");
76 }
77
79 if (inst_str == NULL) {
80 inst_str = _("Not installed");
81 }
82
83 log_normal("%s", "");
84 log_normal(_("Name=\"%s\""), name);
85 log_normal(_("Version=\"%s\""), version);
86 log_normal(_("Installed=\"%s\""), inst_str);
87 log_normal(_("Type=\"%s\" / \"%s\""), type_str, subtype);
88 log_normal(_("License=\"%s\""), lic_str);
89 log_normal(_("URL=\"%s\""), URL);
90 if (notes != NULL) {
91 log_normal(_("Comment=\"%s\""), notes);
92 }
93}
94
95/**********************************************************************/
98int main(int argc, char *argv[])
99{
100 int ui_options;
101
103
104 fcmp_init();
105
106 /* This modifies argv! */
108
109 if (ui_options != -1) {
110 int i;
111
112 for (i = 1; i <= ui_options; i++) {
113 if (is_option("--help", argv[i])) {
115 _("This modpack installer does not support any specific options\n\n"));
116
117 /* TRANS: No full stop after the URL, could cause confusion. */
118 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
119
120 ui_options = -1;
121 } else {
122 log_error(_("Unknown option '--' '%s'"), argv[i]);
123 ui_options = -1;
124 }
125 }
126 }
127
128 if (ui_options != -1) {
129 const char *rev_ver;
130
132
133 log_normal(_("Freeciv modpack installer (command line version)"));
134
136
138 if (rev_ver != NULL) {
139 log_normal(_("commit: %s"), rev_ver);
140 }
141
142 log_normal("%s", "");
143
144 if (fcmp.autoinstall == NULL) {
146
147 log_normal("%s", "");
148 log_normal(_("To install a modpack, run:"));
149 log_normal(_("%s -i <URL>"), argv[0]);
150 } else {
151 const char *errmsg;
152
154
155 if (errmsg == NULL) {
156 log_normal(_("Modpack installed successfully"));
157 } else {
158 log_error(_("Modpack install failed: %s"), errmsg);
159 }
160 }
161
162 close_mpdbs();
163 }
164
165 fcmp_deinit();
167
168 return EXIT_SUCCESS;
169}
char * incite_cost
Definition comments.c:76
const char * download_modpack(const char *URL, const struct fcmp_params *fcmp, dl_msg_callback mcb, dl_pb_callback pbcb)
Definition download.c:66
const char * download_modpack_list(const struct fcmp_params *fcmp, modpack_list_setup_cb cb, dl_msg_callback mcb)
Definition download.c:427
void executable_init(void)
Definition executable.c:34
bool is_option(const char *option_name, char *option)
Definition fc_cmdline.c:112
void cmdline_option_values_free(void)
Definition fc_cmdline.c:97
void fc_fprintf(FILE *stream, const char *format,...) fc__attribute((__format__(__printf__
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
GType type
Definition repodlgs.c:1313
const char * name
Definition inputfile.c:127
#define log_normal(message,...)
Definition log.h:108
#define log_error(message,...)
Definition log.h:104
void load_install_info_lists(struct fcmp_params *fcmp)
Definition modinst.c:44
void fcmp_deinit(void)
Definition modinst.c:98
void fcmp_init(void)
Definition modinst.c:82
#define MODPACK_LIST_URL
Definition modinst.h:30
int main(int argc, char *argv[])
Definition mpcli.c:98
struct fcmp_params fcmp
Definition mpcli.c:38
static void setup_modpack_list(const char *name, const char *URL, const char *version, const char *license, enum modpack_type type, const char *subtype, const char *notes)
Definition mpcli.c:55
static void msg_callback(const char *msg)
Definition mpcli.c:47
int fcmp_parse_cmdline(int argc, char *argv[])
Definition mpcmdline.c:45
const char * mpdb_installed_version(const char *name, enum modpack_type type)
Definition mpdb.c:253
void close_mpdbs(void)
Definition mpdb.c:202
const char * list_url
Definition modinst.h:18
const char * autoinstall
Definition modinst.h:20
const char * fc_git_revision(void)
Definition version.c:75
const char * word_version(void)
Definition version.c:62
#define VERSION_STRING
Definition version_gen.h:14