Ejemplo n.º 1
0
static void Http_host_connection_remove(HostConnection_t *hc)
{
    assert(hc->queue.head == NULL);
    dList_remove_fast(host_connections, hc);
    dFree(hc->host);
    dFree(hc);
}
Ejemplo n.º 2
0
/*
 * Memory deallocator (only called at exit time)
 */
void a_Cache_freeall(void)
{
   CacheClient_t *Client;
   void *data;

   /* free the client queue */
   while ((Client = dList_nth_data(ClientQueue, 0)))
      Cache_client_dequeue(Client, NULLKey);

   /* Remove every cache entry */
   while ((data = dList_nth_data(CachedURLs, 0))) {
      dList_remove_fast(CachedURLs, data);
      Cache_entry_free(data);
   }
   /* Remove the cache list */
   dList_free(CachedURLs);
}
Ejemplo n.º 3
0
Archivo: auth.c Proyecto: epitron/dillo
static void Auth_realm_add_path(AuthRealm_t *realm, const char *path)
{
   int len, i;
   char *realm_path, *n_path;

   n_path = dStrdup(path);
   len = strlen(n_path);

   /* remove trailing '/' */
   if (len && n_path[len - 1] == '/')
      n_path[--len] = 0;

   /* delete existing paths that are inside the new one */
   for (i = 0; (realm_path = dList_nth_data(realm->paths, i)); i++) {
      if (Auth_path_is_inside(realm_path, path, len)) {
         dList_remove_fast(realm->paths, realm_path);
         dFree(realm_path);
         i--; /* reconsider this slot */
      }
   }

   dList_append(realm->paths, n_path);
}
Ejemplo n.º 4
0
Archivo: auth.c Proyecto: epitron/dillo
static void Auth_do_auth_dialog_cb(const char *user, const char *password,
                                   void *vData)
{
   AuthDialogData_t *data;
   AuthHost_t *host;
   AuthRealm_t *realm;

   data = (AuthDialogData_t *)vData;

   /* find or create the host */
   if (!(host = Auth_host_by_url(data->url))) {
      /* create a new host */
      host = dNew(AuthHost_t, 1);
      host->scheme = dStrdup(URL_SCHEME(data->url));
      host->authority = dStrdup(URL_AUTHORITY(data->url));
      host->realms = dList_new(1);
      dList_append(auth_hosts, host);
   }

   /* find or create the realm */
   if (!(realm = Auth_realm_by_name(host, data->auth_parse->realm))) {
      realm = dNew0(AuthRealm_t, 1);
      realm->name = dStrdup(data->auth_parse->realm);
      realm->paths = dList_new(1);
      dList_append(host->realms, realm);
   }
   realm->type = data->auth_parse->type;
   dFree(realm->authorization);
   realm->authorization = NULL;

   Auth_realm_add_path(realm, URL_PATH(data->url));

   if (realm->type == BASIC) {
      char *user_password = dStrconcat(user, ":", password, NULL);
      char *response = a_Misc_encode_base64(user_password);
      char *authorization =
         dStrconcat("Authorization: Basic ", response, "\r\n", NULL);
      dFree(realm->authorization);
      realm->authorization = authorization;
      dFree(response);
      dStrshred(user_password);
      dFree(user_password);
   } else if (realm->type == DIGEST) {
      dFree(realm->username);
      realm->username = dStrdup(user);
      realm->nonce_count = 0;
      dFree(realm->nonce);
      realm->nonce = dStrdup(data->auth_parse->nonce);
      dFree(realm->opaque);
      realm->opaque = dStrdup(data->auth_parse->opaque);
      realm->algorithm = data->auth_parse->algorithm;
      dFree(realm->domain);
      realm->domain = dStrdup(data->auth_parse->domain);
      realm->qop = data->auth_parse->qop;
      dFree(realm->cnonce);
      if (realm->qop != QOPNOTSET)
         realm->cnonce = a_Digest_create_cnonce();
      if (!a_Digest_compute_digest(realm, user, password)) {
         MSG("Auth_do_auth_dialog_cb: a_Digest_compute_digest failed.\n");
         dList_remove_fast(host->realms, realm);
         Auth_realm_delete(realm);
      }
   } else {
      MSG("Auth_do_auth_dialog_cb: Unknown auth type: %i\n",
          realm->type);
   }
   dStrshred((char *)password);
}