Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int makeAlias( char* user_input )
- {
- unsigned int len, count=0, alias_len, command_len;
- if( (user_input == NULL) || ((len = strlen(user_input)) < 3) ) return -1;
- char *space, *equal, *end = (user_input+len);
- while( (space = strchr(user_input,' ')) ) {memmove(space,space+1,end-(space+1));--end;}
- len = ((end - user_input) > alias_limit) ? alias_limit : (end-user_input);
- user_input[len] = '\0';
- if( !(equal = strchr(user_input,'=')) ) return -1;
- alias_len = equal-user_input;
- command_len = end - (equal+1);
- if( !command_len || !alias_len ) return -1;
- strncpy(aliases[num_aliases],user_input,alias_len);
- strncpy(alias_lookup[num_aliases],equal+1,command_len);
- ++num_aliases;
- return 1;
- }
Add Comment
Please, Sign In to add comment