Changeset 944004c


Ignore:
Timestamp:
Oct 14, 2007, 5:16:35 PM (17 years ago)
Author:
Matthew S. Goldstein <austein@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
fa4f9c3
Parents:
abe0962
Message:
added -m flag to aimwrite
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rabe0962 r944004c  
    132132  OWLCMD_ARGS("aimwrite", owl_command_aimwrite, OWL_CTX_INTERACTIVE,
    133133              "send an AIM message",
    134               "aimwrite <user>",
    135               "Send an aim message to a user.\n"),
     134              "aimzwrite <user> [-m <message...>]",
     135              "Send an aim message to a user.\n\n"
     136              "The following options are available:\n\n"
     137              "-m    Specifies a message to send without prompting.\n"
     138              "      Note that this does not yet log an outgoing message.\n"
     139              "      or display the sent message.\n"),
    136140
    137141  OWLCMD_ARGS("loopwrite", owl_command_loopwrite, OWL_CTX_INTERACTIVE,
     
    18861890char *owl_command_aimwrite(int argc, char **argv, char *buff)
    18871891{
    1888   char *newbuff;
    1889   int i, j;
     1892  char *newbuff, *recip, **myargv;
     1893  int i, j, myargc;
    18901894 
    18911895  if (!owl_global_is_aimloggedin(&g)) {
     
    18971901    owl_function_makemsg("Not enough arguments to the aimwrite command.");
    18981902    return(NULL);
     1903  }
     1904
     1905  myargv=argv;
     1906  if (argc<0) {
     1907    owl_function_error("Unbalanced quotes in aimwrite");
     1908    return(NULL);
     1909  }
     1910  myargc=argc;
     1911  if (myargc && *(myargv[0])!='-') {
     1912    myargc--;
     1913    myargv++;
     1914  }
     1915  while (myargc) {
     1916    if (!strcmp(myargv[0], "-m")) {
     1917      if (myargc<2) {
     1918        break;
     1919      }
     1920
     1921      /* Once we have -m, gobble up everything else on the line */
     1922      myargv++;
     1923      myargc--;
     1924      newbuff=owl_malloc(1);
     1925      newbuff=owl_strdup("");
     1926      while (myargc) {
     1927        newbuff=realloc(newbuff, strlen(newbuff)+strlen(myargv[0])+5);
     1928        strcat(newbuff, myargv[0]);
     1929        strcat(newbuff, " ");
     1930        myargc--;
     1931        myargv++;
     1932      }
     1933      newbuff[strlen(newbuff)-1]='\0'; /* remove last space */
     1934
     1935      recip=owl_malloc(strlen(argv[0])+5);
     1936      sprintf(recip, "%s ", argv[1]);
     1937      owl_aim_send_im(recip, newbuff);
     1938      owl_free(recip);
     1939      owl_free(newbuff);
     1940      return(NULL);
     1941    } else {
     1942      /* we don't care */
     1943      myargv++;
     1944      myargc--;
     1945    }
    18991946  }
    19001947
Note: See TracChangeset for help on using the changeset viewer.