• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/tools/perf/util/ui/
1#define _GNU_SOURCE
2#include <stdio.h>
3#include <stdlib.h>
4#include <newt.h>
5
6#include "../debug.h"
7#include "helpline.h"
8
9void ui_helpline__pop(void)
10{
11	newtPopHelpLine();
12}
13
14void ui_helpline__push(const char *msg)
15{
16	newtPushHelpLine(msg);
17}
18
19void ui_helpline__vpush(const char *fmt, va_list ap)
20{
21	char *s;
22
23	if (vasprintf(&s, fmt, ap) < 0)
24		vfprintf(stderr, fmt, ap);
25	else {
26		ui_helpline__push(s);
27		free(s);
28	}
29}
30
31void ui_helpline__fpush(const char *fmt, ...)
32{
33	va_list ap;
34
35	va_start(ap, fmt);
36	ui_helpline__vpush(fmt, ap);
37	va_end(ap);
38}
39
40void ui_helpline__puts(const char *msg)
41{
42	ui_helpline__pop();
43	ui_helpline__push(msg);
44}
45
46void ui_helpline__init(void)
47{
48	ui_helpline__puts(" ");
49}
50
51char ui_helpline__last_msg[1024];
52
53int ui_helpline__show_help(const char *format, va_list ap)
54{
55	int ret;
56	static int backlog;
57
58        ret = vsnprintf(ui_helpline__last_msg + backlog,
59			sizeof(ui_helpline__last_msg) - backlog, format, ap);
60	backlog += ret;
61
62	if (ui_helpline__last_msg[backlog - 1] == '\n') {
63		ui_helpline__puts(ui_helpline__last_msg);
64		newtRefresh();
65		backlog = 0;
66	}
67
68	return ret;
69}
70