Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
html.h File Reference
#include <stddef.h>
#include "gwlib/gwlib.h"

Go to the source code of this file.


Octstrhtml_to_sms (Octstr *html)

Function Documentation

Octstr* html_to_sms ( Octstr html)

Definition at line 283 of file html.c.

References convert_html_entity(), html_comment_begins(), octstr_append_char(), octstr_create, octstr_get_char(), octstr_len(), octstr_shrink_blanks(), octstr_strip_blanks(), skip_html_comment(), and skip_html_tag().

Referenced by smsbox_sendsms_post(), and url_result_thread().

284 {
285  long i, len;
286  int c;
287  Octstr *sms;
289  sms = octstr_create("");
290  len = octstr_len(html);
291  i = 0;
292  while (i < len) {
293  c = octstr_get_char(html, i);
294  switch (c) {
295  case '<':
296  if (html_comment_begins(html, i))
297  skip_html_comment(html, &i);
298  else
299  skip_html_tag(html, &i);
300  break;
301  case '&':
302  convert_html_entity(sms, html, &i);
303  break;
304  default:
305  octstr_append_char(sms, c);
306  ++i;
307  break;
308  }
309  }
311  octstr_strip_blanks(sms);
312  return sms;
313 }
void octstr_append_char(Octstr *ostr, int ch)
Definition: octstr.c:1515
static void skip_html_tag(Octstr *html, long *pos)
Definition: html.c:100
void octstr_strip_blanks(Octstr *text)
Definition: octstr.c:1344
static int html_comment_begins(Octstr *html, long pos)
Definition: html.c:75
#define octstr_create(cstr)
Definition: octstr.h:125
long octstr_len(const Octstr *ostr)
Definition: octstr.c:340
Definition: octstr.c:118
static void convert_html_entity(Octstr *sms, Octstr *html, long *pos)
Definition: html.c:129
int octstr_get_char(const Octstr *ostr, long pos)
Definition: octstr.c:404
void octstr_shrink_blanks(Octstr *text)
Definition: octstr.c:1431
static void skip_html_comment(Octstr *html, long *pos)
Definition: html.c:86
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.