Exemple #1
0
/* See hlcache.h for documentation */
nserror hlcache_handle_abort(hlcache_handle *handle)
{
	struct hlcache_entry *entry = handle->entry;
	struct content *c;

	if (entry == NULL) {
		/* This handle is not yet associated with a cache entry.
		 * The implication is that the fetch for the handle has
		 * not progressed to the point where the entry can be
		 * created. */

		RING_ITERATE_START(struct hlcache_retrieval_ctx,
				   hlcache->retrieval_ctx_ring,
				   ictx) {
			if (ictx->handle == handle &&
					ictx->migrate_target == false) {
				/* This is the nascent context for us,
				 * so abort the fetch */
				llcache_handle_abort(ictx->llcache);
				llcache_handle_release(ictx->llcache);
				/* Remove us from the ring */
				RING_REMOVE(hlcache->retrieval_ctx_ring, ictx);
				/* Throw us away */
				free((char *) ictx->child.charset);
				free(ictx);
				/* And stop */
				RING_ITERATE_STOP(hlcache->retrieval_ctx_ring,
						ictx);
			}
		} RING_ITERATE_END(hlcache->retrieval_ctx_ring, ictx);

		return NSERROR_OK;
	}
Exemple #2
0
/* See hlcache.h for documentation */
nserror hlcache_handle_release(hlcache_handle *handle)
{
	if (handle->entry != NULL) {
		content_remove_user(handle->entry->content,
				hlcache_content_callback, handle);
	} else {
		RING_ITERATE_START(struct hlcache_retrieval_ctx,
				   hlcache->retrieval_ctx_ring,
				   ictx) {
			if (ictx->handle == handle &&
					ictx->migrate_target == false) {
				/* This is the nascent context for us,
				 * so abort the fetch */
				llcache_handle_abort(ictx->llcache);
				llcache_handle_release(ictx->llcache);
				/* Remove us from the ring */
				RING_REMOVE(hlcache->retrieval_ctx_ring, ictx);
				/* Throw us away */
				free((char *) ictx->child.charset);
				free(ictx);
				/* And stop */
				RING_ITERATE_STOP(hlcache->retrieval_ctx_ring,
						ictx);
			}
		} RING_ITERATE_END(hlcache->retrieval_ctx_ring, ictx);
	}

	handle->cb = NULL;
	handle->pw = NULL;

	free(handle);

	return NSERROR_OK;
}
Exemple #3
0
void
monkey_process_command(void)
{
  char buffer[PATH_MAX];
  int argc = 0;
  char **argv = NULL;
  char *p, *r = NULL;
  handle_command_fn fn = NULL;
  char **nargv;
  
  if (fgets(buffer, PATH_MAX, stdin) == NULL) {
    /* end of input or read error so issue QUIT */
    sprintf(buffer, "QUIT\n");
  }

  /* remove newline */
  buffer[strlen(buffer) - 1] = '\0';
  
  argv = malloc(sizeof *argv);
  if (argv == NULL) {
    return;
  }
  argc = 1;
  *argv = buffer;
  
  for (p = r = buffer; *p != '\0'; p++) {
    if (*p == ' ') {
      nargv = realloc(argv, sizeof(*argv) * (argc + 1));
      if (nargv == NULL) {
	/* reallocation of argument vector failed, try using what is
	 * already processed.
	 */
	break;
      } else {
	argv = nargv;
      }
      argv[argc++] = r = p + 1;
      *p = '\0';
    }
  }
  
  RING_ITERATE_START(monkey_cmdhandler_t, handler_ring, handler) {
    if (strcmp(argv[0], handler->cmd) == 0) {
      fn = handler->fn;
      RING_ITERATE_STOP(handler_ring, handler);
    }
  } RING_ITERATE_END(handler_ring, handler);
  
  if (fn != NULL) {
    fn(argc, argv);
  }

  free(argv);
}
Exemple #4
0
void
monkey_process_command(void)
{
  char buffer[PATH_MAX];
  int argc = 0;
  char **argv = NULL;
  char *p, *r = NULL;
  handle_command_fn fn = NULL;
  
  if (fgets(buffer, PATH_MAX, stdin) == NULL) {
    netsurf_quit = true;
  }
  
  buffer[strlen(buffer)-1] = '\0';
  
  argv = malloc(sizeof *argv);
  argc = 1;
  *argv = buffer;
  
  for (p = r = buffer; *p != '\0'; p++) {
    if (*p == ' ') {
      argv = realloc(argv, sizeof(*argv) * (argc + 1));
      argv[argc++] = r = p + 1;
      *p = '\0';
    }
  }
  
  RING_ITERATE_START(monkey_cmdhandler_t, handler_ring, handler) {
    if (strcmp(argv[0], handler->cmd) == 0) {
      fn = handler->fn;
      RING_ITERATE_STOP(handler_ring, handler);
    }
  } RING_ITERATE_END(handler_ring, handler);
  
  if (fn != NULL)
    fn(argc, argv);
}