diff options
author | GDR! <gdr@gdr.name> | 2015-01-12 22:57:20 +0100 |
---|---|---|
committer | GDR! <gdr@gdr.name> | 2015-01-12 22:57:20 +0100 |
commit | 4350dabf2f524daabb03f26928742296310b456f (patch) | |
tree | d4f10c24d5890e9f0b253f6e884387833046f043 | |
parent | 4e3d5e48fe25648a182dc7f67f4f49e4d8471ebf (diff) |
Allow using @ instead of : in port forward definitions
Useful for SYSTEM in socat
-rw-r--r-- | util.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -89,6 +89,14 @@ int parse_local_port_forward(char *string, int *local_port, char **hostname, int | |||
89 | char *lport; | 89 | char *lport; |
90 | char *host; | 90 | char *host; |
91 | char *rport; | 91 | char *rport; |
92 | |||
93 | /* First replace all @ with :, ':' is forbidden in some environments */ | ||
94 | char *p = string; | ||
95 | while(*p) | ||
96 | { | ||
97 | if(*p == '@') *p = ':'; | ||
98 | p++; | ||
99 | } | ||
92 | 100 | ||
93 | lport = strtok(string, ":"); | 101 | lport = strtok(string, ":"); |
94 | host = strtok(NULL, ":"); | 102 | host = strtok(NULL, ":"); |
@@ -112,6 +120,14 @@ int parse_pipe_port_forward(char *string, char **hostname, int *remote_port) | |||
112 | { | 120 | { |
113 | char *host; | 121 | char *host; |
114 | char *rport; | 122 | char *rport; |
123 | |||
124 | /* First replace all @ with :, ':' is forbidden in some environments */ | ||
125 | char *p = string; | ||
126 | while(*p) | ||
127 | { | ||
128 | if(*p == '@') *p = ':'; | ||
129 | p++; | ||
130 | } | ||
115 | 131 | ||
116 | host = strtok(string, ":"); | 132 | host = strtok(string, ":"); |
117 | rport = strtok(NULL, ":"); | 133 | rport = strtok(NULL, ":"); |