Changeset 3abf28b for text.c


Ignore:
Timestamp:
Jun 1, 2003, 9:11:25 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
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:
75e3879
Parents:
df0d93a
Message:
make smartnarrow work for AIM
  (though it will crash on names with spaces)
don't set an away message by default
better default format
bold them like personal zephyrs
same with terminal bell
do some basic HTML stripping (buggy, in progress)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • text.c

    r1aee7d9 r3abf28b  
    127127}
    128128
     129
     130/* caller must free the return */
     131char *owl_text_htmlstrip(char *in) {
     132  char *ptr1, *end, *ptr2, *ptr3, *out;
     133
     134  out=owl_malloc(strlen(in)+30);
     135  strcpy(out, "");
     136
     137  ptr1=in;
     138  end=in+strlen(in);
     139 
     140  while(ptr1<end) {
     141    /* look for an open bracket */
     142    ptr2=strchr(ptr1, '<');
     143
     144    /* if not, copy in from here to end and exit */
     145    if (ptr2==NULL) {
     146      strcat(out, ptr1);
     147      return(out);
     148    }
     149
     150    /* otherwise copy in everything before the open bracket */
     151    if (ptr2>ptr1) {
     152      strncat(out, ptr1, ptr2-ptr1);
     153    }
     154
     155    /* find the close bracket */
     156    ptr3=strchr(ptr2, '>');
     157   
     158    /* if there is no close, copy as you are and exit */
     159    if (!ptr3) {
     160      strcat(out, ptr2);
     161    }
     162
     163    /* look for things we know */
     164    if (!strncasecmp(ptr2, "<BODY ", 6) ||
     165        !strncasecmp(ptr2, "<FONT ", 6) ||
     166        !strncasecmp(ptr2, "<HTML", 5) ||
     167        !strncasecmp(ptr2, "</FONT", 6) ||
     168        !strncasecmp(ptr2, "</HTML", 6) ||
     169        !strncasecmp(ptr2, "</BODY", 6)) {
     170
     171      /* advance to beyond the angle brakcet and go again */
     172      ptr1=ptr3+1;
     173      continue;
     174    }
     175
     176    /* if it wasn't something we know, copy to the > and  go again */
     177    strncat(out, ptr2, ptr3-ptr2);
     178    ptr1=ptr3+1;
     179  }
     180  return(out);
     181}
Note: See TracChangeset for help on using the changeset viewer.