Changeset 3f82515 for commands.c
- Timestamp:
- Feb 10, 2011, 9:08:33 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- edd0be7
- Parents:
- 6965867
- git-author:
- David Benjamin <davidben@mit.edu> (01/24/11 17:33:31)
- git-committer:
- David Benjamin <davidben@mit.edu> (02/10/11 21:08:33)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rdfe5829 r3f82515 1974 1974 char *owl_command_aimwrite(int argc, const char *const *argv, const char *buff) 1975 1975 { 1976 char *newbuff, *recip; 1976 char *message = NULL; 1977 GString *recip = g_string_new(""); 1977 1978 const char *const *myargv; 1978 int i, j, myargc; 1979 owl_message *m; 1979 int myargc; 1980 1980 1981 1981 if (!owl_global_is_aimloggedin(&g)) { 1982 owl_function_makemsg("You are not logged in to AIM."); 1983 return(NULL); 1984 } 1985 1986 if (argc < 2) { 1987 owl_function_makemsg("Not enough arguments to the aimwrite command."); 1988 return(NULL); 1989 } 1990 1991 myargv=argv; 1992 if (argc<0) { 1993 owl_function_error("Unbalanced quotes in aimwrite"); 1994 return(NULL); 1995 } 1996 myargc=argc; 1997 if (myargc && *(myargv[0])!='-') { 1998 myargc--; 1999 myargv++; 2000 } 1982 owl_function_error("You are not logged in to AIM."); 1983 goto err; 1984 } 1985 1986 /* Skip argv[0]. */ 1987 myargv = argv+1; 1988 myargc = argc-1; 2001 1989 while (myargc) { 2002 1990 if (!strcmp(myargv[0], "-m")) { 2003 if (myargc<2) { 2004 break; 1991 if (myargc <= 1) { 1992 owl_function_error("No message specified."); 1993 goto err; 2005 1994 } 2006 2007 1995 /* Once we have -m, gobble up everything else on the line */ 2008 1996 myargv++; 2009 1997 myargc--; 2010 newbuff=owl_strdup(""); 2011 while (myargc) { 2012 newbuff=owl_realloc(newbuff, strlen(newbuff)+strlen(myargv[0])+5); 2013 strcat(newbuff, myargv[0]); 2014 strcat(newbuff, " "); 2015 myargc--; 2016 myargv++; 2017 } 2018 if (strlen(newbuff) >= 1) 2019 newbuff[strlen(newbuff) - 1] = '\0'; /* remove last space */ 2020 2021 recip=owl_strdup(argv[1]); 2022 owl_aim_send_im(recip, newbuff); 2023 m=owl_function_make_outgoing_aim(newbuff, recip); 2024 if (m) { 2025 owl_global_messagequeue_addmsg(&g, m); 2026 } else { 2027 owl_function_error("Could not create outgoing AIM message"); 2028 } 2029 2030 owl_free(recip); 2031 owl_free(newbuff); 2032 return(NULL); 1998 message = g_strjoinv(" ", (char**)myargv); 1999 break; 2033 2000 } else { 2034 /* we don't care */ 2001 /* squish arguments together to make one screenname w/o spaces for now */ 2002 g_string_append(recip, myargv[0]); 2035 2003 myargv++; 2036 2004 myargc--; … … 2038 2006 } 2039 2007 2040 /* squish arguments together to make one screenname w/o spaces for now */ 2041 newbuff=owl_malloc(strlen(buff)+5); 2042 sprintf(newbuff, "%s ", argv[0]); 2043 j=argc-1; 2044 for (i=0; i<j; i++) { 2045 strcat(newbuff, argv[i+1]); 2046 } 2047 2048 owl_function_aimwrite_setup(newbuff); 2049 owl_free(newbuff); 2050 return(NULL); 2008 if (recip->str[0] == '\0') { 2009 owl_function_error("No recipient specified"); 2010 goto err; 2011 } 2012 2013 if (message != NULL) 2014 owl_function_aimwrite(recip->str, message, false); 2015 else 2016 owl_function_aimwrite_setup(recip->str); 2017 err: 2018 g_string_free(recip, true); 2019 owl_free(message); 2020 return NULL; 2051 2021 } 2052 2022
Note: See TracChangeset
for help on using the changeset viewer.