Beispiel #1
0
char *
url_from_user_input(const char *arg)
{
    /* If it is already a URL, return the argument as is. */
    if (has_scheme(arg) || !strcasecmp(arg, "about:blank"))
        return strdup(arg);

    Eina_Strbuf *buf = eina_strbuf_manage_new(eina_file_path_sanitize(arg));

    /* Check if the path exists. */
    if (ecore_file_exists(eina_strbuf_string_get(buf))) {
        /* File exists, convert local path to a URL. */
        eina_strbuf_prepend(buf, "file://");
    } else {
        /* The path does not exist, convert it to a URL by
           prepending http:// scheme:
           www.google.com -> http://www.google.com */
         eina_strbuf_string_free(buf);
         eina_strbuf_append_printf(buf, "http://%s", arg);
    }
    char *url = eina_strbuf_string_steal(buf);
    eina_strbuf_free(buf);

    return url;
}
static Eina_Bool
_forecasts_server_del(void *data, int type, void *event)
{
   Instance *inst;
   Ecore_Con_Event_Server_Del *ev;
   int ret;

   inst = data;
   ev = event;
   if ((!inst->server) || (inst->server != ev->server))
     return EINA_TRUE;

   ecore_con_server_del(inst->server);
   inst->server = NULL;

   ret = _forecasts_parse(inst);
   _forecasts_converter(inst);
   _forecasts_display_set(inst, ret);

   eina_strbuf_string_free(inst->buffer);

   return EINA_FALSE;
}