Changes in / [923c3f6:ba4d1ad]
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
r7803326 rf89cc6f 1985 1985 } 1986 1986 /* check for a zwrite -m */ 1987 z = owl_zwrite_new( buff);1987 z = owl_zwrite_new(argc, argv); 1988 1988 if (!z) { 1989 1989 owl_function_error("Error in zwrite arguments"); -
util.c
r6646fdb r7b89e8c 262 262 CALLER_OWN char *owl_arg_quote(const char *arg) 263 263 { 264 GString *buf = g_string_new(""); ;264 GString *buf = g_string_new(""); 265 265 owl_string_append_quoted_arg(buf, arg); 266 return g_string_free(buf, false); 267 } 268 269 /* Returns a quoted version of argv. owl_parseline on the result should give 270 * back the input. */ 271 CALLER_OWN char *owl_argv_quote(int argc, const char *const *argv) 272 { 273 int i; 274 GString *buf = g_string_new(""); 275 for (i = 0; i < argc; i++) { 276 if (i > 0) 277 g_string_append_c(buf, ' '); 278 owl_string_append_quoted_arg(buf, argv[i]); 279 } 266 280 return g_string_free(buf, false); 267 281 } -
zephyr.c
rf271129 rd953ede 909 909 g_free(to); 910 910 911 z = owl_zwrite_new (tmpbuff);911 z = owl_zwrite_new_from_line(tmpbuff); 912 912 g_free(tmpbuff); 913 913 if (z == NULL) { -
zwrite.c
rf271129 r6329cd5 1 1 #include "owl.h" 2 2 3 CALLER_OWN owl_zwrite *owl_zwrite_new (const char *line)3 CALLER_OWN owl_zwrite *owl_zwrite_new_from_line(const char *line) 4 4 { 5 5 owl_zwrite *z = g_new(owl_zwrite, 1); … … 11 11 } 12 12 13 CALLER_OWN owl_zwrite *owl_zwrite_new(int argc, const char *const *argv) 14 { 15 owl_zwrite *z = g_new(owl_zwrite, 1); 16 if (owl_zwrite_create(z, argc, argv) < 0) { 17 owl_zwrite_delete(z); 18 return NULL; 19 } 20 return z; 21 } 22 13 23 G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create_from_line(owl_zwrite *z, const char *line) 14 24 { 15 int argc , badargs, myargc;25 int argc; 16 26 char **argv; 17 const char *const *myargv; 27 int ret; 28 29 /* parse the command line for options */ 30 argv = owl_parseline(line, &argc); 31 if (argc < 0) { 32 owl_function_error("Unbalanced quotes in zwrite"); 33 return -1; 34 } 35 ret = owl_zwrite_create(z, argc, strs(argv)); 36 g_strfreev(argv); 37 return ret; 38 } 39 40 G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create(owl_zwrite *z, int argc, const char *const *argv) 41 { 42 int badargs = 0; 18 43 char *msg = NULL; 19 20 badargs=0;21 44 22 45 /* start with null entries */ … … 31 54 z->noping=0; 32 55 z->recips = g_ptr_array_new(); 33 z->zwriteline = g_strdup(line); 34 35 /* parse the command line for options */ 36 argv=owl_parseline(line, &argc); 37 myargv=strs(argv); 38 if (argc<0) { 39 owl_function_error("Unbalanced quotes in zwrite"); 40 return(-1); 41 } 42 myargc=argc; 43 if (myargc && *(myargv[0])!='-') { 44 z->cmd=g_strdup(myargv[0]); 45 myargc--; 46 myargv++; 47 } 48 while (myargc) { 49 if (!strcmp(myargv[0], "-c")) { 50 if (myargc<2) { 51 badargs=1; 52 break; 53 } 54 z->class=owl_validate_utf8(myargv[1]); 55 myargv+=2; 56 myargc-=2; 57 } else if (!strcmp(myargv[0], "-i")) { 58 if (myargc<2) { 59 badargs=1; 60 break; 61 } 62 z->inst=owl_validate_utf8(myargv[1]); 63 myargv+=2; 64 myargc-=2; 65 } else if (!strcmp(myargv[0], "-r")) { 66 if (myargc<2) { 67 badargs=1; 68 break; 69 } 70 z->realm=owl_validate_utf8(myargv[1]); 71 myargv+=2; 72 myargc-=2; 73 } else if (!strcmp(myargv[0], "-s")) { 74 if (myargc<2) { 75 badargs=1; 76 break; 77 } 78 z->zsig=owl_validate_utf8(myargv[1]); 79 myargv+=2; 80 myargc-=2; 81 } else if (!strcmp(myargv[0], "-O")) { 82 if (myargc<2) { 83 badargs=1; 84 break; 85 } 86 z->opcode=owl_validate_utf8(myargv[1]); 87 myargv+=2; 88 myargc-=2; 89 } else if (!strcmp(myargv[0], "-m")) { 90 if (myargc<2) { 56 z->zwriteline = owl_argv_quote(argc, argv); 57 58 if (argc && *(argv[0])!='-') { 59 z->cmd=g_strdup(argv[0]); 60 argc--; 61 argv++; 62 } 63 while (argc) { 64 if (!strcmp(argv[0], "-c")) { 65 if (argc<2) { 66 badargs=1; 67 break; 68 } 69 z->class=owl_validate_utf8(argv[1]); 70 argv+=2; 71 argc-=2; 72 } else if (!strcmp(argv[0], "-i")) { 73 if (argc<2) { 74 badargs=1; 75 break; 76 } 77 z->inst=owl_validate_utf8(argv[1]); 78 argv+=2; 79 argc-=2; 80 } else if (!strcmp(argv[0], "-r")) { 81 if (argc<2) { 82 badargs=1; 83 break; 84 } 85 z->realm=owl_validate_utf8(argv[1]); 86 argv+=2; 87 argc-=2; 88 } else if (!strcmp(argv[0], "-s")) { 89 if (argc<2) { 90 badargs=1; 91 break; 92 } 93 z->zsig=owl_validate_utf8(argv[1]); 94 argv+=2; 95 argc-=2; 96 } else if (!strcmp(argv[0], "-O")) { 97 if (argc<2) { 98 badargs=1; 99 break; 100 } 101 z->opcode=owl_validate_utf8(argv[1]); 102 argv+=2; 103 argc-=2; 104 } else if (!strcmp(argv[0], "-m")) { 105 if (argc<2) { 91 106 badargs=1; 92 107 break; … … 99 114 100 115 /* Once we have -m, gobble up everything else on the line */ 101 myargv++;102 myargc--;103 msg = g_strjoinv(" ", (char**) myargv);116 argv++; 117 argc--; 118 msg = g_strjoinv(" ", (char**)argv); 104 119 break; 105 } else if (!strcmp( myargv[0], "-C")) {120 } else if (!strcmp(argv[0], "-C")) { 106 121 z->cc=1; 107 myargv++;108 myargc--;109 } else if (!strcmp( myargv[0], "-n")) {122 argv++; 123 argc--; 124 } else if (!strcmp(argv[0], "-n")) { 110 125 z->noping=1; 111 myargv++;112 myargc--;126 argv++; 127 argc--; 113 128 } else { 114 129 /* anything unattached is a recipient */ 115 g_ptr_array_add(z->recips, owl_validate_utf8( myargv[0]));116 myargv++;117 myargc--;130 g_ptr_array_add(z->recips, owl_validate_utf8(argv[0])); 131 argv++; 132 argc--; 118 133 } 119 134 } 120 121 g_strfreev(argv);122 135 123 136 if (badargs) {
Note: See TracChangeset
for help on using the changeset viewer.