mirror of
https://github.com/swaywm/sway.git
synced 2025-10-31 22:25:26 -04:00
swaybar: rewrite protocol determination
This now uses the getline function to receive the header, replacing read_line_buffer, which has been deleted since it is otherwise unused. Furthermore, once the protocol has been determined, the current status is handled immediately to be shown (though this has not been added for the i3bar protocol since it has not yet been rewritten to handle this).
This commit is contained in:
parent
70245c2cd5
commit
8cbce77e1d
2 changed files with 33 additions and 56 deletions
|
|
@ -70,28 +70,3 @@ char *peek_line(FILE *file, int line_offset, long *position) {
|
|||
fseek(file, pos, SEEK_SET);
|
||||
return line;
|
||||
}
|
||||
|
||||
char *read_line_buffer(FILE *file, char *string, size_t string_len) {
|
||||
size_t length = 0;
|
||||
if (!string) {
|
||||
return NULL;
|
||||
}
|
||||
while (1) {
|
||||
int c = getc(file);
|
||||
if (c == EOF || c == '\n' || c == '\0') {
|
||||
break;
|
||||
}
|
||||
if (c == '\r') {
|
||||
continue;
|
||||
}
|
||||
string[length++] = c;
|
||||
if (string_len <= length) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (length + 1 == string_len) {
|
||||
return NULL;
|
||||
}
|
||||
string[length] = '\0';
|
||||
return string;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue