Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osdd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
osdd
Commits
f3b7c40f
Commit
f3b7c40f
authored
4 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Added --to=stdout option.
parent
2f655e73
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README
+2
-0
2 additions, 0 deletions
README
osdd.c
+83
-6
83 additions, 6 deletions
osdd.c
util.h
+1
-1
1 addition, 1 deletion
util.h
with
86 additions
and
7 deletions
README
+
2
−
0
View file @
f3b7c40f
...
...
@@ -51,6 +51,8 @@ You can also add attributes to the message (written as command-line options):
--slider=p Draw a line with a slider (p=0..100)
--to=stdout Write message to stdout instead of display.
The default values of most of these attributes can be given by command-line
options of the daemon, use `osdd --help' to get the full list.
...
...
This diff is collapsed.
Click to expand it.
osdd.c
+
83
−
6
View file @
f3b7c40f
...
...
@@ -178,7 +178,6 @@ display_msg(struct msg *msg)
outline_color
=
val
;
else
if
(
!
strcmp
(
key
,
"outline-width"
))
outline_width
=
atoi
(
val
);
if
(
l
)
{
l
->
fg_color
=
fg_color
;
...
...
@@ -195,6 +194,44 @@ display_msg(struct msg *msg)
osd_show
(
osd
);
}
static
void
msg_to_stdout
(
struct
msg
*
msg
)
{
DBG
(
"## Printing message to stdout
\n
"
);
char
*
line
=
msg
->
text
;
int
out_parametr_index
=
0
;
while
(
*
line
)
{
// The parser it destructive, but it does not do any harm, since we display each message only once.
char
*
nl
=
strchr
(
line
,
'\n'
);
*
nl
++
=
0
;
char
*
key
;
char
*
val
=
strchr
(
line
,
':'
);
if
(
val
)
{
key
=
line
;
*
val
++
=
0
;
}
else
{
key
=
""
;
val
=
line
;
}
DBG
(
"
\t
%s:%s
\n
"
,
key
,
val
);
if
(
!
key
[
0
])
{
printf
(
out_parametr_index
++?
" %s"
:
"%s"
,
val
);
}
line
=
nl
;
}
printf
(
"
\n
"
);
fflush
(
stdout
);
}
static
void
hide_msg
(
struct
msg
*
msg
)
{
...
...
@@ -218,6 +255,45 @@ enqueue_msg(unsigned char *buf, int len)
memcpy
(
msg
->
text
,
buf
,
len
);
msg
->
text
[
len
]
=
0
;
char
to
[
123
];
*
to
=
0
;
char
*
line
=
msg
->
text
;
while
(
*
line
)
{
char
*
nl
=
strchr
(
line
,
'\n'
);
*
nl
++=
0
;
char
*
key
;
char
*
val
=
strchr
(
line
,
':'
);
if
(
val
)
{
key
=
line
;
*
val
++
=
0
;
}
else
{
key
=
""
;
val
=
line
;
}
DBG
(
"
\t
%s:%s
\n
"
,
key
,
val
);
if
(
!
strcmp
(
key
,
"to"
))
{
if
(
strlen
(
val
)
<
120
)
strcpy
(
to
,
val
);
}
val
[
-
1
]
=
':'
;
nl
[
-
1
]
=
10
;
line
=
nl
;
}
if
(
!
strcmp
(
to
,
"stdout"
))
{
msg_to_stdout
(
msg
);
}
else
{
if
(
first_msg
)
last_msg
->
next
=
msg
;
else
...
...
@@ -225,6 +301,7 @@ enqueue_msg(unsigned char *buf, int len)
last_msg
=
msg
;
msg
->
next
=
NULL
;
}
}
static
void
parse_input
(
unsigned
char
*
buf
,
int
len
)
...
...
This diff is collapsed.
Click to expand it.
util.h
+
1
−
1
View file @
f3b7c40f
...
...
@@ -16,7 +16,7 @@ typedef uint64_t timestamp_t;
void
NONRET
FORMAT_CHECK
(
printf
,
1
,
2
)
die
(
char
*
fmt
,
...);
#ifdef DEBUG
#define DBG(f...) printf(f)
#define DBG(f...)
f
printf(
stderr,
f)
#else
#define DBG(f...) do { } while(0)
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment