Exemplo n.º 1
0
static boolean fill_input_buffer(j_decompress_ptr cinfo)
{
   DilloJpeg *jpeg = ((my_source_mgr *) cinfo->src)->jpeg;

   _MSG("fill_input_buffer\n");
#if 0
   if (!cinfo->src->bytes_in_buffer) {
      _MSG("fill_input_buffer: %ld bytes in buffer\n",
           (long)cinfo->src->bytes_in_buffer);

      jpeg->Start_Ofs = (ulong_t) jpeg->cinfo.src->next_input_byte -
         (ulong_t) jpeg->Data;
#endif
      if (jpeg->Skip) {
         jpeg->Start_Ofs = jpeg->NewStart + jpeg->Skip - 1;
         jpeg->Skip = 0;
      } else {
         jpeg->Start_Ofs = (ulong_t) jpeg->cinfo.src->next_input_byte -
            (ulong_t) jpeg->Data;
      }
      return FALSE;
#if 0
   }
   return TRUE;
#endif
}
Exemplo n.º 2
0
/*
 * List tracker PID(s) of session and domain.
 */
static int list_tracker_pids(void)
{
	int enabled, ret;
	int *pids = NULL;
	size_t nr_pids;

	ret = lttng_list_tracker_pids(handle,
		&enabled, &pids, &nr_pids);
	if (ret) {
		return ret;
	}
	if (enabled) {
		int i;
		_MSG("PID tracker: [");

		for (i = 0; i < nr_pids; i++) {
			if (i) {
				_MSG(",");
			}
			_MSG(" %d", pids[i]);
		}
		_MSG(" ]\n\n");
	}
	free(pids);
	return 0;
}
Exemplo n.º 3
0
/*
 * Consume bytes until the whole header is got (up to a "\r\n\r\n" sequence)
 * (Also unfold multi-line fields and strip '\r' chars from header)
 */
static int Cache_get_header(CacheEntry_t *entry,
                            const char *buf, size_t buf_size)
{
   size_t N, i;
   Dstr *hdr = entry->Header;

   /* Header finishes when N = 2 */
   N = (hdr->len && hdr->str[hdr->len - 1] == '\n');
   for (i = 0; i < buf_size && N < 2; ++i) {
      if (buf[i] == '\r' || !buf[i])
         continue;
      if (N == 1 && (buf[i] == ' ' || buf[i] == '\t')) {
         /* unfold multiple-line header */
         _MSG("Multiple-line header!\n");
         dStr_erase(hdr, hdr->len - 1, 1);
      }
      N = (buf[i] == '\n') ? N + 1 : 0;
      dStr_append_c(hdr, buf[i]);
   }

   if (N == 2) {
      /* Got whole header */
      _MSG("Header [buf_size=%d]\n%s", i, hdr->str);
      entry->Flags |= CA_GotHeader;
      dStr_fit(hdr);
      /* Return number of header bytes in 'buf' [1 based] */
      return i;
   }
   return 0;
}
Exemplo n.º 4
0
/*
 * Confirm that the dpid is running. If not, start it.
 * Return: 0 running OK, 1 starting (EAGAIN), 2 Error.
 */
static int Dpi_check_dpid(int num_tries)
{
   static int starting = 0;
   int check_st = 1, ret = 2;

   check_st = Dpi_check_dpid_ids();
   _MSG("Dpi_check_dpid: check_st=%d\n", check_st);

   if (check_st == 1) {
      /* connection test with dpi server passed */
      starting = 0;
      ret = 0;
   } else {
      if (!starting) {
         /* start dpid */
         if (Dpi_start_dpid() == 0) {
            starting = 1;
            ret = 1;
         }
      } else if (++starting < num_tries) {
         /* starting */
         ret = 1;
      } else {
         /* we waited too much, report an error... */
         starting = 0;
      }
   }

   _MSG("Dpi_check_dpid:: %s\n",
        (ret == 0) ? "OK" : (ret == 1 ? "EAGAIN" : "ERROR"));
   return ret;
}
Exemplo n.º 5
0
/*
 * List tracker PID(s) of session and domain.
 */
