Changeset 24ccc01 for message.c


Ignore:
Timestamp:
Aug 26, 2009, 11:50:56 PM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
e2ebf39
Parents:
36486be
git-author:
Nelson Elhage <nelhage@mit.edu> (08/19/09 23:41:06)
git-committer:
Nelson Elhage <nelhage@mit.edu> (08/26/09 23:50:56)
Message:
Replace owl_message_create_from_zwriteline with owl_message_create_from_zwrite.

By passing in a zwrite structure instead of a line, we make it easier to
construct faked messages without having to go through generaring and
parsing a zwrite command line. We change owl_zephyr_handle_ack to fake a
zwrite structure, fixing the segfault on zephyring users with
quotes (fixes #94), as well as logging errors sending instanced personals
slightly better.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • message.c

    r27f6487 r24ccc01  
    898898}
    899899
    900 void owl_message_create_from_zwriteline(owl_message *m, const char *line, const char *body, const char *zsig)
    901 {
    902   owl_zwrite z;
     900void owl_message_create_from_zwrite(owl_message *m, const owl_zwrite *z, const char *body)
     901{
    903902  int ret;
    904903  char hostbuff[5000];
    905904 
    906905  owl_message_init(m);
    907 
    908   /* create a zwrite for the purpose of filling in other message fields */
    909   owl_zwrite_create_from_line(&z, line);
    910906
    911907  /* set things */
     
    913909  owl_message_set_type_zephyr(m);
    914910  owl_message_set_sender(m, owl_zephyr_get_sender());
    915   owl_message_set_class(m, owl_zwrite_get_class(&z));
    916   owl_message_set_instance(m, owl_zwrite_get_instance(&z));
    917   if (owl_zwrite_get_numrecips(&z)>0) {
    918     char *longzuser = long_zuser(owl_zwrite_get_recip_n(&z, 0));
     911  owl_message_set_class(m, owl_zwrite_get_class(z));
     912  owl_message_set_instance(m, owl_zwrite_get_instance(z));
     913  if (owl_zwrite_get_numrecips(z)>0) {
     914    char *longzuser = long_zuser(owl_zwrite_get_recip_n(z, 0));
    919915    owl_message_set_recipient(m,
    920916                              longzuser); /* only gets the first user, must fix */
    921917    owl_free(longzuser);
    922918  }
    923   owl_message_set_opcode(m, owl_zwrite_get_opcode(&z));
    924   owl_message_set_realm(m, owl_zwrite_get_realm(&z)); /* also a hack, but not here */
    925   owl_message_set_zwriteline(m, line);
     919  owl_message_set_opcode(m, owl_zwrite_get_opcode(z));
     920  owl_message_set_realm(m, owl_zwrite_get_realm(z)); /* also a hack, but not here */
     921  if(z->zwriteline) {
     922    owl_message_set_zwriteline(m, z->zwriteline);
     923  }
    926924  owl_message_set_body(m, body);
    927   owl_message_set_zsig(m, zsig);
     925  owl_message_set_zsig(m, owl_zwrite_get_zsig(z));
    928926 
    929927  /* save the hostname */
     
    937935
    938936  /* set the "isprivate" attribute if it's a private zephyr. */
    939   if (owl_zwrite_is_personal(&z)) {
     937  if (owl_zwrite_is_personal(z)) {
    940938    owl_message_set_isprivate(m);
    941939  }
    942 
    943   owl_zwrite_free(&z);
    944940}
    945941
Note: See TracChangeset for help on using the changeset viewer.