Lines Matching +full:c +full:- +full:version +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0
3 * builtin-help.c
11 #include <subcmd/exec-cmd.h>
12 #include "common-cmds.h"
13 #include <subcmd/parse-options.h>
14 #include <subcmd/run-command.h>
32 char name[0];
38 char name[0];
61 static const char *get_man_viewer_info(const char *name)
65 for (viewer = man_viewer_info_list; viewer; viewer = viewer->next) {
66 if (!strcasecmp(name, viewer->name))
67 return viewer->info;
76 const char *argv_ec[] = { "emacsclient", "--version", NULL };
77 int version;
78 int ret = -1;
80 /* emacsclient prints its version number on stderr */
83 ec_process.err = -1;
87 return -1;
90 fprintf(stderr, "Failed to read emacsclient version\n");
96 * Don't bother checking return value, because "emacsclient --version"
102 fprintf(stderr, "Failed to parse emacsclient version.\n");
106 version = atoi(buffer.buf + strlen("emacsclient"));
108 if (version < 22) {
110 "emacsclient version '%d' too old (< 22).\n",
111 version);
128 /* This works only with emacsclient version >= 22. */
134 execlp(path, "emacsclient", "-e", man_page, NULL);
185 execl("/bin/sh", "sh", "-c", shell_cmd, NULL);
191 static void add_man_viewer(const char *name)
194 size_t len = strlen(name);
197 p = &((*p)->next);
199 strcpy((*p)->name, name);
202 static int supported_man_viewer(const char *name, size_t len)
204 return (!strncasecmp("man", name, len) ||
205 !strncasecmp("woman", name, len) ||
206 !strncasecmp("konqueror", name, len));
209 static void do_add_man_viewer_info(const char *name,
215 strncpy(new->name, name, len);
216 new->info = strdup(value);
217 new->next = man_viewer_info_list;
221 static void unsupported_man_viewer(const char *name, const char *var)
224 "Please consider using 'man.<tool>.%s' instead.", name, var);
227 static int add_man_viewer_path(const char *name,
231 if (supported_man_viewer(name, len))
232 do_add_man_viewer_info(name, len, value);
234 unsupported_man_viewer(name, "cmd");
239 static int add_man_viewer_cmd(const char *name,
243 if (supported_man_viewer(name, len))
244 unsupported_man_viewer(name, "path");
246 do_add_man_viewer_info(name, len, value);
253 const char *name = var + 4;
254 const char *subkey = strrchr(name, '.');
257 pr_err("Config with no key for man viewer: %s", name);
258 return -1;
264 return add_man_viewer_path(name, subkey - name, value);
269 return add_man_viewer_cmd(name, subkey - name, value);
285 return -1;
307 if (longest < strlen(common_cmds[i].name))
308 longest = strlen(common_cmds[i].name);
313 printf(" %-*s ", longest, common_cmds[i].name);
327 return asprintf(&s, "perf-%s", perf_cmd) < 0 ? NULL : s;
337 * system-wide paths after ours to find the manual page. If
347 static void exec_viewer(const char *name, const char *page)
349 const char *info = get_man_viewer_info(name);
351 if (!strcasecmp(name, "man"))
353 else if (!strcasecmp(name, "woman"))
355 else if (!strcasecmp(name, "konqueror"))
360 pr_warning("'%s': unknown man viewer.", name);
370 for (viewer = man_viewer_list; viewer; viewer = viewer->next)
371 exec_viewer(viewer->name, page); /* will return when unable */
378 return -1;
386 return -1;
399 return -1;
406 * If open_html is not defined in a platform-specific way (see for
407 * example compat/mingw.h), we use the script web--browse to display
413 execl_cmd("web--browse", "-c", "help.browser", path, NULL);
423 return -1;
444 "buildid-cache", "buildid-list", "diff", "evlist", "help", "list",
453 "perf help [--all] [--man|--web|--info] [command]",
458 load_command_list("perf-", &main_cmds, &other_cmds);
492 /* fall-through */
494 rc = -1;