Changeset 5376a95 for zephyr.c


Ignore:
Timestamp:
Dec 28, 2007, 5:04:34 PM (13 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
6201646
Parents:
925e122
Message:
First pass at incoming zephyr -> UTF-8 sanitizing.
This only operates on incoming data so far.
We still need to clean outgoing data -- the plan is to attempt conversion
to ISO-8859-1, and use that if it works.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    r50e29e3 r5376a95  
    354354  return(owl_strdup(""));
    355355}
     356
     357char *owl_zephyr_get_field_as_utf8(ZNotice_t *n, int j)
     358{
     359  int i, count, save;
     360
     361  /* If there's no message here, just run along now */
     362  if (n->z_message_len == 0)
     363    return(owl_strdup(""));
     364
     365  count=save=0;
     366  for (i = 0; i < n->z_message_len; i++) {
     367    if (n->z_message[i]=='\0') {
     368      count++;
     369      if (count == j) {
     370        /* just found the end of the field we're looking for */
     371        return(owl_validate_or_convert(n->z_message + save, -1));
     372      } else {
     373        save = i + 1;
     374      }
     375    }
     376  }
     377  /* catch the last field, which might not be null terminated */
     378  if (count == j - 1) {
     379    return owl_validate_or_convert(n->z_message + save, n->z_message_len - save);
     380  }
     381
     382  return(owl_strdup(""));
     383}
    356384#else
    357385char *owl_zephyr_get_field(void *n, int j)
    358386{
    359387  return(owl_strdup(""));
     388}
     389char *owl_zephyr_get_field_as_utf8(ZNotice_t *n, int j)
     390{
     391  return owl_zephyr_get_field(n, j);
    360392}
    361393#endif
Note: See TracChangeset for help on using the changeset viewer.