- Timestamp:
- Aug 21, 2008, 12:52:04 AM (16 years ago)
- Branches:
- master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 38a7f22
- Parents:
- aef51f8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cmd.c
r34509d5 rc4ba74d 67 67 } 68 68 69 char *_owl_cmddict_execute(owl_cmddict *cd, owl_context *ctx, char **argv, int argc, char *buff) { 70 char *retval = NULL; 71 owl_cmd *cmd; 72 73 if (!strcmp(argv[0], "")) { 74 } else if (NULL != (cmd = (owl_cmd*)owl_dict_find_element(cd, argv[0]))) { 75 retval = owl_cmd_execute(cmd, cd, ctx, argc, argv, buff); 76 } else { 77 owl_function_makemsg("Unknown command '%s'.", buff); 78 } 79 return retval; 80 } 81 69 82 char *owl_cmddict_execute(owl_cmddict *cd, owl_context *ctx, char *cmdbuff) { 70 83 char **argv; … … 72 85 char *tmpbuff; 73 86 char *retval = NULL; 74 owl_cmd *cmd;75 87 76 88 tmpbuff=owl_strdup(cmdbuff); … … 85 97 if (argc < 1) return(NULL); 86 98 87 if (!strcmp(argv[0], "")) { 88 } else if (NULL != (cmd = (owl_cmd*)owl_dict_find_element(cd, argv[0]))) { 89 retval = owl_cmd_execute(cmd, cd, ctx, argc, argv, cmdbuff); 90 } else { 91 owl_function_makemsg("Unknown command '%s'.", cmdbuff); 92 } 99 retval = _owl_cmddict_execute(cd, ctx, argv, argc, cmdbuff); 100 93 101 owl_parsefree(argv, argc); 94 102 owl_free(tmpbuff); 95 103 sepbar(NULL); 104 return retval; 105 } 106 107 char *owl_cmddict_execute_argv(owl_cmddict *cd, owl_context *ctx, char **argv, int argc) { 108 char *buff, *ptr; 109 int len = 0, i; 110 char *retval = NULL; 111 112 for(i = 0; i < argc; i++) { 113 len += strlen(argv[i]) + 1; 114 } 115 116 ptr = buff = owl_malloc(len); 117 118 for(i = 0; i < argc; i++) { 119 strcpy(ptr, argv[i]); 120 ptr += strlen(argv[i]); 121 *(ptr++) = ' '; 122 } 123 *(ptr - 1) = 0; 124 125 retval = _owl_cmddict_execute(cd, ctx, argv, argc, buff); 126 127 owl_free(buff); 96 128 return retval; 97 129 }
Note: See TracChangeset
for help on using the changeset viewer.