summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2020-08-20 07:02:25 -0400
committerAndrew Cady <d@jerkface.net>2020-08-20 16:29:56 -0400
commit930eda72be5ee1f3b61aa2ea6280eacd8fe01b36 (patch)
tree4595e7a81a016167c49d8033f14a1d2a6e947406
parentd2345a8a2f28aed7722cbd76cc3f03543db90bbd (diff)
improve parsing
-rw-r--r--util.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/util.c b/util.c
index 01fbe65..0084c19 100644
--- a/util.c
+++ b/util.c
@@ -90,17 +90,11 @@ int parse_local_port_forward(char *string, int *local_port, char **hostname, int
90 char *host; 90 char *host;
91 char *rport; 91 char *rport;
92 92
93 /* First replace all @ with :, ':' is forbidden in some environments */ 93 /* Alternative delimiter '@', as ':' is forbidden in some environments */
94 char *p = string;
95 while(*p)
96 {
97 if(*p == '@') *p = ':';
98 p++;
99 }
100 94
101 lport = strtok(string, ":"); 95 lport = strtok(string, ":@");
102 host = strtok(NULL, ":"); 96 host = strtok(NULL, ":@");
103 rport = strtok(NULL, ":"); 97 rport = strtok(NULL, ":@");
104 98
105 if(!lport || !host || !rport) 99 if(!lport || !host || !rport)
106 { 100 {
@@ -121,16 +115,10 @@ int parse_pipe_port_forward(char *string, char **hostname, int *remote_port)
121 char *host; 115 char *host;
122 char *rport; 116 char *rport;
123 117
124 /* First replace all @ with :, ':' is forbidden in some environments */ 118 /* Alternative delimiter '@', as ':' is forbidden in some environments */
125 char *p = string;
126 while(*p)
127 {
128 if(*p == '@') *p = ':';
129 p++;
130 }
131 119
132 host = strtok(string, ":"); 120 host = strtok(string, ":@");
133 rport = strtok(NULL, ":"); 121 rport = strtok(NULL, ":@");
134 122
135 if(!host || !rport) 123 if(!host || !rport)
136 { 124 {