static int list_tracker_pids(void)
{
	int ret = 0;
	int enabled;
	int *pids = NULL;
	size_t nr_pids;

	ret = lttng_list_tracker_pids(handle,
		&enabled, &pids, &nr_pids);
	if (ret) {
		return ret;
	}
	if (enabled) {
		int i;
		_MSG("PID tracker: [");

		/* Mi tracker_pid element*/
		if (writer) {
			/* Open tracker_pid and targets elements */
			ret = mi_lttng_pid_tracker_open(writer);
			if (ret) {
				goto end;
			}
		}

		for (i = 0; i < nr_pids; i++) {
			if (i) {
				_MSG(",");
			}
			_MSG(" %d", pids[i]);

			/* Mi */
			if (writer) {
				ret = mi_lttng_pid_target(writer, pids[i], 0);
				if (ret) {
					goto end;
				}
			}
		}
		_MSG(" ]\n\n");

		/* Mi close tracker_pid and targets */
		if (writer) {
			ret = mi_lttng_close_multi_element(writer,2);
			if (ret) {
				goto end;
			}
		}
	}
end:
	free(pids);
	return ret;

}
Exemplo n.º 6
0
/*
 * Stop tracing for all traces of the session.
 */
static int _lttng_stop_tracing(const char *session_name, int wait)
{
	int ret, data_ret;
	struct lttcomm_session_msg lsm;

	if (session_name == NULL) {
		return -LTTNG_ERR_INVALID;
	}

	lsm.cmd_type = LTTNG_STOP_TRACE;

	copy_string(lsm.session.name, session_name, sizeof(lsm.session.name));

	ret = ask_sessiond(&lsm, NULL);
	if (ret < 0 && ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED) {
		goto error;
	}

	if (!wait) {
		goto end;
	}

	_MSG("Waiting for data availability");

	/* Check for data availability */
	do {
		data_ret = lttng_data_pending(session_name);
		if (data_ret < 0) {
			/* Return the data available call error. */
			ret = data_ret;
			goto error;
		}

		/*
		 * Data sleep time before retrying (in usec). Don't sleep if the call
		 * returned value indicates availability.
		 */
		if (data_ret) {
			usleep(DEFAULT_DATA_AVAILABILITY_WAIT_TIME);
			_MSG(".");
		}
	} while (data_ret != 0);

	MSG("");

end:
error:
	return ret;
}
Exemplo n.º 7
0
/*
 * Process redirections (HTTP 30x answers)
 * (This is a work in progress --not finished yet)
 */
static int Cache_redirect(CacheEntry_t *entry, int Flags, BrowserWindow *bw)
{
   DilloUrl *NewUrl;

   _MSG(" Cache_redirect: redirect_level = %d\n", bw->redirect_level);

   /* Don't allow redirection for SpamSafe/local URLs */
   if (URL_FLAGS(entry->Url) & URL_SpamSafe) {
      a_UIcmd_set_msg(bw, "WARNING: local URL with redirection.  Aborting.");
      return 0;
   }

   /* if there's a redirect loop, stop now */
   if (bw->redirect_level >= 5)
      entry->Flags |= CA_RedirectLoop;

   if (entry->Flags & CA_RedirectLoop) {
      a_UIcmd_set_msg(bw, "ERROR: redirect loop for: %s", URL_STR_(entry->Url));
      bw->redirect_level = 0;
      return 0;
   }

   if ((entry->Flags & CA_Redirect && entry->Location) &&
       (entry->Flags & CA_ForceRedirect || entry->Flags & CA_TempRedirect ||
        !entry->Data->len || entry->Data->len < 1024)) {

      _MSG(">>>> Redirect from: %s\n to %s <<<<\n",
           URL_STR_(entry->Url), URL_STR_(entry->Location));
      _MSG("%s", entry->Header->str);

      if (Flags & WEB_RootUrl) {
         /* Redirection of the main page */
         NewUrl = a_Url_new(URL_STR_(entry->Location), URL_STR_(entry->Url));
         if (entry->Flags & CA_TempRedirect)
            a_Url_set_flags(NewUrl, URL_FLAGS(NewUrl) | URL_E2EQuery);
         a_Nav_push(bw, NewUrl, entry->Url);
         a_Url_free(NewUrl);
      } else {
         /* Sub entity redirection (most probably an image) */
         if (!entry->Data->len) {
            _MSG(">>>> Image redirection without entity-content <<<<\n");
         } else {
            _MSG(">>>> Image redirection with entity-content <<<<\n");
         }
      }
   }
   return 0;
}
Exemplo n.º 8
0
static
void print_timer(const char *timer_name, uint32_t space_count, int64_t value)
{
	uint32_t i;

	_MSG("%s%s:", indent6, timer_name);
	for (i = 0; i < space_count; i++) {
		_MSG(" ");
	}

	if (value) {
		MSG("%" PRId64 " µs", value);
	} else {
		MSG("inactive");
	}
}
Exemplo n.º 9
0
void Log::printLog(ELogLevel level, const char *msg)
{
    if (NULL == msg)
        return;

    if ((mLevel & (int)level) == 0)
        return;

#if PLATFORM == PLATFORM_WIN32
# ifdef _DEBUG
    if (::IsDebuggerPresent())
    {
        ::OutputDebugString(msg);
    }
# endif
#endif

    THREAD_MUTEX_LOCK(mMutex);

    mInlist->push_back(_MSG());
    _MSG &msgnode = mInlist->back();
    msgnode.level = level;
    msgnode.time = mHasTime ? time(0) : 0;
    msgnode.msg = msg;

    THREAD_MUTEX_UNLOCK(mMutex);

    THREAD_SINGNAL_SET(mCond);
}
Exemplo n.º 10
0
/*
 * Assign a position for an already existing anchor.
 */
