diff options
author | Andrew Cady <d@jerkface.net> | 2020-08-20 07:02:25 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-08-20 16:29:56 -0400 |
commit | 930eda72be5ee1f3b61aa2ea6280eacd8fe01b36 (patch) | |
tree | 4595e7a81a016167c49d8033f14a1d2a6e947406 | |
parent | d2345a8a2f28aed7722cbd76cc3f03543db90bbd (diff) |
improve parsing
-rw-r--r-- | util.c | 26 |
1 files changed, 7 insertions, 19 deletions
@@ -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 | { |