Changeset a962f5c


Ignore:
Timestamp:
Sep 30, 2011, 9:35:01 PM (10 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
7803326 (diff), 2dd9c48 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge 2dd9c4831cbda78650784ec9d10c3f6820bfdc01 into 78033261fc599d8d986e1c32b68523132b853d40
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r7803326 r2dd9c48  
    19851985  }
    19861986  /* check for a zwrite -m */
    1987   z = owl_zwrite_new(buff);
     1987  z = owl_zwrite_new(argc, argv);
    19881988  if (!z) {
    19891989    owl_function_error("Error in zwrite arguments");
  • util.c

    r6646fdb r7b89e8c  
    262262CALLER_OWN char *owl_arg_quote(const char *arg)
    263263{
    264   GString *buf = g_string_new("");;
     264  GString *buf = g_string_new("");
    265265  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. */
     271CALLER_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  }
    266280  return g_string_free(buf, false);
    267281}
  • zephyr.c

    rf271129 rd953ede  
    909909  g_free(to);
    910910
    911   z = owl_zwrite_new(tmpbuff);
     911  z = owl_zwrite_new_from_line(tmpbuff);
    912912  g_free(tmpbuff);
    913913  if (z == NULL) {
  • zwrite.c

    rf271129 rd6c2e03  
    11#include "owl.h"
    22
    3 CALLER_OWN owl_zwrite *owl_zwrite_new(const char *line)
     3CALLER_OWN owl_zwrite *owl_zwrite_new_from_line(const char *line)
    44{
    55  owl_zwrite *z = g_new(owl_zwrite, 1);
     
    1111}
    1212
     13CALLER_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
    1323G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create_from_line(owl_zwrite *z, const char *line)
    1424{
    15   int argc, badargs, myargc;
     25  int argc;
    1626  char **argv;
     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
     40G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create(owl_zwrite *z, int argc, const char *const *argv)
     41{
     42  int badargs, myargc;
    1743  const char *const *myargv;
    1844  char *msg = NULL;
     
    3157  z->noping=0;
    3258  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;
     59  z->zwriteline = owl_argv_quote(argc, argv);
     60
     61  myargc = argc;
     62  myargv = argv;
    4363  if (myargc && *(myargv[0])!='-') {
    4464    z->cmd=g_strdup(myargv[0]);
     
    119139  }
    120140
    121   g_strfreev(argv);
    122 
    123141  if (badargs) {
    124142    return(-1);
Note: See TracChangeset for help on using the changeset viewer.