void p_Dw_gtk_viewport_change_anchor (DwWidget *widget,
                                      gchar *name,
                                      gint32 y)
{
   GtkDwViewport *viewport;
   GtkDwViewportAnchor *anchor;
   gpointer tmp_anchor;
   gboolean exists;

   _MSG("changing anchor %p/'%s' -> %d\n", widget, name, y);

   g_return_if_fail (widget->viewport != NULL);
   viewport = GTK_DW_VIEWPORT (widget->viewport);

   exists =
      g_hash_table_lookup_extended (viewport->anchors_table, name, NULL,
                                    &tmp_anchor);
   g_return_if_fail(exists);

   anchor = tmp_anchor;
   g_return_if_fail(anchor->widget == widget);

   anchor->y = y;

   Dw_gtk_viewport_update_anchor (viewport);
}
Exemplo n.º 11
0
/*
 * Test proxy settings and check the no_proxy domains list
 * Return value: whether to use proxy or not.
 */
static int Http_must_use_proxy(const DilloUrl *url)
{
   char *np, *p, *tok;
   int ret = 0;

   if (HTTP_Proxy) {
      ret = 1;
      if (prefs.no_proxy) {
         const char *host = URL_HOST(url);
         size_t host_len = strlen(host);

         np = dStrdup(prefs.no_proxy);
         for (p = np; (tok = dStrsep(&p, " "));  ) {
            int start = host_len - strlen(tok);

            if (start >= 0 && dStrAsciiCasecmp(host + start, tok) == 0) {
               /* no_proxy token is suffix of host string */
               ret = 0;
               break;
            }
         }
         dFree(np);
      }
   }
   _MSG("Http_must_use_proxy: %s\n  %s\n", URL_STR(url), ret ? "YES":"NO");
   return ret;
}
Exemplo n.º 12
0
/*
 * Add an anchor, and assign a position for it. For all widgets
 * directly or indirectly assigned to a viewports, anchors must be
 * unique, this is tested. "name" is copied, so no strdup is
 * neccessary for the caller.
 *
 * Return the copy on success, or NULL, when this anchor had already
 * been added to the widget tree.
 *
 * The viewport gets the responsibility to free "name".
 */
gchar* p_Dw_gtk_viewport_add_anchor (DwWidget *widget,
                                     const gchar *name,
                                     gint32 y)
{
   GtkDwViewport *viewport;
   GtkDwViewportAnchor *anchor;

   _MSG("new anchor %p/'%s' -> %d\n", widget, name, y);

   g_return_val_if_fail (widget->viewport != NULL, NULL);
   viewport = GTK_DW_VIEWPORT (widget->viewport);

   if (g_hash_table_lookup_extended (viewport->anchors_table, name, NULL,NULL))
      /* Anchor does already exist. */
      return NULL;
   else {
      anchor = g_new (GtkDwViewportAnchor, 1);
      anchor->name = g_strdup (name);
      anchor->widget = widget;
      anchor->y = y;

      g_hash_table_insert (viewport->anchors_table, anchor->name, anchor);
      Dw_gtk_viewport_update_anchor (viewport);

      return anchor->name;
   }
}
Exemplo n.º 13
0
/*
 * Decrement the reference count (and remove from list when zero)
 */
static void Capi_conn_unref(capi_conn_t *conn)
{
   _MSG(" Capi_conn_unref #%d %p\n", conn->Ref - 1, conn);

   /* We may validate conn here, but it doesn't *seem* necessary */
   if (--conn->Ref == 0) {
      /* remove conn preserving the list order */
      dList_remove(CapiConns, (void *)conn);
      /* free dynamic memory */
      a_Url_free(conn->url);
      dFree(conn->server);
      dFree(conn->datastr);
      dFree(conn);
   }
   _MSG(" Capi_conn_unref CapiConns=%d\n", dList_length(CapiConns));
}
Exemplo n.º 14
0
/*
 * Remove an anchor from the table in the viewport. Notice that "name"
 * is freed here.
 */
void p_Dw_gtk_viewport_remove_anchor (DwWidget *widget,
                                      gchar *name)
{
   GtkDwViewport *viewport;
   GtkDwViewportAnchor *anchor;
   gpointer tmp_anchor;
   gboolean exists;

   _MSG("removing anchor %p/'%s'\n", widget, name);

   g_return_if_fail (widget->viewport != NULL);
   viewport = GTK_DW_VIEWPORT (widget->viewport);

   exists =
      g_hash_table_lookup_extended (viewport->anchors_table, name, NULL,
                                    &tmp_anchor);
   g_return_if_fail(exists);

   anchor = tmp_anchor;
   g_return_if_fail(anchor->widget == widget);

   g_hash_table_remove (viewport->anchors_table, name);
   g_free (anchor->name);
   g_free (anchor);
}
Exemplo n.º 15
0
/*
 * Increment the reference count and add to the list if not present
 */
static void Capi_conn_ref(capi_conn_t *conn)
{
   if (++conn->Ref == 1) {
      /* add the connection data to list */
      dList_append(CapiConns, (void *)conn);
   }
   _MSG(" Capi_conn_ref #%d %p\n", conn->Ref, conn);
}
Exemplo n.º 16
0
/*
 * Set a call to Cache_process_queue from the main cycle.
 */
static void Cache_delayed_process_queue(CacheEntry_t *entry)
{
   /* there's no need to repeat entries in the queue */
   if (!dList_find(DelayedQueue, entry))
      dList_append(DelayedQueue, entry);

   if (DelayedQueueIdleId == 0) {
      _MSG("  Setting timeout callback\n");
      a_Timeout_add(0.0, Cache_delayed_process_queue_callback, NULL);
      DelayedQueueIdleId = 1;
   }
}
Exemplo n.º 17
0
/*
 * Queue an area for drawing. This function is called by
 * p_Dw_widget_queue_draw_area. x and y are passed in world coordinates.
 */
void Dw_gtk_viewport_queue_draw (GtkDwViewport *viewport,
                                 gint32 x,
                                 gint32 y,
                                 gint32 width,
                                 gint32 height)
{
   DwRectangle area;
   int i;

   if (viewport->draw_resize_idle_id == 0) {
      viewport->draw_resize_action = DW_GTK_VIEWPORT_DRAW;
      viewport->draw_resize_idle_id =
         gtk_idle_add (Dw_gtk_viewport_draw_resize_idle, (gpointer)viewport);
   } else if (viewport->draw_resize_action == DW_GTK_VIEWPORT_RESIZE)
      /* Drawing is always overridden by resizing. */
      return;

   area.x = x;
   area.y = y;
   area.width = width;
   area.height = height;

   /* First, try to keep the list as clean as possible. Check whether other
    * rectangles interfer with this one in some way. */
   /* An idea for optimization: The list could be sorted, and so the part of
    * the list we have to consider here, may be reduced, the start may be
    * found via linear search. However, this probably makes balanced binary
    * trees necessary, since moving elements within the array may be quite
    * time-consuming.
    */
   _MSG("  num_draw_areas = %d\n", viewport->num_draw_areas);
   for (i = 0; i < viewport->num_draw_areas; i++) {
      if (p_Dw_rectangle_is_subset (&area, &viewport->draw_areas[i]))
         /* First case: area is a subset of an already queued rectangle
          * -> nothing to do. */
         return;
      else if (p_Dw_rectangle_is_subset (&viewport->draw_areas[i], &area)) {
         /* Second case: area is a subset of an already queued rectangle
          * -> replace the other one with area. */
         viewport->draw_areas[i] = area;
         return;
      }
      /* Maybe some more tests: if both areas may exactly be combined to a
       * rectangle? Very unlikely case ... */
   }

   /* No interference: add  the new area to the list. */
   viewport->num_draw_areas++;
   a_List_add (viewport->draw_areas, viewport->num_draw_areas,
               viewport->num_draw_areas_max);
   viewport->draw_areas[viewport->num_draw_areas - 1] = area;
}
Exemplo n.º 18
0
/*
 * Remove a client from the cache client queue.
 * force = also abort the CCC if this is the last client.
 */
void a_Capi_stop_client(int Key, int force)
{
   CacheClient_t *Client;

   _MSG("a_Capi_stop_client:  force=%d\n", force);

   Client = a_Cache_client_get_if_unique(Key);
   if (Client && (force || Client->BufSize == 0)) {
      /* remove empty entries too */
      a_Capi_conn_abort_by_url(Client->Url);
   }
   a_Cache_stop_client(Key);
}
Exemplo n.º 19
0
Arquivo: auth.c Projeto: epitron/dillo
/*
 * Determine whether the user needs to authenticate.
 */
static int Auth_do_auth_required(const AuthParse_t *auth_parse,
                                 const DilloUrl *url)
{
   /*
    * TO DO: I dislike the way that this code must decide whether we
    * sent authentication during the request and trust us to resend it
    * after the reload.  Could it be more robust if every DilloUrl
    * recorded its authentication, and whether it was accepted?  (JCH)
    */

   AuthHost_t *host;
   AuthRealm_t *realm;

   /*
    * The size of the following comments reflects the concerns in the
    * TO DO at the top of this function.  It should not be so hard to
    * explain why code is correct! (JCH)
    */

   /*
    * If we have authentication but did not send it (because we did
    * not know this path was in the realm) then we update the realm.
    * We do not re-authenticate because our authentication is probably
    * OK.  Thanks to the updated realm the forthcoming reload will
    * make us send the authentication.  If our authentication is not
    * OK the server will challenge us again after the reload and then
    * we will re-authenticate.
    */
   if ((host = Auth_host_by_url(url)) &&
       (realm = Auth_realm_by_name(host, auth_parse->realm))) {
      if (!Auth_realm_includes_path(realm, URL_PATH(url))) {
         _MSG("Auth_do_auth_required: updating realm '%s' with URL '%s'\n",
              auth_parse->realm, URL_STR(url));
         Auth_realm_add_path(realm, URL_PATH(url));
         return 0;
      }

      if (auth_parse->type == DIGEST && auth_parse->stale) {
         /* we do have valid credentials but our nonce is old */
         dFree((void *)realm->nonce);
         realm->nonce = dStrdup(auth_parse->nonce);
         return 0;
      }
   }

   /*
    * Either we had no authentication or we sent it and the server
    * rejected it, so we must re-authenticate.
    */
   return 1;
}
Exemplo n.º 20
0
static int Dpi_connect_socket(const char *server_name)
{
   struct sockaddr_in sin;
   int sock_fd, dpi_port, ret = -1;
   char *cmd = NULL;

   /* Query dpid for the port number for this server */
   if ((dpi_port = Dpi_get_server_port(server_name)) == -1) {
      _MSG("Dpi_connect_socket:: can't get port number for %s\n", server_name);
      return -1;
   }
   _MSG("Dpi_connect_socket: server=%s port=%d\n", server_name, dpi_port);

   /* connect with this server's socket */
   memset(&sin, 0, sizeof(sin));
   sin.sin_family = AF_INET;
   sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   sin.sin_port = htons(dpi_port);

   if ((sock_fd = Dpi_make_socket_fd()) == -1) {
      perror("[dpi::socket]");
   } else if (connect(sock_fd, (void*)&sin, sizeof(sin)) == -1) {
      MSG("[dpi::connect] errno:%d %s\n", errno, dStrerror(errno));

   /* send authentication Key (the server closes sock_fd on auth error) */
   } else if (!(cmd = a_Dpip_build_cmd("cmd=%s msg=%s", "auth", SharedKey))) {
      MSG_ERR("[Dpi_connect_socket] Can't make auth message.\n");
   } else if (Dpi_blocking_write(sock_fd, cmd, strlen(cmd)) == -1) {
      MSG_ERR("[Dpi_connect_socket] Can't send auth message.\n");
   } else {
      ret = sock_fd;
   }
   dFree(cmd);
   if (sock_fd != -1 && ret == -1) /* can't send cmd? */
      Dpi_close_fd(sock_fd);

   return ret;
}
Exemplo n.º 21
0
/*
 * Reference the cache data.
 */
