Changes in zwrite.c [3cdd6d2:d427f08]
Legend:
- Unmodified
- Added
- Removed
-
zwrite.c
r3cdd6d2 rd427f08 5 5 #include "owl.h" 6 6 7 CALLER_OWNowl_zwrite *owl_zwrite_new(const char *line)7 G_GNUC_WARN_UNUSED_RESULT owl_zwrite *owl_zwrite_new(const char *line) 8 8 { 9 9 owl_zwrite *z = g_new(owl_zwrite, 1); … … 34 34 z->cc=0; 35 35 z->noping=0; 36 z->recips = g_ptr_array_new();36 owl_list_create(&(z->recips)); 37 37 z->zwriteline = g_strdup(line); 38 38 … … 97 97 } 98 98 /* we must already have users or a class or an instance */ 99 if ( z->recips->len <1 && (!z->class) && (!z->inst)) {99 if (owl_list_get_size(&(z->recips))<1 && (!z->class) && (!z->inst)) { 100 100 badargs=1; 101 101 break; … … 117 117 } else { 118 118 /* anything unattached is a recipient */ 119 g_ptr_array_add(z->recips, owl_validate_utf8(myargv[0]));119 owl_list_append_element(&(z->recips), owl_validate_utf8(myargv[0])); 120 120 myargv++; 121 121 myargc--; … … 131 131 if (z->class == NULL && 132 132 z->inst == NULL && 133 z->recips->len ==0) {133 owl_list_get_size(&(z->recips))==0) { 134 134 owl_function_error("You must specify a recipient for zwrite"); 135 135 return(-1); … … 162 162 void owl_zwrite_send_ping(const owl_zwrite *z) 163 163 { 164 int i ;164 int i, j; 165 165 char *to; 166 166 … … 173 173 /* if there are no recipients we won't send a ping, which 174 174 is what we want */ 175 for (i = 0; i < z->recips->len; i++) { 175 j=owl_list_get_size(&(z->recips)); 176 for (i=0; i<j; i++) { 176 177 to = owl_zwrite_get_recip_n_with_realm(z, i); 177 178 send_ping(to, z->class, z->inst); … … 190 191 void owl_zwrite_set_message(owl_zwrite *z, const char *msg) 191 192 { 192 int i ;193 int i, j; 193 194 GString *message; 194 195 char *tmp = NULL, *tmp2; … … 196 197 g_free(z->message); 197 198 198 if (z->recips->len > 0 && z->cc) { 199 j=owl_list_get_size(&(z->recips)); 200 if (j>0 && z->cc) { 199 201 message = g_string_new("CC: "); 200 for (i = 0; i < z->recips->len; i++) {202 for (i=0; i<j; i++) { 201 203 tmp = owl_zwrite_get_recip_n_with_realm(z, i); 202 204 g_string_append_printf(message, "%s ", tmp); … … 231 233 int owl_zwrite_send_message(const owl_zwrite *z) 232 234 { 233 int i, ret = 0;235 int i, j, ret = 0; 234 236 char *to = NULL; 235 237 236 238 if (z->message==NULL) return(-1); 237 239 238 if (z->recips->len > 0) { 239 for (i = 0; i < z->recips->len; i++) { 240 j=owl_list_get_size(&(z->recips)); 241 if (j>0) { 242 for (i=0; i<j; i++) { 240 243 to = owl_zwrite_get_recip_n_with_realm(z, i); 241 244 ret = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message); … … 309 312 int owl_zwrite_get_numrecips(const owl_zwrite *z) 310 313 { 311 return z->recips->len;314 return(owl_list_get_size(&(z->recips))); 312 315 } 313 316 314 317 const char *owl_zwrite_get_recip_n(const owl_zwrite *z, int n) 315 318 { 316 return z->recips->pdata[n];319 return(owl_list_get_element(&(z->recips), n)); 317 320 } 318 321 319 322 /* Caller must free the result. */ 320 CALLER_OWNchar *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)323 G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n) 321 324 { 322 325 if (z->realm[0]) { … … 330 333 { 331 334 /* return true if at least one of the recipients is personal */ 332 int i; 333 char *recip; 334 335 for (i = 0; i < z->recips->len; i++) { 336 recip = z->recips->pdata[i]; 337 if (recip[0] != '@') return 1; 335 int i, j; 336 char *foo; 337 338 j=owl_list_get_size(&(z->recips)); 339 for (i=0; i<j; i++) { 340 foo=owl_list_get_element(&(z->recips), i); 341 if (foo[0]!='@') return(1); 338 342 } 339 343 return(0); … … 348 352 void owl_zwrite_cleanup(owl_zwrite *z) 349 353 { 350 owl_ ptr_array_free(z->recips,g_free);354 owl_list_cleanup(&(z->recips), &g_free); 351 355 g_free(z->cmd); 352 356 g_free(z->zwriteline); … … 366 370 * If not a CC, only the recip_index'th user will be replied to. 367 371 */ 368 CALLER_OWNchar *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)372 G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index) 369 373 { 370 374 /* Match ordering in zwrite help. */ … … 399 403 } 400 404 if (z->cc) { 401 for (i = 0; i < z->recips->len; i++) {405 for (i = 0; i < owl_list_get_size(&(z->recips)); i++) { 402 406 g_string_append_c(buf, ' '); 403 owl_string_append_quoted_arg(buf, z->recips->pdata[i]);407 owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), i)); 404 408 } 405 } else if (recip_index < z->recips->len) {409 } else if (recip_index < owl_list_get_size(&(z->recips))) { 406 410 g_string_append_c(buf, ' '); 407 owl_string_append_quoted_arg(buf, z->recips->pdata[recip_index]);411 owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), recip_index)); 408 412 } 409 413
Note: See TracChangeset
for help on using the changeset viewer.