[746] in BarnOwl Developers
[D-O-H] r768 - trunk/owl
daemon@ATHENA.MIT.EDU (matt@MIT.EDU)
Thu Oct 29 18:09:17 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: matt@MIT.EDU
Reply-To: dirty-owl-hackers@MIT.EDU
Date: Sun, 14 Oct 2007 17:16:36 -0400 (EDT)
Author: matt
Date: 2007-10-14 17:16:35 -0400 (Sun, 14 Oct 2007)
New Revision: 768
Modified:
trunk/owl/commands.c
Log:
added -m flag to aimwrite
Modified: trunk/owl/commands.c
===================================================================
--- trunk/owl/commands.c 2007-10-10 19:21:13 UTC (rev 767)
+++ trunk/owl/commands.c 2007-10-14 21:16:35 UTC (rev 768)
@@ -131,8 +131,12 @@
OWLCMD_ARGS("aimwrite", owl_command_aimwrite, OWL_CTX_INTERACTIVE,
"send an AIM message",
- "aimwrite <user>",
- "Send an aim message to a user.\n"),
+ "aimzwrite <user> [-m <message...>]",
+ "Send an aim message to a user.\n\n"
+ "The following options are available:\n\n"
+ "-m Specifies a message to send without prompting.\n"
+ " Note that this does not yet log an outgoing message.\n"
+ " or display the sent message.\n"),
OWLCMD_ARGS("loopwrite", owl_command_loopwrite, OWL_CTX_INTERACTIVE,
"send a loopback message",
@@ -1885,8 +1889,8 @@
char *owl_command_aimwrite(int argc, char **argv, char *buff)
{
- char *newbuff;
- int i, j;
+ char *newbuff, *recip, **myargv;
+ int i, j, myargc;
if (!owl_global_is_aimloggedin(&g)) {
owl_function_makemsg("You are not logged in to AIM.");
@@ -1898,6 +1902,49 @@
return(NULL);
}
+ myargv=argv;
+ if (argc<0) {
+ owl_function_error("Unbalanced quotes in aimwrite");
+ return(NULL);
+ }
+ myargc=argc;
+ if (myargc && *(myargv[0])!='-') {
+ myargc--;
+ myargv++;
+ }
+ while (myargc) {
+ if (!strcmp(myargv[0], "-m")) {
+ if (myargc<2) {
+ break;
+ }
+
+ /* Once we have -m, gobble up everything else on the line */
+ myargv++;
+ myargc--;
+ newbuff=owl_malloc(1);
+ newbuff=owl_strdup("");
+ while (myargc) {
+ newbuff=realloc(newbuff, strlen(newbuff)+strlen(myargv[0])+5);
+ strcat(newbuff, myargv[0]);
+ strcat(newbuff, " ");
+ myargc--;
+ myargv++;
+ }
+ newbuff[strlen(newbuff)-1]='\0'; /* remove last space */
+
+ recip=owl_malloc(strlen(argv[0])+5);
+ sprintf(recip, "%s ", argv[1]);
+ owl_aim_send_im(recip, newbuff);
+ owl_free(recip);
+ owl_free(newbuff);
+ return(NULL);
+ } else {
+ /* we don't care */
+ myargv++;
+ myargc--;
+ }
+ }
+
/* squish arguments together to make one screenname w/o spaces for now */
newbuff=owl_malloc(strlen(buff)+5);
sprintf(newbuff, "%s ", argv[0]);