本文整理汇总了C++中pager_open函数的典型用法代码示例。如果您正苦于以下问题:C++ pager_open函数的具体用法?C++ pager_open怎么用?C++ pager_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pager_open函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: command_lskern
int
command_lskern(int argc, char *argv[])
{
struct preloaded_file *fp;
char lbuf[80];
int ch, verbose;
verbose = 0;
optind = 1;
optreset = 1;
pager_open();
for (fp = preloaded_files; fp; fp = fp->f_next) {
snprintf(lbuf, sizeof(lbuf), " %p: %s (%s, 0x%lx)\n",
(void *) fp->f_addr, fp->f_name, fp->f_type, (long) fp->f_size);
pager_output(lbuf);
if (fp->f_args != NULL) {
pager_output(" args: ");
pager_output(fp->f_args);
pager_output("\n");
}
}
pager_close();
return(CMD_OK);
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:25,代码来源:fileload.c
示例2: list_timezones
static int list_timezones(int argc, char **argv, void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
int r;
char** zones;
r = sd_bus_call_method(bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
"ListTimezones",
&error,
&reply,
NULL);
if (r < 0)
return log_error_errno(r, "Failed to request list of time zones: %s",
bus_error_message(&error, r));
r = sd_bus_message_read_strv(reply, &zones);
if (r < 0)
return bus_log_parse_error(r);
(void) pager_open(arg_pager_flags);
strv_print(zones);
return 0;
}
开发者ID:clemensg,项目名称:systemd,代码行数:28,代码来源:timedatectl.c
示例3: efipart_print
static void
efipart_print(int verbose)
{
char line[80];
EFI_BLOCK_IO *blkio;
EFI_HANDLE h;
EFI_STATUS status;
u_int unit;
pager_open();
for (unit = 0, h = efi_find_handle(&efipart_dev, 0);
h != NULL; h = efi_find_handle(&efipart_dev, ++unit)) {
sprintf(line, " %s%d:", efipart_dev.dv_name, unit);
if (pager_output(line))
break;
status = BS->HandleProtocol(h, &blkio_guid, (void **)&blkio);
if (!EFI_ERROR(status)) {
sprintf(line, " %llu blocks",
(unsigned long long)(blkio->Media->LastBlock + 1));
if (pager_output(line))
break;
if (blkio->Media->RemovableMedia)
if (pager_output(" (removable)"))
break;
}
if (pager_output("\n"))
break;
}
pager_close();
}
开发者ID:2asoft,项目名称:freebsd,代码行数:31,代码来源:efipart.c
示例4: pager_open_if_enabled
static void pager_open_if_enabled(void) {
if (arg_no_pager)
return;
pager_open(false);
}
开发者ID:ringlej,项目名称:systemd,代码行数:7,代码来源:networkctl.c
示例5: pager_open_if_enabled
static void pager_open_if_enabled(void) {
/* Cache result before we open the pager */
if (arg_no_pager)
return;
pager_open(false);
}
开发者ID:klausi,项目名称:systemd,代码行数:8,代码来源:busctl.c
示例6: list_timezones
static int list_timezones(int argc, char **argv, void *userdata) {
_cleanup_strv_free_ char **zones = NULL;
int r;
r = get_timezones(&zones);
if (r < 0)
return log_error_errno(r, "Failed to read list of time zones: %m");
(void) pager_open(arg_no_pager, false);
strv_print(zones);
return 0;
}
开发者ID:davide125,项目名称:systemd,代码行数:13,代码来源:timedatectl.c
示例7: list_vconsole_keymaps
static int list_vconsole_keymaps(int argc, char **argv, void *userdata) {
_cleanup_strv_free_ char **l = NULL;
int r;
r = get_keymaps(&l);
if (r < 0)
return log_error_errno(r, "Failed to read list of keymaps: %m");
(void) pager_open(arg_no_pager, false);
strv_print(l);
return 0;
}
开发者ID:halfline,项目名称:systemd,代码行数:14,代码来源:localectl.c
示例8: main
int main(int argc, char *argv[]) {
int r, k;
r = parse_argv(argc, argv);
if (r <= 0)
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
umask(0022);
r = 0;
if (argc > optind) {
int i;
for (i = optind; i < argc; i++) {
k = apply_file(argv[i], false);
if (k < 0 && r == 0)
r = k;
}
} else {
_cleanup_strv_free_ char **files = NULL;
char **f;
r = conf_files_list_strv(&files, ".conf", NULL, 0, (const char**) CONF_PATHS_STRV("binfmt.d"));
if (r < 0) {
log_error_errno(r, "Failed to enumerate binfmt.d files: %m");
goto finish;
}
if (arg_cat_config) {
(void) pager_open(arg_no_pager, false);
r = cat_files(NULL, files, 0);
goto finish;
}
/* Flush out all rules */
write_string_file("/proc/sys/fs/binfmt_misc/status", "-1", 0);
STRV_FOREACH(f, files) {
k = apply_file(*f, true);
if (k < 0 && r == 0)
r = k;
}
}
开发者ID:Hariprasathganesh,项目名称:testsysd,代码行数:49,代码来源:binfmt.c
示例9: command_configuration
static int
command_configuration(int argc, char *argv[])
{
char line[80];
UINTN i;
snprintf(line, sizeof(line), "NumberOfTableEntries=%lu\n",
(unsigned long)ST->NumberOfTableEntries);
pager_open();
if (pager_output(line)) {
pager_close();
return (CMD_OK);
}
for (i = 0; i < ST->NumberOfTableEntries; i++) {
EFI_GUID *guid;
printf(" ");
guid = &ST->ConfigurationTable[i].VendorGuid;
if (!memcmp(guid, &mps, sizeof(EFI_GUID)))
printf("MPS Table");
else if (!memcmp(guid, &acpi, sizeof(EFI_GUID)))
printf("ACPI Table");
else if (!memcmp(guid, &acpi20, sizeof(EFI_GUID)))
printf("ACPI 2.0 Table");
else if (!memcmp(guid, &smbios, sizeof(EFI_GUID)))
printf("SMBIOS Table %p",
ST->ConfigurationTable[i].VendorTable);
else if (!memcmp(guid, &dxe, sizeof(EFI_GUID)))
printf("DXE Table");
else if (!memcmp(guid, &hoblist, sizeof(EFI_GUID)))
printf("HOB List Table");
else if (!memcmp(guid, &memtype, sizeof(EFI_GUID)))
printf("Memory Type Information Table");
else if (!memcmp(guid, &debugimg, sizeof(EFI_GUID)))
printf("Debug Image Info Table");
else if (!memcmp(guid, &fdtdtb, sizeof(EFI_GUID)))
printf("FDT Table");
else
printf("Unknown Table (%s)", guid_to_string(guid));
snprintf(line, sizeof(line), " at %p\n",
ST->ConfigurationTable[i].VendorTable);
if (pager_output(line))
break;
}
pager_close();
return (CMD_OK);
}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:49,代码来源:main.c
示例10: efinet_dev_print
static void
efinet_dev_print(int verbose)
{
char line[80];
EFI_HANDLE h;
int unit;
pager_open();
for (unit = 0, h = efi_find_handle(&efinet_dev, 0);
h != NULL; h = efi_find_handle(&efinet_dev, ++unit)) {
sprintf(line, " %s%d:\n", efinet_dev.dv_name, unit);
if (pager_output(line))
break;
}
pager_close();
}
开发者ID:tomtor,项目名称:freebsd,代码行数:16,代码来源:efinet.c
示例11: list_timezones
static int list_timezones(sd_bus *bus, char **args, unsigned n) {
_cleanup_strv_free_ char **zones = NULL;
int r;
assert(args);
assert(n == 1);
r = get_timezones(&zones);
if (r < 0)
return log_error_errno(r, "Failed to read list of time zones: %m");
pager_open(arg_no_pager, false);
strv_print(zones);
return 0;
}
开发者ID:GuillaumeSeren,项目名称:systemd,代码行数:16,代码来源:timedatectl.c
示例12: command_lsmod
static int
command_lsmod(int argc, char *argv[])
{
struct loaded_module *am;
struct module_metadata *md;
char lbuf[80];
int ch, verbose;
verbose = 0;
optind = 1;
optreset = 1;
while ((ch = getopt(argc, argv, "v")) != -1) {
switch(ch) {
case 'v':
verbose = 1;
break;
case '?':
default:
/* getopt has already reported an error */
return(CMD_OK);
}
}
pager_open();
for (am = loaded_modules; (am != NULL); am = am->m_next) {
sprintf(lbuf, " %p: %s (%s, 0x%lx)\n",
(void *) am->m_addr, am->m_name, am->m_type, (long) am->m_size);
pager_output(lbuf);
if (am->m_args != NULL) {
pager_output(" args: ");
pager_output(am->m_args);
pager_output("\n");
}
if (verbose)
/* XXX could add some formatting smarts here to display some better */
for (md = am->m_metadata; md != NULL; md = md->md_next) {
sprintf(lbuf, " 0x%04x, 0x%lx\n", md->md_type, (long) md->md_size);
pager_output(lbuf);
}
}
pager_close();
return(CMD_OK);
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:43,代码来源:module.c
示例13: efinet_dev_print
static void
efinet_dev_print(int verbose)
{
CHAR16 *text;
EFI_HANDLE h;
int unit;
pager_open();
for (unit = 0, h = efi_find_handle(&efinet_dev, 0);
h != NULL; h = efi_find_handle(&efinet_dev, ++unit)) {
printf(" %s%d:", efinet_dev.dv_name, unit);
text = efi_devpath_name(efi_lookup_devpath(h));
if (text != NULL) {
printf(" %S", text);
efi_free_devpath_name(text);
}
if (pager_output("\n"))
break;
}
pager_close();
}
开发者ID:2asoft,项目名称:freebsd,代码行数:21,代码来源:efinet.c
示例14: command_commandlist
/*
* Please note: although we use the pager for the list of commands,
* this routine is called from the ? FORTH function which then
* unconditionally prints some commands. This will lead to anomalous
* behavior. There's no 'pager_output' binding to FORTH to allow
* things to work right, so I'm documenting the bug rather than
* fixing it.
*/
static int
command_commandlist(int argc, char *argv[])
{
struct bootblk_command **cmdp;
int res;
char name[20];
res = 0;
pager_open();
res = pager_output("Available commands:\n");
SET_FOREACH(cmdp, Xcommand_set) {
if (res)
break;
if (((*cmdp)->c_name != NULL) && ((*cmdp)->c_desc != NULL)) {
sprintf(name, " %-15s ", (*cmdp)->c_name);
pager_output(name);
pager_output((*cmdp)->c_desc);
res = pager_output("\n");
}
}
pager_close();
return(CMD_OK);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:31,代码来源:commands.c
示例15: hexdump
/*
* Display a region in traditional hexdump format.
*/
void
hexdump(caddr_t region, size_t len)
{
caddr_t line;
int x, c;
char lbuf[80];
#define emit(fmt, args...) {sprintf(lbuf, fmt , ## args); pager_output(lbuf);}
pager_open();
for (line = region; line < (region + len); line += 16) {
emit("%08lx ", (long) line);
for (x = 0; x < 16; x++) {
if ((line + x) < (region + len)) {
emit("%02x ", *(u_int8_t *)(line + x));
} else {
emit("-- ");
}
if (x == 7)
emit(" ");
}
emit(" |");
for (x = 0; x < 16; x++) {
if ((line + x) < (region + len)) {
c = *(u_int8_t *)(line + x);
if ((c < ' ') || (c > '~')) /* !isprint(c) */
c = '.';
emit("%c", c);
} else {
emit(" ");
}
}
emit("|\n");
}
pager_close();
}
开发者ID:oza,项目名称:FreeBSD-7.3-dyntick,代码行数:39,代码来源:misc.c
示例16: main
int main(int argc, char *argv[]) {
const char prefixes[] =
"/etc\0"
"/run\0"
"/usr/local/lib\0"
"/usr/local/share\0"
"/usr/lib\0"
"/usr/share\0"
#ifdef HAVE_SPLIT_USR
"/lib\0"
#endif
;
const char suffixes[] =
"sysctl.d\0"
"tmpfiles.d\0"
"modules-load.d\0"
"binfmt.d\0"
"systemd/system\0"
"systemd/user\0"
"systemd/system-preset\0"
"systemd/user-preset\0"
"udev/rules.d\0"
"modprobe.d\0";
int r = 0, k;
int n_found = 0;
log_parse_environment();
log_open();
r = parse_argv(argc, argv);
if (r <= 0)
goto finish;
if (arg_flags == 0)
arg_flags = SHOW_DEFAULTS;
if (arg_diff < 0)
arg_diff = !!(arg_flags & SHOW_OVERRIDDEN);
else if (arg_diff)
arg_flags |= SHOW_OVERRIDDEN;
if (!arg_no_pager)
pager_open();
if (optind < argc) {
int i;
for (i = optind; i < argc; i++) {
k = process_suffix_chop(prefixes, argv[i]);
if (k < 0)
r = k;
else
n_found += k;
}
} else {
const char *n;
NULSTR_FOREACH(n, suffixes) {
k = process_suffix(prefixes, n);
if (k < 0)
r = k;
else
n_found += k;
}
}
开发者ID:RoadRunnr,项目名称:systemd,代码行数:69,代码来源:delta.c
示例17: main
int main(int argc, char *argv[]) {
int r, output_flags;
log_parse_environment();
log_open();
r = parse_argv(argc, argv);
if (r <= 0)
goto finish;
if (!arg_no_pager) {
r = pager_open(false);
if (r > 0 && arg_full < 0)
arg_full = true;
}
output_flags =
arg_all * OUTPUT_SHOW_ALL |
(arg_full > 0) * OUTPUT_FULL_WIDTH;
if (optind < argc) {
_cleanup_free_ char *root = NULL;
int i;
r = get_cgroup_root(&root);
if (r < 0)
goto finish;
for (i = optind; i < argc; i++) {
int q;
if (path_startswith(argv[i], "/sys/fs/cgroup")) {
printf("Directory %s:\n", argv[i]);
fflush(stdout);
q = show_cgroup_by_path(argv[i], NULL, 0, arg_kernel_threads, output_flags);
} else {
_cleanup_free_ char *c = NULL, *p = NULL, *j = NULL;
const char *controller, *path;
r = cg_split_spec(argv[i], &c, &p);
if (r < 0) {
log_error_errno(r, "Failed to split argument %s: %m", argv[i]);
goto finish;
}
controller = c ?: SYSTEMD_CGROUP_CONTROLLER;
if (p) {
j = strjoin(root, "/", p, NULL);
if (!j) {
r = log_oom();
goto finish;
}
path_kill_slashes(j);
path = j;
} else
path = root;
show_cg_info(controller, path);
q = show_cgroup(controller, path, NULL, 0, arg_kernel_threads, output_flags);
}
if (q < 0)
r = q;
}
} else {
开发者ID:michich,项目名称:systemd,代码行数:70,代码来源:cgls.c
示例18: main
int main(int argc, char *argv[]) {
int r = 0, retval = EXIT_FAILURE;
int output_flags;
log_parse_environment();
log_open();
r = parse_argv(argc, argv);
if (r < 0)
goto finish;
else if (r == 0) {
retval = EXIT_SUCCESS;
goto finish;
}
if (!arg_no_pager) {
r = pager_open(false);
if (r > 0) {
if (arg_full == -1)
arg_full = true;
}
}
output_flags =
arg_all * OUTPUT_SHOW_ALL |
(arg_full > 0) * OUTPUT_FULL_WIDTH;
if (optind < argc) {
unsigned i;
for (i = (unsigned) optind; i < (unsigned) argc; i++) {
int q;
printf("%s:\n", argv[i]);
q = show_cgroup_by_path(argv[i], NULL, 0,
arg_kernel_threads, output_flags);
if (q < 0)
r = q;
}
} else {
char _cleanup_free_ *p;
p = get_current_dir_name();
if (!p) {
log_error("Cannot determine current working directory: %m");
goto finish;
}
if (path_startswith(p, "/sys/fs/cgroup")) {
printf("Working Directory %s:\n", p);
r = show_cgroup_by_path(p, NULL, 0,
arg_kernel_threads, output_flags);
} else {
char _cleanup_free_ *root = NULL;
const char *t = NULL;
r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 1, &root);
if (r < 0)
t = "/";
else {
if (endswith(root, "/system"))
root[strlen(root)-7] = 0;
t = root[0] ? root : "/";
}
r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, t, NULL, 0,
arg_kernel_threads, output_flags);
}
}
if (r < 0)
log_error("Failed to list cgroup tree: %s", strerror(-r));
retval = EXIT_SUCCESS;
finish:
pager_close();
return retval;
}
开发者ID:banada,项目名称:systemd,代码行数:82,代码来源:cgls.c
示例19: inspect_image
static int inspect_image(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_strv_free_ char **matches = NULL;
_cleanup_free_ char *image = NULL;
bool nl = false, header = false;
const void *data;
const char *path;
size_t sz;
int r;
r = determine_image(argv[1], false, &image);
if (r < 0)
return r;
r = determine_matches(argv[1], argv + 2, true, &matches);
if (r < 0)
return r;
r = acquire_bus(&bus);
if (r < 0)
return r;
r = sd_bus_message_new_method_call(
bus,
&m,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"GetImageMetadata");
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_message_append(m, "s", image);
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_message_append_strv(m, matches);
if (r < 0)
return bus_log_create_error(r);
r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0)
return log_error_errno(r, "Failed to inspect image metadata: %s", bus_error_message(&error, r));
r = sd_bus_message_read(reply, "s", &path);
if (r < 0)
return bus_log_parse_error(r);
r = sd_bus_message_read_array(reply, 'y', &data, &sz);
if (r < 0)
return bus_log_parse_error(r);
(void) pager_open(arg_pager_flags);
if (arg_cat) {
printf("%s-- OS Release: --%s\n", ansi_highlight(), ansi_normal());
fwrite(data, sz, 1, stdout);
fflush(stdout);
nl = true;
} else {
_cleanup_free_ char *pretty_portable = NULL, *pretty_os = NULL;
_cleanup_fclose_ FILE *f;
f = fmemopen_unlocked((void*) data, sz, "re");
if (!f)
return log_error_errno(errno, "Failed to open /etc/os-release buffer: %m");
r = parse_env_file(f, "/etc/os-release",
"PORTABLE_PRETTY_NAME", &pretty_portable,
"PRETTY_NAME", &pretty_os);
if (r < 0)
return log_error_errno(r, "Failed to parse /etc/os-release: %m");
printf("Image:\n\t%s\n"
"Portable Service:\n\t%s\n"
"Operating System:\n\t%s\n",
path,
strna(pretty_portable),
strna(pretty_os));
}
r = sd_bus_message_enter_container(reply, 'a', "{say}");
if (r < 0)
return bus_log_parse_error(r);
for (;;) {
const char *name;
r = sd_bus_message_enter_container(reply, 'e', "say");
if (r < 0)
return bus_log_parse_error(r);
if (r == 0)
break;
r = sd_bus_message_read(reply, "s", &name);
if (r < 0)
return bus_log_parse_error(r);
//.........这里部分代码省略.........
开发者ID:l10n-tw,项目名称:systemd,代码行数:101,代码来源:portablectl.c
示例20: main
int main(int argc, char *argv[]) {
int r = 0, retval = EXIT_FAILURE;
int output_flags;
_cleanup_free_ char *root = NULL;
_cleanup_bus_close_unref_ sd_bus *bus = NULL;
log_parse_environment();
log_open();
r = parse_argv(argc, argv);
if (r < 0)
goto finish;
else if (r == 0) {
retval = EXIT_SUCCESS;
goto finish;
}
if (!arg_no_pager) {
r = pager_open(false);
if (r > 0) {
if (arg_full == -1)
arg_full = true;
}
}
output_flags =
arg_all * OUTPUT_SHOW_ALL |
(arg_full > 0) * OUTPUT_FULL_WIDTH;
r = bus_open_transport(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
if (r < 0) {
log_error_errno(r, "Failed to create bus connection: %m");
goto finish;
}
if (optind < argc) {
int i;
for (i = optind; i < argc; i++) {
int q;
fprintf(stdout, "%s:\n", argv[i]);
fflush(stdout);
if (arg_machine)
root = strjoin("machine/", arg_machine, "/", argv[i], NULL);
else
root = strdup(argv[i]);
if (!root)
return log_oom();
q = show_cgroup_by_path(root, NULL, 0,
arg_kernel_threads, output_flags);
if (q < 0)
r = q;
}
} else {
_cleanup_free_ char *p;
p = get_current_dir_name();
if (!p) {
log_error_errno(errno, "Cannot determine current working directory: %m");
goto finish;
}
if (path_startswith(p, "/sys/fs/cgroup") && !arg_machine) {
printf("Working Directory %s:\n", p);
r = show_cgroup_by_path(p, NULL, 0,
arg_kernel_threads, output_flags);
} else {
if (arg_machine) {
char *m;
const char *cgroup;
_cleanup_free_ char *scope = NULL;
_cleanup_free_ char *path = NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
m = strjoina("/run/systemd/machines/", arg_machine);
r = parse_env_file(m, NEWLINE, "SCOPE", &scope, NULL);
if (r < 0) {
log_error_errno(r, "Failed to get machine path: %m");
goto finish;
}
path = unit_dbus_path_from_name(scope);
if (!path) {
log_oom();
goto finish;
}
r = sd_bus_get_property(
bus,
"org.freedesktop.systemd1",
path,
"org.freedesktop.systemd1.Scope",
"ControlGroup",
&error,
&reply,
//.........这里部分代码省略.........
开发者ID:AlexBaranosky,项目名称:systemd,代码行数:101,代码来源:cgls.c
注:本文中的pager_open函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论