Changeset 24b8bbb for lib


Ignore:
Timestamp:
2010-04-12T00:06:49Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
89c11e7
Parents:
e21c0f8
Message:

Start handling CTCPs, in a saner way than before.

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/misc.c

    re21c0f8 r24b8bbb  
    614614        return ret;
    615615}
     616
     617char **split_command_parts( char *command )
     618{
     619        static char *cmd[IRC_MAX_ARGS+1];
     620        char *s, q = 0;
     621        int k;
     622       
     623        memset( cmd, 0, sizeof( cmd ) );
     624        cmd[0] = command;
     625        k = 1;
     626        for( s = command; *s && k < IRC_MAX_ARGS; s ++ )
     627                if( *s == ' ' && !q )
     628                {
     629                        *s = 0;
     630                        while( *++s == ' ' );
     631                        if( *s == '"' || *s == '\'' )
     632                        {
     633                                q = *s;
     634                                s ++;
     635                        }
     636                        if( *s )
     637                        {
     638                                cmd[k++] = s;
     639                                s --;
     640                        }
     641                        else
     642                        {
     643                                break;
     644                        }
     645                }
     646                else if( *s == '\\' && ( ( !q && s[1] ) || ( q && q == s[1] ) ) )
     647                {
     648                        char *cpy;
     649                       
     650                        for( cpy = s; *cpy; cpy ++ )
     651                                cpy[0] = cpy[1];
     652                }
     653                else if( *s == q )
     654                {
     655                        q = *s = 0;
     656                }
     657        cmd[k] = NULL;
     658       
     659        return cmd;
     660}
  • lib/misc.h

    re21c0f8 r24b8bbb  
    6868G_MODULE_EXPORT int md5_verify_password( char *password, char *hash );
    6969
     70G_MODULE_EXPORT char **split_command_parts( char *command );
     71
    7072#endif
Note: See TracChangeset for help on using the changeset viewer.