static void Cache_ref_data(CacheEntry_t *entry)
{
   if (entry) {
      entry->DataRefcount++;
      _MSG("DataRefcount++: %d\n", entry->DataRefcount);
      if (entry->CharsetDecoder &&
          (!entry->UTF8Data || entry->DataRefcount == 1)) {
         dStr_free(entry->UTF8Data, 1);
         entry->UTF8Data = a_Decode_process(entry->CharsetDecoder,
                                            entry->Data->str,
                                            entry->Data->len);
      }
   }
}
Exemplo n.º 22
0
/*
 * Change Content-Type for cache entry found by url.
 * from = { "http" | "meta" }
 * Return new content type.
 */
const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
                                     const char *from)
{
   const char *curr;
   char *major, *minor, *charset;
   CacheEntry_t *entry = Cache_entry_search(url);

   dReturn_val_if_fail (entry != NULL, NULL);

   _MSG("a_Cache_set_content_type {%s} {%s}\n", ctype, URL_STR(url));

   curr = Cache_current_content_type(entry);
   if  (entry->TypeMeta || (*from == 'h' && entry->TypeHdr) ) {
      /* Type is already been set. Do nothing.
       * BTW, META overrides TypeHdr */
   } else {
      if (*from == 'h') {
         /* Content-Type from HTTP header */
         entry->TypeHdr = dStrdup(ctype);
      } else {
         /* Content-Type from META */
         entry->TypeMeta = dStrdup(ctype);
      }
      if (a_Misc_content_type_cmp(curr, ctype)) {
         /* ctype gives one different from current */
         a_Misc_parse_content_type(ctype, &major, &minor, &charset);
         if (*from == 'm' && charset &&
             ((!major || !*major) && (!minor || !*minor))) {
            /* META only gives charset; use detected MIME type too */
            entry->TypeNorm = dStrconcat(entry->TypeDet, ctype, NULL);
         } else if (*from == 'm' &&
                    !dStrnAsciiCasecmp(ctype, "text/xhtml", 10)) {
            /* WORKAROUND: doxygen uses "text/xhtml" in META */
            entry->TypeNorm = dStrdup(entry->TypeDet);
         }
         if (charset) {
            if (entry->CharsetDecoder)
               a_Decode_free(entry->CharsetDecoder);
            entry->CharsetDecoder = a_Decode_charset_init(charset);
            curr = Cache_current_content_type(entry);

            /* Invalidate UTF8Data */
            dStr_free(entry->UTF8Data, 1);
            entry->UTF8Data = NULL;
         }
         dFree(major); dFree(minor); dFree(charset);
      }
   }
   return curr;
}
Exemplo n.º 23
0
Arquivo: web.c Projeto: dimkr/dillo
/*
 * Allocate and set safe values for a DilloWeb structure
 */
DilloWeb* a_Web_new(const DilloUrl *url)
{
   DilloWeb *web= g_new(DilloWeb, 1);

   _MSG(" a_Web_new: ValidWebs ==> %d\n", g_slist_length(ValidWebs));
   web->url = a_Url_dup(url);
   web->bw = NULL;
   web->flags = 0;
   web->Image = NULL;
   web->stream  = NULL;
   web->SavedBytes = 0;

   ValidWebs = g_slist_append(ValidWebs, (gpointer)web);
   return web;
}
Exemplo n.º 24
0
/*
 * Initialize transfer decoder. Currently handles "chunked".
 */
