Esempio n. 1
0
char *hexencode_string(const char *str)
{
    size_t orig_len, new_len, i;
    GString *s;
    gchar *ret;
    if (!str) {
        s = g_string_sized_new(0);
        goto cleanup;
    }
    new_len = orig_len = strlen(str);
    for (i = 0; i < orig_len; i++) {
        if (!g_ascii_isalnum(str[i])) {
            new_len += 2;
        }
    }
    s = g_string_sized_new(new_len);

    for (i = 0; i < orig_len; i++) {
        if (g_ascii_isalnum(str[i])) {
            g_string_append_c(s, str[i]);
        } else {
            g_string_append_printf(s, "%%%02hhx", str[i]);
        }
    }

cleanup:
    ret = s->str;
    g_string_free(s, FALSE);
    return ret;
}
/**
 * hildon_helper_smart_match:
 * @haystack: a string where to find a match
 * @needle: what to find
 *
 * Searches for the first occurence of @needle in @haystack. The search
 * is performed only in the first alphanumeric character after a
 * sequence of non-alphanumeric ones. This allows smart matching of words
 * inside more complex strings.
 *
 * If @haystack itself doesn't start with an alphanumeric character,
 * then the search is equivalent to strcasecmp().
 *
 * To make the best of this method, it is recommended that both the needle
 * and the haystack are already normalized as ASCII strings. For this, you
 * should call hildon_helper_normalize_string() on both strings.
 *
 * Returns: a pointer to the first occurence of @needle in @haystack or %NULL
 * if not found
 **/
