Changeset 2ace81e for commands.c
- Timestamp:
- Mar 29, 2009, 2:58:21 PM (16 years ago)
- Branches:
- owl
- Children:
- 2f01162
- Parents:
- ba4fde8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rba4fde8 r2ace81e 156 156 OWLCMD_ARGS("aimwrite", owl_command_aimwrite, OWL_CTX_INTERACTIVE, 157 157 "send an AIM message", 158 "aimzwrite <user>", 159 "Send an aim message to a user.\n"), 158 "aimwrite <user> [-m <message...>]", 159 "Send an aim message to a user.\n\n" 160 "The following options are available:\n\n" 161 "-m Specifies a message to send without prompting.\n"), 160 162 161 163 OWLCMD_ARGS("loopwrite", owl_command_loopwrite, OWL_CTX_INTERACTIVE, … … 1858 1860 char *owl_command_aimwrite(int argc, char **argv, char *buff) 1859 1861 { 1860 char *newbuff; 1861 int i, j; 1862 char *newbuff, *recip, **myargv; 1863 int i, j, myargc; 1864 owl_message *m; 1862 1865 1863 1866 if (!owl_global_is_aimloggedin(&g)) { … … 1869 1872 owl_function_makemsg("Not enough arguments to the aimwrite command."); 1870 1873 return(NULL); 1874 } 1875 1876 myargv=argv; 1877 if (argc<0) { 1878 owl_function_error("Unbalanced quotes in aimwrite"); 1879 return(NULL); 1880 } 1881 myargc=argc; 1882 if (myargc && *(myargv[0])!='-') { 1883 myargc--; 1884 myargv++; 1885 } 1886 while (myargc) { 1887 if (!strcmp(myargv[0], "-m")) { 1888 if (myargc<2) { 1889 break; 1890 } 1891 1892 /* Once we have -m, gobble up everything else on the line */ 1893 myargv++; 1894 myargc--; 1895 newbuff=owl_malloc(1); 1896 newbuff=owl_strdup(""); 1897 while (myargc) { 1898 newbuff=realloc(newbuff, strlen(newbuff)+strlen(myargv[0])+5); 1899 strcat(newbuff, myargv[0]); 1900 strcat(newbuff, " "); 1901 myargc--; 1902 myargv++; 1903 } 1904 newbuff[strlen(newbuff)-1]='\0'; /* remove last space */ 1905 1906 recip=owl_malloc(strlen(argv[0])+5); 1907 sprintf(recip, "%s ", argv[1]); 1908 owl_aim_send_im(recip, newbuff); 1909 m=owl_function_make_outgoing_aim(newbuff, recip); 1910 if (m) { 1911 owl_global_messagequeue_addmsg(&g, m); 1912 } else { 1913 owl_function_error("Could not create outgoing AIM message"); 1914 } 1915 1916 owl_free(recip); 1917 owl_free(newbuff); 1918 return(NULL); 1919 } else { 1920 /* we don't care */ 1921 myargv++; 1922 myargc--; 1923 } 1871 1924 } 1872 1925
Note: See TracChangeset
for help on using the changeset viewer.