Decode *a_Decode_transfer_init(const char *format)
{
   Decode *dc = NULL;

   if (format && !dStrAsciiCasecmp(format, "chunked")) {
      int *chunk_remaining = dNew(int, 1);
      *chunk_remaining = 0;
      dc = dNew(Decode, 1);
      dc->leftover = dStr_new("");
      dc->state = chunk_remaining;
      dc->decode = Decode_chunked;
      dc->free = Decode_chunked_free;
      dc->buffer = NULL; /* not used */
      _MSG("chunked!\n");
   }
Exemplo n.º 25
0
char *a_Cookies_get_query(const char *scheme, const char *host,
                          const char *path)
{
   char *cmd, *dpip_tag, *query;

   cmd = a_Dpip_build_cmd("cmd=%s scheme=%s host=%s path=%s",
                          "get_cookie", scheme,
                          host, path);

   /* Get the answer from cookies.dpi */
   _MSG("cookies.c: a_Dpi_send_blocking_cmd cmd = {%s}\n", cmd);
   dpip_tag = a_Dpi_send_blocking_cmd("cookies", cmd);
   _MSG("cookies.c: after a_Dpi_send_blocking_cmd resp={%s}\n", dpip_tag);
   dFree(cmd);

   if (dpip_tag != NULL) {
      query = a_Dpip_get_attr(dpip_tag, "cookie");
      dFree(dpip_tag);
   } else {
      query = dStrdup("");
   }

   return query;
}
Exemplo n.º 26
0
void
command_stop(Module_Services *services,
             Gotham_Citizen_Command *command)
{
   DBG("services[%p] command[%p]", services, command);
   _INVALID(command);

#ifdef _WIN32
   if (!command_win32_stop(services, command, command->message + 14))
     return;

   _MSG(command, "stop", "Service is stopping");
#else
   _RUN(services, command->jid, services->commands.stop, command->message + 14);
#endif
}
Exemplo n.º 27
0
void
command_restart(Module_Services *services,
                Gotham_Citizen_Command *command)
{
   _INVALID(command);

#ifdef _WIN32
   command_win32_stop(services, command, command->message + 17);
   if (!command_win32_start(services, command, command->message + 17))
     return;

   _MSG(command, "restart", "Service restarted");
#else
   _RUN(services, command->jid, services->commands.restart, command->message + 17);
#endif
}
Exemplo n.º 28
0
/*
 * Make the HTTP header's Referer line according to preferences
 * (default is "host" i.e. "scheme://hostname/" )
 */
static char *Http_get_referer(const DilloUrl *url)
{
   char *referer = NULL;

   if (!strcmp(prefs.http_referer, "host")) {
      referer = dStrconcat("Referer: ", URL_SCHEME(url), "://",
                           URL_AUTHORITY(url), "/", "\r\n", NULL);
   } else if (!strcmp(prefs.http_referer, "path")) {
      referer = dStrconcat("Referer: ", URL_SCHEME(url), "://",
                           URL_AUTHORITY(url),
                           URL_PATH_(url) ? URL_PATH(url) : "/", "\r\n", NULL);
   }
   if (!referer)
      referer = dStrdup("");
   _MSG("http, referer='%s'\n", referer);
   return referer;
}
Exemplo n.º 29
0
/*
 * Unreference the cache data.
 */
static void Cache_unref_data(CacheEntry_t *entry)
{
   if (entry) {
      entry->DataRefcount--;
      _MSG("DataRefcount--: %d\n", entry->DataRefcount);

      if (entry->CharsetDecoder) {
         if (entry->DataRefcount == 0) {
            dStr_free(entry->UTF8Data, 1);
            entry->UTF8Data = NULL;
         } else if (entry->DataRefcount < 0) {
            MSG_ERR("Cache_unref_data: negative refcount\n");
            entry->DataRefcount = 0;
         }
      }
   }
}
Exemplo n.º 30
0
Arquivo: auth.c Projeto: epitron/dillo
/*
 * Do authorization for an auth string.
 */
static int Auth_do_auth(char *challenge, enum AuthParseHTTPAuthType_t type,
                        const DilloUrl *url)
{
   AuthParse_t *auth_parse;
   int reload = 0;

   _MSG("auth.c: Auth_do_auth: challenge={%s}\n", challenge);
   auth_parse = Auth_parse_new();
   auth_parse->type = type;
   Auth_parse_challenge(auth_parse, challenge);
   if (auth_parse->ok)
      reload =
         Auth_do_auth_required(auth_parse, url) ?
         Auth_do_auth_dialog(auth_parse, url)
         : 1;
   Auth_parse_free(auth_parse);

   return reload;
}