gchar *
hildon_helper_smart_match (const gchar *haystack, const gchar *needle)
{
    if (haystack == NULL) return NULL;
    if (needle == NULL) return NULL;
    if (strlen (haystack) == 0) return NULL;

    gboolean skip_separators = g_ascii_isalnum (needle[0]);

    if (skip_separators) {
        gint i = 0;
        while (haystack[i] != '\0') {
            while (haystack[i] != '\0' && !g_ascii_isalnum (haystack[i]))
                i++;
            if (g_ascii_strncasecmp (haystack + i, needle, strlen (needle)) == 0) {
                return (gchar *)haystack + i;
            }
            while (g_ascii_isalnum (haystack[i]))
                   i++;
        }
    } else {
        return strcasestr (haystack, needle);
    }

    return NULL;
}
Esempio n. 3
0
gchar *
get_gsettings_name (GstMixer *mixer, GstMixerTrack *track)
{
  const gchar *dev;
  gchar *res;
  gint i, pos;
  gchar *label = NULL;

  g_return_val_if_fail(mixer != NULL, NULL);

  dev = g_object_get_data (G_OBJECT (mixer),
			   "mate-volume-control-name");
  if (track != NULL) {
    label = g_strdup (track->label);
  } else {
    label = g_strdup ("");
  }

  pos = 0;
  res = g_new (gchar, strlen (dev) + 1 + strlen (label) + 1);

  for (i = 0; dev[i] != '\0'; i++) {
    if (g_ascii_isalnum (dev[i]))
      res[pos++] = dev[i];
  }
  res[pos] = '/';
  for (i = 0; label[i] != '\0'; i++) {
    if (g_ascii_isalnum (label[i]))
      res[pos++] = label[i];
  }
  res[pos] = '\0';

  g_free (label);
  return res;
}
Esempio n. 4
0
gboolean
r_parser_email(gchar *str, gint *len, const gchar *param, gpointer state, RParserMatch *match)
{
  gint end;
  int count = 0;

  const gchar *email = "!#$%&'*+-/=?^_`{|}~.";

  *len = 0;

  if (param)
    while (strchr(param, str[*len]))
      (*len)++;

  if (match)
    match->ofs = *len;

  /* first character of e-mail can not be a period */
  if (str[*len] == '.')
    return FALSE;

  while (g_ascii_isalnum(str[*len]) || (strchr(email, str[*len])))
    (*len)++;
  /* last character of e-mail can not be a period */
  if (str[*len-1] == '.')
    return FALSE;

  if (str[*len] == '@' )
    (*len)++;
  else
    return FALSE;

  /* Be accepting of any hostnames - if they are in the logs, they
     probably were in the DNS */
  while (g_ascii_isalnum(str[*len]) || (str[*len] == '-' ))
    {
      (*len)++;
      count++;
      while (g_ascii_isalnum(str[*len]) || (str[*len] == '-' ))
        (*len)++;

      if (str[*len] == '.')
        (*len)++;
    }
  if (count < 2)
    return FALSE;

  end = *len;
  if (param)
    while (strchr(param, str[*len]))
      (*len)++;

  if (match)
    match->len = end - *len - match->ofs;

  if (*len > 0)
    return TRUE;
  return FALSE;
}
Esempio n. 5
0
static gboolean
parse_parameters (const gchar *argument, gint index, gint *parsed_position,
                  GHashTable **parameters, GError **error)
{
    gint local_index = 0;

    while (argument[index + local_index] == ' ') {
        gint i, current_argument_index;
        gint keyword_length, value_length = 0;
        const gchar *keyword, *value = NULL;

        current_argument_index = index + local_index + 1;
        keyword = argument + current_argument_index;
        if (!keyword[0])
            RETURN_ERROR_WITH_POSITION("parameter keyword is missing",
                                       argument, current_argument_index);
        if (!g_ascii_isalnum(keyword[0]))
            RETURN_ERROR_WITH_POSITION("parameter keyword should start with "
                                       "alphabet or digit",
                                       argument, current_argument_index);

        i = 1;
        while (g_ascii_isalnum(keyword[i]) || keyword[i] == '-') {
            i++;
        }
        keyword_length = i;

        if (keyword[i] == '=') {
            gint j = 0;

            value = keyword + i + 1;
            while (g_ascii_isgraph(value[j]) && value[j] != '=') {
                j++;
            }
            value_length = j;
            i += 1 + j;
        }

        if (parameters) {
            if (!*parameters)
                *parameters = g_hash_table_new_full(g_str_hash,
                                                    g_str_equal,
                                                    g_free,
                                                    g_free);
            g_hash_table_insert(*parameters,
                                g_strndup(keyword, keyword_length),
                                value ? g_strndup(value, value_length) : NULL);
        }

        local_index += i + 1;
    }

    *parsed_position = local_index;
    return TRUE;
}
Esempio n. 6
0
static gboolean
parse_domain (const gchar *argument, gint index, gint *parsed_position,
              GError **error)
{
    gint i;
    const gchar *domain;

    domain = argument + index;
    if (domain[0] == '[') {
        i = 1;
        while (TRUE) {
            if (domain[i] == '[' || domain[i] == ']') {
                break;
            } else if (domain[i] == '\\') {
                i++;
                if (IS_TEXT(domain[i])) {
                    i++;
                } else {
                    RETURN_ERROR_WITH_POSITION("invalid quoted character "
                                               "in domain",
                                               argument, index + i);
                }
            } else if (g_ascii_isspace(domain[i])) {
                break;
            } else if (g_ascii_iscntrl(domain[i]) ||
                       g_ascii_isgraph(domain[i])) {
                i++;
            } else {
                break;
            }
        }
        if (domain[i] != ']')
            RETURN_ERROR_WITH_POSITION("terminate ']' is missing in domain",
                                       argument, index + i);
        i++;
    } else {
        i = 0;
        if (!g_ascii_isalnum(domain[i]))
            RETURN_ERROR_WITH_POSITION("domain should start with "
                                       "alphabet or digit",
                                       argument, index + i);
        do {
            i++;
            while (g_ascii_isalnum(domain[i]) || domain[i] == '-') {
                i++;
            }
        } while (domain[i] == '.');
    }

    *parsed_position = i;
    return TRUE;
}
/******************************************************
 * The video4linux command line tool v4l2-ctrl
 * normalises the names of the controls received from
 * the kernel like:
 *
 *     "Exposure (absolute)" -> "exposure_absolute"
 *
 * We follow their lead here.  @name is modified
 * in-place.
 ******************************************************/
