Freeciv-3.3
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 "fc_cmdline.h"
22#include "fciconv.h"
23#include "fcintl.h"
24#include "log.h"
25#include "mem.h"
26
27/* common */
28#include "version.h"
29
30/* modinst */
31#include "download.h"
32#include "mpcmdline.h"
33#include "mpdb.h"
34
35#include "modinst.h"
36
37struct fcmp_params fcmp = {
39 .inst_prefix = NULL,
40 .autoinstall = NULL
41};
42
43/**********************************************************************/
46static void msg_callback(const char *msg)
47{
48 log_normal("%s", msg);
49}
50
51/**********************************************************************/
54static 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,
57 const char *notes)
58{
59 const char *type_str;
60 const char *lic_str;
61 const char *inst_str;
62
65 } else {
66 /* TRANS: Unknown modpack type */
67 type_str = _("?");
68 }
69
70 if (license != NULL) {
72 } else {
73 /* TRANS: License of modpack is not known */
74 lic_str = Q_("?license:Unknown");
75 }
76
78 if (inst_str == NULL) {
79 inst_str = _("Not installed");
80 }
81
82 log_normal("%s", "");
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);
89 if (notes != NULL) {
90 log_normal(_("Comment=\"%s\""), notes);
91 }
92}
93
94/**********************************************************************/
97int main(int argc, char *argv[])
98{
99 int ui_options;
100
101 fcmp_init();
102
103 /* This modifies argv! */
105
106 if (ui_options != -1) {
107 int i;
108
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"));
113
114 /* TRANS: No full stop after the URL, could cause confusion. */
115 fc_fprintf(stderr, _("Report bugs at %s\n"), BUG_URL);
116
117 ui_options = -1;
118 } else {
119 log_error(_("Unknown option '--' '%s'"), argv[i]);
120 ui_options = -1;
121 }
122 }
123 }
124
125 if (ui_options != -1) {
126 const char *rev_ver;
127
129
130 log_normal(_("Freeciv modpack installer (command line version)"));
131
133
135 if (rev_ver != NULL) {
136 log_normal(_("commit: %s"), rev_ver);
137 }
138
139 log_normal("%s", "");
140
141 if (fcmp.autoinstall == NULL) {
143 } else {
144 const char *errmsg;
145
147
148 if (errmsg == NULL) {
149 log_normal(_("Modpack installed successfully"));
150 } else {
151 log_error(_("Modpack install failed: %s"), errmsg);
152 }
153 }
154
155 close_mpdbs();
156 }
157
158 fcmp_deinit();
160
161 return EXIT_SUCCESS;
162}
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
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:97
struct fcmp_params fcmp
Definition mpcli.c:37
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:54
static void msg_callback(const char *msg)
Definition mpcli.c:46
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