diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-04-12 02:06:49 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-04-12 02:06:49 +0200 |
commit | 24b8bbb2616d685006a279e46a4bd2e8e7cf6694 (patch) | |
tree | c585d428a08bdd8c7f22b1fdef8e65d758f60d6e /lib/misc.c | |
parent | e21c0f8b276cc3ca177bcf6217eba9c634d410f7 (diff) |
Start handling CTCPs, in a saner way than before.
Diffstat (limited to 'lib/misc.c')
-rw-r--r-- | lib/misc.c | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -613,3 +613,48 @@ int md5_verify_password( char *password, char *hash ) return ret; } + +char **split_command_parts( char *command ) +{ + static char *cmd[IRC_MAX_ARGS+1]; + char *s, q = 0; + int k; + + memset( cmd, 0, sizeof( cmd ) ); + cmd[0] = command; + k = 1; + for( s = command; *s && k < IRC_MAX_ARGS; s ++ ) + if( *s == ' ' && !q ) + { + *s = 0; + while( *++s == ' ' ); + if( *s == '"' || *s == '\'' ) + { + q = *s; + s ++; + } + if( *s ) + { + cmd[k++] = s; + s --; + } + else + { + break; + } + } + else if( *s == '\\' && ( ( !q && s[1] ) || ( q && q == s[1] ) ) ) + { + char *cpy; + + for( cpy = s; *cpy; cpy ++ ) + cpy[0] = cpy[1]; + } + else if( *s == q ) + { + q = *s = 0; + } + cmd[k] = NULL; + + return cmd; +} |