aboutsummaryrefslogtreecommitdiffstats
path: root/common/ipc-client.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-12-09 12:09:11 +0000
committerLibravatar Ian Fan <ianfan0@gmail.com>2019-01-01 09:01:25 +0000
commita82b8a3c14e45697708e57f8cb27a8fc6cf31839 (patch)
tree5e30327566fb6f30bd6d319f7b8a96226683e986 /common/ipc-client.c
parentstringop.c: rewrite strip_whitespace (diff)
downloadsway-a82b8a3c14e45697708e57f8cb27a8fc6cf31839.tar.gz
sway-a82b8a3c14e45697708e57f8cb27a8fc6cf31839.tar.zst
sway-a82b8a3c14e45697708e57f8cb27a8fc6cf31839.zip
Remove readline.c
All occurrences of read_line have been replaced by getline. peek_line has been absorbed into detect_brace.
Diffstat (limited to 'common/ipc-client.c')
-rw-r--r--common/ipc-client.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/common/ipc-client.c b/common/ipc-client.c
index 496fd131..3515ef0a 100644
--- a/common/ipc-client.c
+++ b/common/ipc-client.c
@@ -7,7 +7,6 @@
7#include <sys/un.h> 7#include <sys/un.h>
8#include <unistd.h> 8#include <unistd.h>
9#include "ipc-client.h" 9#include "ipc-client.h"
10#include "readline.h"
11#include "log.h" 10#include "log.h"
12 11
13static const char ipc_magic[] = {'i', '3', '-', 'i', 'p', 'c'}; 12static const char ipc_magic[] = {'i', '3', '-', 'i', 'p', 'c'};
@@ -18,28 +17,30 @@ char *get_socketpath(void) {
18 if (swaysock) { 17 if (swaysock) {
19 return strdup(swaysock); 18 return strdup(swaysock);
20 } 19 }
20 char *line = NULL;
21 size_t line_size = 0;
21 FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r"); 22 FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r");
22 if (fp) { 23 if (fp) {
23 char *line = read_line(fp); 24 getline(&line, &line_size, fp);
24 pclose(fp); 25 pclose(fp);
25 if (line && *line) { 26 if (line && *line) {
26 return line; 27 return line;
27 } 28 }
28 free(line);
29 } 29 }
30 const char *i3sock = getenv("I3SOCK"); 30 const char *i3sock = getenv("I3SOCK");
31 if (i3sock) { 31 if (i3sock) {
32 free(line);
32 return strdup(i3sock); 33 return strdup(i3sock);
33 } 34 }
34 fp = popen("i3 --get-socketpath 2>/dev/null", "r"); 35 fp = popen("i3 --get-socketpath 2>/dev/null", "r");
35 if (fp) { 36 if (fp) {
36 char *line = read_line(fp); 37 getline(&line, &line_size, fp);
37 pclose(fp); 38 pclose(fp);
38 if (line && *line) { 39 if (line && *line) {
39 return line; 40 return line;
40 } 41 }
41 free(line);
42 } 42 }
43 free(line);
43 return NULL; 44 return NULL;
44} 45}
45 46