adium: fix some #import paths
[siplcs.git] / src / miranda / miranda-markup.c
blob3cd6d05fc8079d84172c06e247e5e91be0763e2a
1 /**
2 * @file miranda-markup.c
4 * pidgin-sipe
6 * Copyright (C) 2010-11 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "glib.h"
25 #include <string.h>
27 #include "sipe-backend.h"
29 gchar *sipe_backend_markup_css_property(const gchar *style,
30 const gchar *opt)
32 const gchar *css_str = style;
33 const gchar *css_value_start;
34 const gchar *css_value_end;
35 gchar *tmp;
36 gchar *ret;
38 g_return_val_if_fail(opt != NULL, NULL);
40 if (!css_str)
41 return NULL;
43 /* find the CSS property */
44 while (1)
46 /* skip whitespace characters */
47 while (*css_str && g_ascii_isspace(*css_str))
48 css_str++;
49 if (!g_ascii_isalpha(*css_str))
50 return NULL;
51 if (g_ascii_strncasecmp(css_str, opt, strlen(opt)))
53 /* go to next css property positioned after the next ';' */
54 while (*css_str && *css_str != '"' && *css_str != ';')
55 css_str++;
56 if(*css_str != ';')
57 return NULL;
58 css_str++;
60 else
61 break;
64 /* find the CSS value position in the string */
65 css_str += strlen(opt);
66 while (*css_str && g_ascii_isspace(*css_str))
67 css_str++;
68 if (*css_str != ':')
69 return NULL;
70 css_str++;
71 while (*css_str && g_ascii_isspace(*css_str))
72 css_str++;
73 if (*css_str == '\0' || *css_str == '"' || *css_str == ';')
74 return NULL;
76 /* mark the CSS value */
77 css_value_start = css_str;
78 while (*css_str && *css_str != '"' && *css_str != ';')
79 css_str++;
80 css_value_end = css_str - 1;
82 /* Removes trailing whitespace */
83 while (css_value_end > css_value_start && g_ascii_isspace(*css_value_end))
84 css_value_end--;
86 tmp = g_strndup(css_value_start, css_value_end - css_value_start + 1);
87 // ret = purple_unescape_html(tmp);
88 // g_free(tmp);
89 ret = tmp;
91 return ret;
94 gchar *sipe_backend_markup_strip_html(const gchar *html)
96 char *tmp = g_malloc(strlen(html)+1);
97 const char *src;
98 char *tgt;
99 gboolean in_tag = FALSE;
101 for ( src=html, tgt=tmp ; *src ; src++ )
103 if (*src == '<') in_tag = TRUE;
104 if (!in_tag) *tgt++ = *src;
105 if (*src == '>') in_tag = FALSE;
107 *tgt = '\0';
109 tgt = g_strdup(tmp);
110 g_free(tmp);
111 return tgt;
115 Local Variables:
116 mode: c
117 c-file-style: "bsd"
118 indent-tabs-mode: t
119 tab-width: 8
120 End: