aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-09-17 14:00:44 +0100
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-09-18 11:36:33 +0100
commit8cbce77e1deb811754a6175388e5ef89f274ff05 (patch)
treeb7c3d04dc6a805a657530e0d1d744d66e9402eef /common
parentswaybar: rewrite text protocol handling (diff)
downloadsway-8cbce77e1deb811754a6175388e5ef89f274ff05.tar.gz
sway-8cbce77e1deb811754a6175388e5ef89f274ff05.tar.zst
sway-8cbce77e1deb811754a6175388e5ef89f274ff05.zip
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).
Diffstat (limited to 'common')
-rw-r--r--common/readline.c25
1 files changed, 0 insertions, 25 deletions
diff --git a/common/readline.c b/common/readline.c
index a2c69018..58652429 100644
--- a/common/readline.c
+++ b/common/readline.c
@@ -70,28 +70,3 @@ char *peek_line(FILE *file, int line_offset, long *position) {
70 fseek(file, pos, SEEK_SET); 70 fseek(file, pos, SEEK_SET);
71 return line; 71 return line;
72} 72}
73
74char *read_line_buffer(FILE *file, char *string, size_t string_len) {
75 size_t length = 0;
76 if (!string) {
77 return NULL;
78 }
79 while (1) {
80 int c = getc(file);
81 if (c == EOF || c == '\n' || c == '\0') {
82 break;
83 }
84 if (c == '\r') {
85 continue;
86 }
87 string[length++] = c;
88 if (string_len <= length) {
89 return NULL;
90 }
91 }
92 if (length + 1 == string_len) {
93 return NULL;
94 }
95 string[length] = '\0';
96 return string;
97}