static void
gst_v4l2_normalise_control_name (gchar * name)
{
  int i, j;
  for (i = 0, j = 0; name[j]; ++j) {
    if (g_ascii_isalnum (name[j])) {
      if (i > 0 && !g_ascii_isalnum (name[j - 1]))
        name[i++] = '_';
      name[i++] = g_ascii_tolower (name[j]);
    }
  }
  name[i++] = '\0';
}
Esempio n. 8
0
static int
fhReadAnyAlphNumString(FileHelper * fh)
{
    char c = fhPeekNextChar(fh);
    if (!g_ascii_isalnum(c))
        return FALSE;
    do {
        c = fhPeekNextChar(fh);
        if (!g_ascii_isalnum(c) && c != '_')
            return fhPeekNextIsWS(fh);
    } while (fhReadNextChar(fh) != '\0');
    return TRUE;
}
Esempio n. 9
0
static gboolean
word_check_right(gchar c)
{
	if (g_ascii_isalnum(c) || c == '_')
		return TRUE;
	return FALSE;
}
/* allocates space and returns the index part of a string */
static char *
_new_get_index(const char *_string)
{
	if (!_string)
		return NULL;

	size_t size;
	gunichar u;
	char *string = NULL;

	if (g_ascii_isalnum(_string[0])) {
		size = sizeof(char);
		string = malloc(size+1);
		string[0] = g_ascii_toupper(_string[0]);
	} else {
		u = g_utf8_get_char_validated(_string, -1);
		if ((u != (gunichar)-1 || u != (gunichar)-2) && g_unichar_isalnum(u)) {
			u = g_unichar_toupper(u);
			size = g_unichar_to_utf8(u, NULL);
			string = malloc(size+1);
			g_unichar_to_utf8(u, string);
		}
	}

	if (string)
		string[size] = '\0';

	return string;
}
Esempio n. 11
0
static const gchar *read_name(const gchar *s, char *id, gsize sz, int line, GError **error)
{
	char b[16];
	gsize i = 0;

	if (!g_ascii_isalpha(s[0]) && s[0] != '$') {
		strncpy(b, s, sizeof(b) - 1);
		b[sizeof(b) - 1] = 0;
		g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Invalid character at line %d `%s'", line, b);
		return NULL;
	}

	while (i < sz && (g_ascii_isalnum(s[i]) || s[i] == '_' || s[i] == '$')) {
		id[i] = s[i];
		i++;
	}

	if (i == sz) {
		id[sz - 1] = 0;
		g_set_error(error, ROBOT_ERROR, ROBOT_ERROR_SYNTAX, "Invalid identifier of size more then %u at line %d `%s...'", (unsigned)sz, line, id);
		return NULL;
	}

	id[i] = 0;

	return s + i;
}
Esempio n. 12
0
static void
autocomplete_protocol_string(GtkWidget *filter_te, gchar *selected_str)
{
  int pos;
  gchar *filter_str;
  gchar *pch;

  /* Get the current filter string */
  pos = gtk_editable_get_position(GTK_EDITABLE(filter_te));
  filter_str = gtk_editable_get_chars(GTK_EDITABLE(filter_te), 0, pos);

  /* Start from the end */
  pch = filter_str + strlen(filter_str);

  /* Walk back through string to find last non-punctuation */
  while(pch != filter_str) {
    pch--;
    if(!g_ascii_isalnum(*pch) && (*pch) != '.' && (*pch) != '_' && (*pch) != '-') {
      pch++;
      break;
    }
  }

  if(strncmp(pch, selected_str, pos-(pch-filter_str))) {
    gtk_editable_delete_text(GTK_EDITABLE(filter_te), (gint) (pch-filter_str), pos);
    pos = (int) (pch-filter_str);
    pch = selected_str;
  } else {
    pch = (selected_str + strlen(pch));
  }

  gtk_editable_insert_text(GTK_EDITABLE(filter_te), pch, (gint) strlen(pch), &pos);
  gtk_editable_set_position(GTK_EDITABLE(filter_te), pos);
  g_free (filter_str);
}
Esempio n. 13
0
G_GNUC_PURE
static bool
valid_channel_char(const char ch)
{
	return g_ascii_isalnum(ch) ||
		ch == '_' || ch == '-' || ch == '.' || ch == ':';
}
Esempio n. 14
0
static gboolean
gst_caps_feature_name_is_valid (const gchar * feature)
{
#ifndef G_DISABLE_CHECKS
  while (TRUE) {
    if (g_ascii_isalpha (*feature))
      feature++;
    else if (*feature == ':')
      break;
    else
      return FALSE;
  }

  if (*feature != ':')
    return FALSE;

  feature++;
  if (*feature == '\0' || !g_ascii_isalpha (*feature))
    return FALSE;

  while (TRUE) {
    if (g_ascii_isalnum (*feature))
      feature++;
    else if (*feature == '\0')
      break;
    else
      return FALSE;
  }
#endif

  return TRUE;
}
Esempio n. 15
0
static gchar*
uri_encode_password (const gchar *value)
{
	gchar *p;
	gchar *result;

	/* Just allocate for worst case */
	result = egg_secure_alloc ((strlen (value) * 3) + 1);

	/* Now loop through looking for escapes */
	p = result;
	while (*value) {

		/* These characters we let through verbatim */
		if (*value && (g_ascii_isalnum (*value) || strchr ("_-.", *value) != NULL)) {
			*(p++) = *(value++);

		/* All others get encoded */
		} else {
			*(p++) = '%';
			*(p++) = HEXC[((unsigned char)*value) >> 4];
			*(p++) = HEXC[((unsigned char)*value) & 0x0F];
			++value;
		}
	}

	*p = 0;
	return result;
}
static gchar *
sanitize_str (const gchar *str)
{
    GString *retstr = g_string_sized_new(strlen(str));
    gchar *realstr, c = '\0';

    while((c = *str++))
    {        
        if (g_ascii_isspace(c))
            g_string_append(retstr, "%20");
        else if (g_ascii_isalnum(c) == FALSE)
        {
            g_string_free(retstr, TRUE);
            return NULL;
        }
        else
            g_string_append_c(retstr, c);
    }

    realstr = retstr->str;

    g_string_free(retstr, FALSE);

       

    return realstr;
}
Esempio n. 17
0
static gboolean
crank_str_g_isalnum (const gchar value,
                     gpointer    userdata)
{
    return g_ascii_isalnum (value);
    // That function is 'macro', so it cannot used as function.
}
Esempio n. 18
0
guint16
is_asciitpkt(tvbuff_t *tvb)
{
    guint16 count;
        /*
         * If TPKT is disabled, don't dissect it, just return -1, meaning
         * "this isn't TPKT".
         */
    if (!proto_is_protocol_enabled(proto_tpkt_ptr))
       return -1;

          /* There should at least be 8 bytes left in the frame */
    if (!tvb_bytes_exist(tvb, 0, 8))
        return -1;      /* there aren't */

        /*
         * The first four  octets should be alphanumeric ASCII
         */
    for (count = 0; count <=7 ; count ++)
        {
        if(!g_ascii_isalnum(tvb_get_guint8(tvb,count)))
          {
          return 0;
          }
        }
     return 1;


}
Esempio n. 19
0
gchar *
gebr_geoxml_line_create_key(const gchar *title)
{
	gchar *lower_no_accents = g_utf8_strdown(title, -1);
	lower_no_accents = gebr_g_string_remove_accents(lower_no_accents);
	GString *buffer = g_string_new(NULL);
	gchar *tmp = lower_no_accents;
	gunichar c;

	for (; tmp && *tmp; tmp = g_utf8_next_char(tmp)) {
		c = g_utf8_get_char(tmp);

		if (c == ' ' || !g_ascii_isalnum((char)c)) {
			g_string_append_c(buffer, '_');
		} else {
			gchar str[7];
			gint len = g_unichar_to_utf8(c, str);
			g_string_append_len(buffer, str, len);
		}
	}
	g_string_append_c(buffer, '\0');

	g_free(lower_no_accents);
	return g_string_free(buffer, FALSE);
}
Esempio n. 20
0
gboolean daemon_helpers_typehelper_IsNumeric (const gchar* text) {
	gboolean result = FALSE;
	g_return_val_if_fail (text != NULL, FALSE);
	{
		gint i;
		i = 0;
		{
			gboolean _tmp0_;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp1_;
				gchar _tmp2_;
				gboolean _tmp3_;
				if (!_tmp0_) {
					i++;
				}
				_tmp0_ = FALSE;
				_tmp1_ = strlen (text);
				if (!(i < _tmp1_)) {
					break;
				}
				_tmp2_ = string_get (text, (glong) i);
				_tmp3_ = g_ascii_isalnum (_tmp2_);
				if (!_tmp3_) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}
Esempio n. 21
0
/* Match a file suffix defined by this regular expression: /(\.[A-Za-z~][A-Za-z0-9~]*)*$/
 *
 * @str pointer to string to scan.
 *
 * @return pointer to the matching suffix, or NULL if not found.
 *         Upon return, @str points to terminating NUL.
 */
static const char *
match_suffix (const char **str)
{
    const char *match = NULL;
    gboolean read_alpha = FALSE;

    while (**str != '\0')
    {
        if (read_alpha)
        {
            read_alpha = FALSE;
            if (!g_ascii_isalpha (**str) && **str != '~')
                match = NULL;
        }
        else if (**str == '.')
        {
            read_alpha = TRUE;
            if (match == NULL)
                match = *str;
        }
        else if (!g_ascii_isalnum (**str) && **str != '~')
            match = NULL;
        (*str)++;
    }

    return match;
}
Esempio n. 22
0
/**
 * xed_message_type_is_valid_object_path:
 * @object_path: (allow-none): the object path
 *
 * Returns whether @object_path is a valid object path
 *
 * Return value: %TRUE if @object_path is a valid object path
 *
 */
gboolean
xed_message_type_is_valid_object_path (const gchar *object_path)
{
	if (!object_path)
		return FALSE;
	
	/* needs to start with / */
	if (*object_path != '/')
		return FALSE;
	
	while (*object_path)
	{
		if (*object_path == '/')
		{
			++object_path;
			
			if (!*object_path || !(g_ascii_isalpha (*object_path) || *object_path == '_'))
				return FALSE;
		}
		else if (!(g_ascii_isalnum (*object_path) || *object_path == '_'))
		{
			return FALSE;
		}
		
		++object_path;
	}
	
	return TRUE;
}
static gboolean
grab_request_options (GPtrArray *store, const char* line)
{
	char **areq, **aiter;
	gboolean end = FALSE;

	/* Grab each 'request' or 'also request'  option and save for later */
	areq = g_strsplit_set (line, "\t ,", -1);
	for (aiter = areq; aiter && *aiter; aiter++) {
		if (!strlen (g_strstrip (*aiter)))
			continue;

		if (*aiter[0] == ';') {
			/* all done */
			end = TRUE;
			break;
		}

		if (!g_ascii_isalnum ((*aiter)[0]))
			continue;

		if ((*aiter)[strlen (*aiter) - 1] == ';') {
			/* Remove the EOL marker */
			(*aiter)[strlen (*aiter) - 1] = '\0';
			end = TRUE;
		}

		add_request (store, *aiter);
	}

	if (areq)
		g_strfreev (areq);

	return end;
}
Esempio n. 24
0
gboolean is_valid_apn(const char *apn)
{
	int i;
	int last_period = 0;

	if (apn[0] == '.' || apn[0] == '\0')
		return FALSE;

	for (i = 0; apn[i] != '\0'; i++) {
		if (g_ascii_isalnum(apn[i]))
			continue;

		if (apn[i] == '-')
			continue;

		if (apn[i] == '.' && (i - last_period) > 1) {
			last_period = i;
			continue;
		}

		return FALSE;
	}

	return TRUE;
}
Esempio n. 25
0
static gchar *
_stat_name (const char *prefix, const char *tail, gchar *d, gsize dlen)
{
	if (g_str_has_prefix(tail, P))
		dlen = g_snprintf (d, dlen, "%s.%s", prefix, tail+sizeof(P)-1);
	else if (g_str_has_prefix(tail, PROXYD_PREFIX))
		dlen = g_snprintf (d, dlen, "%s.%s", prefix, tail+sizeof(PROXYD_PREFIX)-1);
	else
		dlen = g_snprintf (d, dlen, "%s.%s", prefix, tail);

	/* replace ugly characters by '_' */
	for (int i=strlen (prefix)+1; d[i] ;++i) {
		if (!g_ascii_isalnum (d[i]))
			d[i]='_';
	}

	gchar *s;
	/* agregate subsequent '_' */
	while (NULL != (s = g_strrstr_len(d, dlen, "__"))) {
		for (;*s;++s)
			*s = *(s+1);
	}

	return d;
}
Esempio n. 26
0
static void
value_pairs_parse_type(gchar *spec, gchar **value, gchar **type)
{
  char *sp, *ep;

  *type = NULL;
  sp = spec;

  while (g_ascii_isalnum(*sp) || (*sp) == '_')
    sp++;

  while (*sp == ' ' || *sp == '\t')
    sp++;

  if (*sp != '(' ||
      !((g_ascii_toupper(spec[0]) >= 'A' &&
         g_ascii_toupper(spec[0]) <= 'Z') ||
        spec[0] == '_'))
    {
      *value = spec;
      return;
    }

  ep = strchr(sp, ')');
  if (ep == NULL || ep[1] != '\0')
    {
      *value = spec;
      return;
    }

  *value = sp + 1;
  *type = spec;
  sp[0] = '\0';
  ep[0] = '\0';
}
Esempio n. 27
0
static const gchar *
get_method_string (const gchar *substring, gchar **method_string)
{
	const gchar *p;
	char *method;

	for (p = substring;
	     g_ascii_isalnum (*p) || *p == '+' || *p == '-' || *p == '.';
	     p++)
		;

	if (*p == ':'
#ifdef G_OS_WIN32
	              &&
	    !(p == substring + 1 && g_ascii_isalpha (*substring))
#endif
								 ) {
		/* Found toplevel method specification.  */
		method = g_strndup (substring, p - substring);
		*method_string = g_ascii_strdown (method, -1);
		g_free (method);
		p++;
	} else {
		*method_string = g_strdup ("file");
		p = substring;
	}
	return p;
}
Esempio n. 28
0
File: learn.c Progetto: CTU-OSP/mc
static gboolean
learn_check_key (int c)
{
    int i;

    for (i = 0; i < learn_total; i++)
    {
        if (key_name_conv_tab[i].code != c || learnkeys[i].ok)
            continue;

        dlg_select_widget (learnkeys[i].button);
        /* TRANSLATORS: This label appears near learned keys.  Keep it short.  */
        label_set_text (LABEL (learnkeys[i].label), _("OK"));
        learnkeys[i].ok = TRUE;
        learnok++;
        if (learnok >= learn_total)
        {
            learn_dlg->ret_value = B_CANCEL;
            if (learnchanged)
            {
                if (query_dialog (learn_title,
                                  _
                                  ("It seems that all your keys already\n"
                                   "work fine. That's great."), D_ERROR, 2,
                                  _("&Save"), _("&Discard")) == 0)
                    learn_dlg->ret_value = B_ENTER;
            }
            else
            {
                message (D_ERROR, learn_title,
                         _
                         ("Great! You have a complete terminal database!\n"
                          "All your keys work well."));
            }
            dlg_stop (learn_dlg);
        }
        return TRUE;
    }

    switch (c)
    {
    case KEY_LEFT:
    case 'h':
        return learn_move (FALSE);
    case KEY_RIGHT:
    case 'l':
        return learn_move (TRUE);
    case 'j':
        dlg_one_down (learn_dlg);
        return TRUE;
    case 'k':
        dlg_one_up (learn_dlg);
        return TRUE;
    }

    /* Prevent from disappearing if a non-defined sequence is pressed
       and contains a button hotkey.  Only recognize hotkeys with ALT.  */
    return (c < 255 && g_ascii_isalnum (c));
}
Esempio n. 29
0
static gboolean bee_irc_user_new(bee_t *bee, bee_user_t *bu)
{
	irc_user_t *iu;
	irc_t *irc = (irc_t *) bee->ui_data;
	char nick[MAX_NICK_LENGTH + 1], *s;

	memset(nick, 0, MAX_NICK_LENGTH + 1);
	strncpy(nick, nick_get(bu), MAX_NICK_LENGTH);

	bu->ui_data = iu = irc_user_new(irc, nick);
	iu->bu = bu;

	if (set_getbool(&irc->b->set, "private")) {
		iu->last_channel = NULL;
	} else {
		iu->last_channel = irc_channel_with_user(irc, iu);
	}

	if ((s = strchr(bu->handle, '@'))) {
		iu->host = g_strdup(s + 1);
		iu->user = g_strndup(bu->handle, s - bu->handle);
	} else {
		iu->user = g_strdup(bu->handle);
		if (bu->ic->acc->server) {
			iu->host = g_strdup(bu->ic->acc->server);
		} else {
			char *s;
			for (s = bu->ic->acc->tag; g_ascii_isalnum(*s); s++) {
				;
			}
			/* Only use the tag if we got to the end of the string.
			   (So allow alphanumerics only. Hopefully not too
			   restrictive.) */
			if (*s) {
				iu->host = g_strdup(bu->ic->acc->prpl->name);
			} else {
				iu->host = g_strdup(bu->ic->acc->tag);
			}
		}
	}

	while ((s = strchr(iu->user, ' '))) {
		*s = '_';
	}

	if (bu->flags & BEE_USER_LOCAL) {
		char *s = set_getstr(&bee->set, "handle_unknown");

		if (strcmp(s, "add_private") == 0) {
			iu->last_channel = NULL;
		} else if (strcmp(s, "add_channel") == 0) {
			iu->last_channel = irc->default_channel;
		}
	}

	iu->f = &irc_user_im_funcs;

	return TRUE;
}
Esempio n. 30
0
static void
_purify_header (gchar *k)
{
	for (gchar *p = k; *p ;++p) {
		if (*p != '-' && !g_ascii_isalnum(*p))
			*p = '-';
	}
}