Changeset 1c6c4d3
- Timestamp:
- Jun 30, 2002, 4:58:09 PM (22 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 507d5aa
- Parents:
- 262422c
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
rb68f9cd r1c6c4d3 12 12 Added "reply zaway" which sends a zaway response to the current msg. 13 13 Added "edit:delete-prev-word" command and bound M-BACKSPACE to it. 14 Added owl_sprintf which returns the formatted string, or NULL. 15 The caller must free this string. 16 This will allocate enough memory and thus 17 avoid potential some buffer overrun situations. 18 Started fixing some potential buffer overrun situations. 19 Simple implementation of 'zwrite -m' (doesn't yet log an outgoing 20 message as having been sent.) 21 The "Not logged in or subscribing to messages" error 22 now includes the name of the recipient. 14 23 15 24 1.2.1-pre-1 -
commands.c
rb68f9cd r1c6c4d3 81 81 OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE, 82 82 "send a zephyr", 83 "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [<user> ...] ",83 "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [<user> ...] [-m <message...>]", 84 84 "Zwrite send a zephyr to the one or more users specified.\n\n" 85 85 "The following options are available:\n\n" 86 "-m Specifies a message to send without prompting.\n" 87 " Note that this does not yet log an outgoing message.\n" 88 " This must be the last argument.\n\n" 86 89 "-n Do not send a ping message.\n\n" 87 90 "-C If the message is sent to more than one user include a\n" … … 1111 1114 1112 1115 char *owl_command_zwrite(int argc, char **argv, char *buff) { 1113 char *tmpbuff; 1116 char *tmpbuff, *pos, *cmd, *msg; 1117 1118 /* check for a zwrite -m */ 1119 for (pos = buff; *pos; pos = skiptokens(pos, 1)) { 1120 if (!strncmp(pos, "-m ", 3)) { 1121 cmd = owl_strdup(buff); 1122 msg = cmd+(pos-buff); 1123 *msg = '\0'; 1124 msg += 3; 1125 owl_zwrite_create_and_send_from_line(cmd, msg); 1126 owl_free(cmd); 1127 return NULL; 1128 } 1129 } 1130 1114 1131 if (argc < 2) { 1115 1132 owl_function_makemsg("Not enough arguments to the zwrite command."); -
functions.c
rd36f2cb r1c6c4d3 155 155 /* display the message as an admin message in the receive window */ 156 156 if (owl_global_is_displayoutgoing(&g) && owl_zwrite_is_personal(&z)) { 157 tmpbuff=owl_malloc(strlen(owl_editwin_get_text(owl_global_get_typwin(&g)))+1024);158 157 owl_zwrite_get_recipstr(&z, buff); 159 sprintf(tmpbuff,"Message sent to %s", buff);158 tmpbuff = owl_sprintf("Message sent to %s", buff); 160 159 owl_function_adminmsg_outgoing(tmpbuff, owl_editwin_get_text(owl_global_get_typwin(&g)), line); 161 160 owl_free(tmpbuff); … … 1162 1161 } 1163 1162 1164 buff= malloc(num*200);1163 buff=owl_malloc(num*200); 1165 1164 strcpy(buff, ""); 1166 1165 for (i=0; i<num; i++) { … … 1173 1172 1174 1173 owl_function_popless_text(buff); 1175 free(buff);1174 owl_free(buff); 1176 1175 ZFlushSubscriptions(); 1177 1176 } … … 1266 1265 owl_view *v; 1267 1266 owl_filter *f; 1268 char buff[LINE];1269 1267 1270 1268 /* get the trash filter */ … … 1287 1285 } 1288 1286 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 1289 sprintf(buff, "%i messages marked for deletion", count); 1290 owl_function_makemsg(buff); 1287 owl_function_makemsg("%i messages marked for deletion", count); 1291 1288 owl_global_set_needrefresh(&g); 1292 1289 } -
owl.c
r1aee7d9 r1c6c4d3 273 273 /* this is an unsupported feature */ 274 274 if (owl_global_is_burningears(&g) && owl_message_is_burningears(m)) { 275 char buff[LINE];276 sprintf(buff,"@i(Burning ears message on class %s)", owl_message_get_class(m));275 char *buff; 276 buff = owl_sprintf("@i(Burning ears message on class %s)", owl_message_get_class(m)); 277 277 /* owl_function_makemsg(buff); */ 278 278 owl_function_adminmsg(buff, ""); 279 owl_free(buff); 279 280 owl_function_beep(); 280 281 } -
util.c
r1aee7d9 r1c6c4d3 28 28 strcpy(buff, " (-/-) "); 29 29 } else { 30 s printf(buff, " (%i/%i/%i) ", owl_global_get_curmsg(&g)+1,30 snprintf(buff, 1024, " (%i/%i/%i) ", owl_global_get_curmsg(&g)+1, 31 31 owl_view_get_size(v), 32 32 owl_messagelist_get_size(ml)); … … 62 62 getyx(sepwin, y, x); 63 63 wmove(sepwin, y, x+2); 64 s printf(buff, " right: %i ", owl_global_get_rightshift(&g));64 snprintf(buff, 1024, " right: %i ", owl_global_get_rightshift(&g)); 65 65 waddstr(sepwin, buff); 66 66 } … … 316 316 } 317 317 318 /* allocates memory and returns the string or null. 319 * caller must free the string. 320 * from Linux sprintf man page. 321 */ 322 char *owl_sprintf(const char *fmt, ...) { 323 int n, size = 100; 324 char *p; 325 va_list ap; 326 if ((p = owl_malloc (size)) == NULL) 327 return NULL; 328 while (1) { 329 /* Try to print in the allocated space. */ 330 va_start(ap, fmt); 331 n = vsnprintf (p, size, fmt, ap); 332 va_end(ap); 333 /* If that worked, return the string. */ 334 if (n > -1 && n < size) 335 return p; 336 /* Else try again with more space. */ 337 if (n > -1) /* glibc 2.1 */ 338 size = n+1; /* precisely what is needed */ 339 else /* glibc 2.0 */ 340 size *= 2; /* twice the old size */ 341 if ((p = owl_realloc (p, size)) == NULL) 342 return NULL; 343 } 344 } 345 318 346 char *pretty_sender(char *in) { 319 347 char *out, *ptr; … … 331 359 332 360 char *long_sender(char *in) { 333 char * out, *ptr;361 char *ptr; 334 362 335 363 /* the caller must free the return */ 336 out=owl_malloc(strlen(in)+100); 337 strcpy(out, in); 338 ptr=strchr(out, '@'); 339 if (ptr) return(out); 340 sprintf(out, "%s@%s", out, ZGetRealm()); 341 return(out); 364 if (NULL != (ptr=strchr(in, '@'))) { 365 return owl_strdup(in); 366 } else { 367 return owl_sprintf("%s@%s", in, ZGetRealm()); 368 } 342 369 } 343 370 -
zephyr.c
r1aee7d9 r1c6c4d3 111 111 subs[count].zsub_classinst=owl_strdup(buffer); 112 112 } else { 113 subs[count].zsub_classinst=owl_malloc(1024); 114 sprintf(subs[count].zsub_classinst, "%s@%s", buffer, ZGetRealm()); 113 subs[count].zsub_classinst=owl_sprintf("%s@%s", buffer, ZGetRealm()); 115 114 } 116 115 … … 346 345 347 346 void owl_zephyr_handle_ack(ZNotice_t *retnotice) { 348 char buff[LINE];349 347 char *tmp; 350 348 … … 362 360 !strcasecmp(retnotice->z_class_inst, "personal")) { 363 361 tmp=pretty_sender(retnotice->z_recipient); 364 sprintf(buff,"Message sent to %s.", tmp);362 owl_function_makemsg("Message sent to %s.", tmp); 365 363 free(tmp); 366 364 } else { 367 sprintf(buff, "Message sent to -c %s -i %s\n", retnotice->z_class, retnotice->z_class_inst); 368 } 369 owl_function_makemsg(buff); 365 owl_function_makemsg("Message sent to -c %s -i %s\n", retnotice->z_class, retnotice->z_class_inst); 366 } 370 367 } else if (!strcmp(retnotice->z_message, ZSRVACK_NOTSENT)) { 371 368 if (strcasecmp(retnotice->z_class, "message")) { 372 sprintf(buff,"Not logged in or not subscribing to class %s, instance %s",369 owl_function_makemsg("Not logged in or not subscribing to class %s, instance %s", 373 370 retnotice->z_class, retnotice->z_class_inst); 374 owl_function_makemsg(buff);375 371 } else { 376 owl_function_makemsg("Not logged in or subscribing to messages."); 377 } 378 } else { 379 char buff[1024]; 380 sprintf(buff, "Internal error on ack (%s)", retnotice->z_message); 381 owl_function_makemsg(buff); 372 tmp = pretty_sender(retnotice->z_recipient); 373 owl_function_makemsg("%s: Not logged in or subscribing to messages.", 374 tmp); 375 owl_free(tmp); 376 } 377 } else { 378 owl_function_makemsg("Internal error on ack (%s)", retnotice->z_message); 382 379 } 383 380 } … … 412 409 413 410 /* display the message as an admin message in the receive window */ 414 tmpbuff=owl_malloc(strlen(owl_global_get_zaway_msg(&g))+LINE); 415 sprintf(tmpbuff, "Message sent to %s", owl_message_get_sender(m)); 411 tmpbuff = owl_sprintf("Message sent to %s", owl_message_get_sender(m)); 416 412 owl_function_adminmsg(tmpbuff, owl_global_get_zaway_msg(&g)); 417 413 owl_free(tmpbuff); -
zwrite.c
r1aee7d9 r1c6c4d3 3 3 4 4 static const char fileIdent[] = "$Id$"; 5 6 int owl_zwrite_create_and_send_from_line(char *cmd, char *msg) { 7 owl_zwrite z; 8 int rv; 9 rv = owl_zwrite_create_from_line(&z, cmd); 10 if (rv) return(rv); 11 owl_zwrite_send_message(&z, msg); 12 owl_zwrite_free(&z); 13 return(0); 14 } 5 15 6 16 int owl_zwrite_create_from_line(owl_zwrite *z, char *line) {
Note: See TracChangeset
for help on using the changeset viewer.