Changeset b0430a6


Ignore:
Timestamp:
Dec 21, 2003, 8:19:14 PM (17 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
2de4f20
Parents:
72836b5
Message:
New zephyr_get_field function
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r72836b5 rb0430a6  
    99        new attributes 'pseudo' 'logintty' and 'loginhost'
    1010        Don't print extra new lines in popless_file
     11        New zephyr_get_field function
    1112       
    12132.0.14
  • functions.c

    r72836b5 rb0430a6  
    14791479          sprintf(buff, "  Field %i   : ", i+1);
    14801480         
    1481           ptr=owl_zephyr_get_field(n, i+1, &len);
    1482           if (!ptr) break;
     1481          ptr=owl_zephyr_get_field(n, i+1);
     1482          len=strlen(ptr);
    14831483          if (len<30) {
    14841484            strncpy(tmpbuff, ptr, len);
     
    14891489            strcat(tmpbuff, "...");
    14901490          }
     1491          owl_free(ptr);
    14911492         
    14921493          for (j=0; j<strlen(tmpbuff); j++) {
  • message.c

    r5a95b69 rb0430a6  
    714714{
    715715  struct hostent *hent;
    716   int k, len;
    717716  char *ptr, *tmp, *tmp2;
    718717
     
    755754  if (!strcasecmp(n->z_class, "login") || !strcasecmp(n->z_class, OWL_WEBZEPHYR_CLASS)) {
    756755    if (!strcasecmp(n->z_opcode, "user_login") || !strcasecmp(n->z_opcode, "user_logout")) {
    757       ptr=owl_zephyr_get_field(n, 1, &len);
    758       tmp=owl_malloc(len+10);
    759       strncpy(tmp, ptr, len);
    760       tmp[len]='\0';
     756      tmp=owl_zephyr_get_field(n, 1);
    761757      owl_message_set_attribute(m, "loginhost", tmp);
    762758      owl_free(tmp);
    763759
    764       ptr=owl_zephyr_get_field(n, 3, &len);
    765       tmp=owl_malloc(len+10);
    766       strncpy(tmp, ptr, len);
    767       tmp[len]='\0';
     760      tmp=owl_zephyr_get_field(n, 3);
    768761      owl_message_set_attribute(m, "logintty", tmp);
    769762      owl_free(tmp);
     
    786779
    787780  /* set the body */
    788   ptr=owl_zephyr_get_message(n, &k);
    789   tmp=owl_malloc(k+10);
    790   memcpy(tmp, ptr, k);
    791   tmp[k]='\0';
     781  tmp=owl_zephyr_get_message(n);
    792782  if (owl_global_is_newlinestrip(&g)) {
    793783    tmp2=owl_util_stripnewlines(tmp);
  • perlconfig.c

    r27c3a93 rb0430a6  
    2626  HV *h;
    2727  SV *hr;
    28   char *ptr, *ptr2, *blessas;
    29   int len, i, j;
     28  char *ptr, *blessas;
     29  int i, j;
    3030
    3131  if (!m) return &PL_sv_undef;
     
    4343    j=owl_zephyr_get_num_fields(owl_message_get_notice(m));
    4444    for (i=0; i<j; i++) {
    45       ptr=owl_zephyr_get_field(owl_message_get_notice(m), i+1, &len);
    46       ptr2=owl_malloc(len+1);
    47       memcpy(ptr2, ptr, len);
    48       ptr2[len]='\0';
    49       av_push(av_zfields, newSVpvn(ptr2, len));
    50       owl_free(ptr2);
     45      ptr=owl_zephyr_get_field(owl_message_get_notice(m), i+1);
     46      av_push(av_zfields, newSVpvn(ptr, strlen(ptr)));
     47      owl_free(ptr);
    5148    }
    5249    hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);
  • zephyr.c

    r5a95b69 rb0430a6  
    257257}
    258258
    259 #ifdef HAVE_LIBZEPHYR
    260 char *owl_zephyr_get_field(ZNotice_t *n, int j, int *k)
    261 {
    262   /* return a pointer to the Jth field, place the length in k.  If the
    263      field doesn't exist return an emtpy string */
     259/* return a pointer to the data in the Jth field, (NULL terminated by
     260 * definition).  Caller must free the return.
     261 */
     262#ifdef HAVE_LIBZEPHYR
     263char *owl_zephyr_get_field(ZNotice_t *n, int j)
     264{
    264265  int i, count, save;
     266  char *out;
    265267
    266268  count=save=0;
     
    270272      if (count==j) {
    271273        /* just found the end of the field we're looking for */
    272         *k=i-save;
    273         return(n->z_message+save);
     274        return(owl_strdup(n->z_message+save));
    274275      } else {
    275276        save=i+1;
     
    277278    }
    278279  }
    279   /* catch the last field */
     280  /* catch the last field, which might not be null terminated */
    280281  if (count==j-1) {
    281     *k=n->z_message_len-save;
    282     return(n->z_message+save);
    283   }
    284  
    285   *k=0;
    286   return("");
     282    out=owl_malloc(n->z_message_len-save+5);
     283    memcpy(out, n->z_message+save, n->z_message_len-save);
     284    out[n->z_message_len-save]='\0';
     285    return(out);
     286  }
     287
     288  return(owl_strdup(""));
    287289}
    288290#else
    289291char *owl_zephyr_get_field(void *n, int j, int *k)
    290292{
    291   return("");
    292 }
    293 #endif
     293  return(owl_strdup(""));
     294}
     295#endif
     296
    294297
    295298#ifdef HAVE_LIBZEPHYR
     
    313316
    314317#ifdef HAVE_LIBZEPHYR
    315 char *owl_zephyr_get_message(ZNotice_t *n, int *k)
    316 {
    317   /* return a pointer to the message, place the message length in k */
     318/* return a pointer to the message, place the message length in k */
     319char *owl_zephyr_get_message(ZNotice_t *n)
     320{
    318321  if (!strcasecmp(n->z_opcode, "ping")) {
    319     *k=0;
    320322    return("");
    321323  }
    322324
    323   return(owl_zephyr_get_field(n, 2, k));
     325  return(owl_zephyr_get_field(n, 2));
    324326}
    325327#endif
     
    793795}
    794796 
    795 
    796797/* Strip a local realm fron the zephyr user name.
    797798 * The caller must free the return
Note: See TracChangeset for help on using the changeset viewer.