예제 #1
0
static void print_queues(){
	int i;
	int g[2],b[2];

	/* Rename variables for easier reference. */
	g[0] = g_queue_get_length(queues[0][GOOD]); g[1] = g_queue_get_length(queues[1][GOOD]);
	b[0] = g_queue_get_length(queues[0][BAD]); b[1] = g_queue_get_length(queues[1][BAD]);

	printf("****** flow1 good queue ********\n");
	for (i=0;i<g[0];i++){
		printf("%d\t",GPOINTER_TO_INT(g_queue_peek_nth(queues[FLOW_1][GOOD],i)));
	}
	putchar('\n');

	printf("****** flow1 bad queue ********\n");
	for (i=0;i<b[0];i++){
		printf("%d\t",GPOINTER_TO_INT(g_queue_peek_nth(queues[FLOW_1][BAD],i)));
	}
	putchar('\n');

	printf("****** flow2 good queue ********\n");
	for (i=0;i<g[1];i++){
		printf("%d\t",GPOINTER_TO_INT(g_queue_peek_nth(queues[FLOW_2][GOOD],i)));
	}
	putchar('\n');

	printf("****** flow2 bad queue ********\n");
	for (i=0;i<b[1];i++){
		printf("%d\t",GPOINTER_TO_INT(g_queue_peek_nth(queues[FLOW_2][BAD],i)));
	}
	putchar('\n');
	
}
static gboolean
dspy_introspection_model_get_iter (GtkTreeModel *model,
                                   GtkTreeIter  *iter,
                                   GtkTreePath  *tree_path)
{
  DspyIntrospectionModel *self = (DspyIntrospectionModel *)model;
  DspyNode *cur;
  gint *indices;
  gint depth;

  LOG_DEBUG (G_STRFUNC);

  g_assert (DSPY_IS_INTROSPECTION_MODEL (self));
  g_assert (iter != NULL);
  g_assert (tree_path != NULL);

  memset (iter, 0, sizeof *iter);

  cur = (DspyNode *)self->root;
  indices = gtk_tree_path_get_indices_with_depth (tree_path, &depth);

  for (guint i = 0; cur != NULL && i < depth; i++)
    {
      gint pos = indices[i];

      if (cur->any.parent == NULL)
        cur = g_queue_peek_nth (&cur->node.nodes, pos);
      else if (cur->any.kind == DSPY_NODE_KIND_NODE)
        cur = (DspyNode *)cur->node.interfaces;
      else if (cur->any.kind == DSPY_NODE_KIND_INTERFACES)
        cur = g_queue_peek_nth (&cur->interfaces.interfaces, pos);
      else if (cur->any.kind == DSPY_NODE_KIND_INTERFACE)
        {
          if (pos == 0)
            cur = (DspyNode *)cur->interface.properties;
          else if (pos == 1)
            cur = (DspyNode *)cur->interface.signals;
          else if (pos == 2)
            cur = (DspyNode *)cur->interface.methods;
          else
            cur = NULL;
        }
      else if (cur->any.kind == DSPY_NODE_KIND_PROPERTIES)
        cur = g_queue_peek_nth (&cur->properties.properties, pos);
      else if (cur->any.kind == DSPY_NODE_KIND_SIGNALS)
        cur = g_queue_peek_nth (&cur->signals.signals, pos);
      else if (cur->any.kind == DSPY_NODE_KIND_METHODS)
        cur = g_queue_peek_nth (&cur->methods.methods, pos);
      else
        cur = NULL;
    }

  if (cur != NULL)
    {
      iter->user_data = cur;
      return TRUE;
    }

  return FALSE;
}
예제 #3
0
void queue_prev(gboolean notif) {
    int n, p;
    int len = g_queue_get_length(&g_queue);

    g_debug("Switching to previous track.");

    if (g_shuffle) {
        /* Possible cases: g_repeat, g_current_track == -1, g_shuffle_first == -1 */
        if (g_current_track == -1) {
            if (g_shuffle_first == -1) {
                /* Pick a random track */
                n = g_random_int_range(0, len);

                /* Set the next one to be the first shuffle track... */
                p = g_queue_index(&g_shuffle_queue, GINT_TO_POINTER(n));
                if (p == -1) g_error("Can't find last track in shuffle queue");
                p = (p+1) % len;
                g_shuffle_first = GPOINTER_TO_INT(g_queue_peek_nth(&g_shuffle_queue, p));
            }
            else {
                /* Find the track that comes just before the first shuffle track */
                p = g_queue_index(&g_shuffle_queue, GINT_TO_POINTER(g_shuffle_first));
                if (p == -1) g_error("Can't find first track in shuffle queue");
                p = (p-1) % len;
                n = GPOINTER_TO_INT(g_queue_peek_nth(&g_shuffle_queue, p));
            }
        }
        else {
            if (g_shuffle_first == -1) {
                g_warning("g_shuffle_first == -1 in goto_prev()");
                g_shuffle_first = g_current_track;
            }

            /* Is this the first track in non-repeat mode? */
            if ((g_current_track == g_shuffle_first) && !g_repeat) {
                n = -1;
            }
            else {
                /* Find the index of the current track in the shuffle queue */
                p = g_queue_index(&g_shuffle_queue, GINT_TO_POINTER(g_current_track));
                if (p == -1)
                    g_error("Can't find current track in shufflequeue");

                /* Find the previous track in the shuffle queue */
                p = (p+len-1) % len;
                n = GPOINTER_TO_INT(g_queue_peek_nth(&g_shuffle_queue, p));
            }
        }
    }
    else {
        n = g_current_track - 1;
        if (g_repeat)
            n %= len;
    }

    queue_goto(FALSE, n, FALSE);
    if (notif) queue_notify();
}
예제 #4
0
static const xmmsv_t *
xmms_xform_auxdata_get_val (xmms_xform_t *xform, const gchar *key)
{
	guint i;
	xmms_xform_hotspot_t *hs;
	xmmsv_t *val = NULL;

	/* privdata is always got from the previous xform */
	xform = xform->prev;

	/* check if we have unhandled current (pos 0) hotspots for this key */
	for (i=0; (hs = g_queue_peek_nth (xform->hotspots, i)) != NULL; i++) {
		if (hs->pos != 0) {
			break;
		} else if (hs->key && !strcmp (key, hs->key)) {
			val = hs->obj;
		}
	}

	if (!val) {
		val = g_hash_table_lookup (xform->privdata, key);
	}

	return val;
}
예제 #5
0
파일: druid.c 프로젝트: kyoushuu/anjuta
static void
on_druid_get_new_page (AnjutaAutogen* gen, gpointer data)
{
	NPWDruid* druid = (NPWDruid *)data;
	gint current;
	NPWPage* page;

	current = gtk_assistant_get_current_page (GTK_ASSISTANT (druid->window));
	page = g_queue_peek_nth (druid->page_list, current - (druid->no_selection ? 0 : 1));

	if (npw_page_get_name (page) == NULL)
	{
		/* no page, display finish page */
		npw_druid_fill_summary_page (druid);

		page = g_queue_pop_nth (druid->page_list, current - (druid->no_selection ? 0 : 1));
		if (page != NULL) npw_page_free (page);
		gtk_container_remove (GTK_CONTAINER (druid->window), gtk_assistant_get_nth_page (GTK_ASSISTANT (druid->window), current + 1));
		gtk_assistant_set_current_page (GTK_ASSISTANT (druid->window), current + 1);
	}
	else
	{
		/* display property page */
		npw_druid_fill_property_page (druid, page);

		gtk_assistant_set_current_page (GTK_ASSISTANT (druid->window), current + 1);
	}
}
예제 #6
0
파일: druid.c 프로젝트: kyoushuu/anjuta
/* Fill last page (summary) */
static void
npw_druid_fill_summary_page (NPWDruid* druid)
{
	NPWPage* page;
	guint i;
	GString* text;
	GtkLabel* label;

	text = g_string_new (NULL);
	g_string_append_printf (text, "<b>%s</b>\n\n", _("Confirm the following information:"));

	/* The project type is translated too, it is something like
	 * generic, GNOME applet, Makefile project... */
	g_string_append_printf (text, _("Project Type: %s\n"), npw_header_get_name (druid->header));

	for (i = 0; (page = g_queue_peek_nth (druid->page_list, i)) != NULL; ++i)
	{
		npw_page_foreach_property (page, (GFunc)cb_druid_add_summary_property, text);
	}

	label = GTK_LABEL (druid->finish_text);
	gtk_label_set_markup (label, text->str);
	g_string_free (text, TRUE);

	gtk_assistant_set_page_complete (GTK_ASSISTANT (druid->window), druid->finish_page, TRUE);
}
예제 #7
0
void meh_simple_popup_render(struct App* app, Screen* screen) {
	SimplePopupData* data = meh_simple_popup_get_data(screen);
	g_assert(data != NULL);

	/* render the background screen */
	gboolean* flip = g_new(gboolean, 1);
	*flip = FALSE;
	meh_message_send(app, data->src_screen, MEH_MSG_RENDER, flip);

	/* render the popup screen */

	meh_widget_rect_render(app->window, data->hover_widget);

	/* title */
	meh_widget_text_render(app->window, data->title_widget);

	meh_widget_rect_render(app->window, data->selection_widget);

	/* render the action */
	for (int i = 0; i < g_queue_get_length(data->actions); i++) {
		SimplePopupAction* action = g_queue_peek_nth(data->actions, i);
		meh_widget_text_render(app->window, action->widget);
	}

	meh_window_render(app->window);
}
예제 #8
0
파일: my_layer.c 프로젝트: yangtao8571/wavy
void		my_layer_shift_down_shape		(MyLayer *self, MyShape *theShape) {
	
	
	GQueue *shapes = MY_LAYER_GET_PRIVATE (self)->shapes;
	guint shapeCount, j;
	MyShape *shape;
	shapeCount = my_layer_shape_count (self);
	
	assert (theShape);
	for (j = shapeCount - 1; j >= 0; j--) {
		shape = my_layer_peek_nth (self, j);
		if (shape == theShape) {
			g_queue_pop_nth (shapes, j);
			break;
		}
	}
	assert (shape == theShape);
	
	shape = g_queue_peek_nth (shapes, j - 1);
	if (shape->isControlShape) {
		g_queue_push_nth (shapes, theShape, j);		
	} else {
		g_queue_push_nth (shapes, theShape, j - 1);		
	}
}
예제 #9
0
/**
 * anjuta_shell_present_widget:
 * @shell: A #AnjutaShell interface
 * @widget: The widget to present
 * @error: Error propagation object
 *
 * Make sure the widget is visible to user. If the widget is hidden, it will
 * be shown. If it is not visible to user, it will be made visible.
 */
void
anjuta_shell_present_widget (AnjutaShell *shell,
                             GtkWidget *widget,
                             GError **error)
{
    GQueue *queue;
    gboolean found_in_queue;

    g_return_if_fail (shell != NULL);
    g_return_if_fail (ANJUTA_IS_SHELL (shell));
    g_return_if_fail (widget != NULL);
    g_return_if_fail (GTK_IS_WIDGET (widget));

    /* If there is a queue and the widget is in the queue, there is no
     * way we can 'present' the widget */
    found_in_queue = FALSE;
    queue = g_object_get_data (G_OBJECT (shell), "__widget_queue");
    if (queue)
    {
        gint i;
        for (i = g_queue_get_length(queue) - 1; i >= 0; i--)
        {
            WidgetQueueData *qd;

            qd = g_queue_peek_nth (queue, i);
            if (qd->widget == widget)
            {
                found_in_queue = TRUE;
                break;
            }
        }
    }
    if (!found_in_queue)
        ANJUTA_SHELL_GET_IFACE (shell)->present_widget (shell, widget, error);
}
void XournalScheduler::removeAllJobs()
{
	XOJ_CHECK_TYPE(XournalScheduler);

	g_mutex_lock(&this->jobQueueMutex);

	for (int priority = JOB_PRIORITY_URGENT; priority < JOB_N_PRIORITIES; priority++)
	{
		int length = g_queue_get_length(this->jobQueue[priority]);
		for (int i = 0; i < length; i++)
		{
			Job* job = (Job*) g_queue_peek_nth(this->jobQueue[priority], i);

			JobType type = job->getType();
			if (type == JOB_TYPE_PREVIEW || type == JOB_TYPE_RENDER)
			{
				job->deleteJob();
				g_queue_remove(this->jobQueue[priority], job);
				job->unref();
			}
		}
	}

	g_mutex_unlock(&this->jobQueueMutex);

}
bool XournalScheduler::existsSource(void* source, JobType type, JobPriority priority)
{
	XOJ_CHECK_TYPE(XournalScheduler);

	bool exists = false;
	g_mutex_lock(&this->jobQueueMutex);

	int length = g_queue_get_length(this->jobQueue[priority]);
	for (int i = 0; i < length; i++)
	{
		Job* job = (Job*) g_queue_peek_nth(this->jobQueue[priority], i);

		if (job->getType() == type)
		{
			if (job->getSource() == source)
			{
				exists = true;
				break;
			}
		}
	}

	g_mutex_unlock(&this->jobQueueMutex);

	return exists;
}
void XournalScheduler::removeSource(void* source, JobType type, JobPriority priority)
{
	XOJ_CHECK_TYPE(XournalScheduler);

	g_mutex_lock(&this->jobQueueMutex);

	int length = g_queue_get_length(this->jobQueue[priority]);
	for (int i = 0; i < length; i++)
	{
		Job* job = (Job*) g_queue_peek_nth(this->jobQueue[priority], i);

		if (job->getType() == type)
		{
			if (job->getSource() == source)
			{
				job->deleteJob();
				g_queue_remove(this->jobQueue[priority], job);
				job->unref();
				break;
			}
		}
	}

	// wait until the last job is done
	// we can be sure we don't access "source"
	finishTask();

	g_mutex_unlock(&this->jobQueueMutex);
}
예제 #13
0
static int _remove_timeout_dev(void)
{
	GQueue *queue = &gl_ctx.queue;
	int len = g_queue_get_length(queue);
	int id;
	VS_DEV_T *pdev;

	for (id = 0; id < len; ) {
		pdev = g_queue_peek_nth(queue, id);
		if (!pdev)
			break;

		if (pdev->idle_time > 10) {
			dev_offline(pdev->id);

			g_queue_pop_nth(queue, id);
			hsb_debug("device offline %s\n", inet_ntoa(pdev->ip));
			g_slice_free(VS_DEV_T, pdev);

			continue;
		}

		pdev->idle_time++;

		id++;
	}

	return 0;
}
예제 #14
0
/**
 *  \param id MessageID of requested message
 *
 *  Reads data from message queue until message with matching id is found.
 *
 *  \return GString containing unpacked message.
 **/
GString *get_message_by_id(MessageID id)
{
    GString *data = NULL;
    guint x, len;
    gboolean found = FALSE;

    g_mutex_lock(message_queue_mutex);
    do {
        len = g_queue_get_length(message_queue);
        for (x = 0; x<len; x++) {
            data = g_queue_peek_nth(message_queue, x);
            if (get_message_id(data) == id) {
                found = TRUE;
                g_queue_pop_nth(message_queue, x);
                break;
            }
        }

        if (found == FALSE)
            g_cond_wait(message_queue_cond, message_queue_mutex);

    } while (found == FALSE);
    g_mutex_unlock(message_queue_mutex);

    unpack_message(data);

    return data;
}
/**
 * gst_stream_collection_get_stream:
 * @collection: a #GstStreamCollection
 * @index: Index of the stream to retrieve
 *
 * Retrieve the #GstStream with index @index from the collection.
 *
 * The caller should not modify the returned #GstStream
 *
 * Returns: (transfer none): A #GstStream
 *
 * Since: 1.10
 */
GstStream *
gst_stream_collection_get_stream (GstStreamCollection * collection, guint index)
{
  g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
  g_return_val_if_fail (collection->priv->streams, NULL);

  return g_queue_peek_nth (collection->priv->streams, index);
}
예제 #16
0
TEST_F(GQueueTest, peek)
{
	int testData1 = 42;
	int testData2 = 1337;

	g_queue_push_tail(queue, &testData1);
	g_queue_push_tail(queue, &testData2);

	gpointer data = g_queue_peek_head(queue);
	ASSERT_EQ(&testData1, data) << "peeking at the head of the queue should produce expected value";
	data = g_queue_peek_tail(queue);
	ASSERT_EQ(&testData2, data) << "peeking at the tail of the queue should produce expected value";
	data = g_queue_peek_nth(queue, 0);
	ASSERT_EQ(&testData1, data) << "peeking at the first element of the queue should produce expected value";
	data = g_queue_peek_nth(queue, 1);
	ASSERT_EQ(&testData2, data) << "peeking at the second element of the queue should produce expected value";
}
예제 #17
0
파일: playlists.c 프로젝트: allanjyu3/hemp
int
write_playlist (void)
{
    FILE *fp = NULL;
    guint i;
    struct hemp_playlist_entry *e;
    GHashTable *done;
    
    if (fp = fopen(playlist_path(), "w")) {
        done = g_hash_table_new(g_str_hash, g_str_equal);

        for (i = 0; i < g_queue_get_length(hotlist); i++) {
            e = g_queue_peek_nth(hotlist, i);
            if (e->finish_count == e->start_count) { 
                write_playlist_entry(fp, done, e->uri);
            }
        }
       
        for (i = 0; i < g_queue_get_length(coldlist); i++) { 
            e = g_queue_peek_nth(coldlist, i);
            write_playlist_entry(fp, done, e->uri);
        }

        if (current) {
            write_playlist_entry(fp, done, current->uri);
        }

        for (i = 0; i < g_queue_get_length(hotlist); i++) {
            e = g_queue_peek_nth(hotlist, i);
            if (e->finish_count < e->start_count) { 
                write_playlist_entry(fp, done, e->uri);
            }
        }

        if((fflush(fp)==0) && (fsync(fileno(fp))!=-1)) {
            if (fclose(fp) == 0) {
                return(1);
            }
        } else {
            fclose(fp);
            return(0); 
        }
    } else {
        return(0);
    }
}
예제 #18
0
파일: gdbmi.c 프로젝트: VujinovM/anjuta
const GDBMIValue*
gdbmi_value_list_get_nth (const GDBMIValue* val, gint idx)
{
	g_return_val_if_fail (val != NULL, NULL);
	g_return_val_if_fail (val->type == GDBMI_DATA_LIST, NULL);
	
	if (idx >= 0)
		return g_queue_peek_nth (val->data.list, idx);
	else
		return g_queue_peek_tail (val->data.list);
}
예제 #19
0
void meh_exec_selection_render(App* app, Screen* screen) {
	ExecutableListData* data = meh_exec_list_get_data(screen);

	/* selection */
	meh_widget_rect_render(app->window, data->selection_widget);

	/* render all the executables names. */
	for (unsigned int i = 0; i < g_queue_get_length(data->executable_widgets); i++) {
		meh_widget_text_render(app->window, g_queue_peek_nth(data->executable_widgets, i));
	}
}
예제 #20
0
파일: navqueue.c 프로젝트: Aligorith/geany
static gboolean
queue_pos_matches(guint queue_pos, const gchar *fname, gint pos)
{
	if (queue_pos < g_queue_get_length(navigation_queue))
	{
		filepos *fpos = g_queue_peek_nth(navigation_queue, queue_pos);

		return (utils_str_equal(fpos->file, fname) && fpos->pos == pos);
	}
	return FALSE;
}
예제 #21
0
파일: druid.c 프로젝트: kyoushuu/anjuta
static NPWPage*
npw_druid_add_new_page (NPWDruid* druid)
{
	gint current;
	NPWPage* page;

	/* Get page in cache */
	current = gtk_assistant_get_current_page (GTK_ASSISTANT (druid->window));
	page = g_queue_peek_nth (druid->page_list, current - (druid->no_selection ? 0 : 1) + 1);

	if (page == NULL)
	{
		/* Page not found in cache, create */
		GtkBuilder *builder;
		GtkWidget *widget;
		GtkAssistantPageType type;
		GtkWidget *table;
		GtkAssistant *assistant;

		/* Build another complete wizard dialog from the gtk builder file
	 	* but keep only the property assistant page */
		builder = gtk_builder_new ();
		if (!gtk_builder_add_from_file (builder, GTK_BUILDER_UI_FILE, NULL))
		{
			g_warn_if_reached ();
			g_object_unref (builder);

			return NULL;
		}
		assistant = GTK_ASSISTANT (gtk_builder_get_object (builder, NEW_PROJECT_DIALOG));
		widget = GTK_WIDGET (gtk_builder_get_object (builder, PROPERTY_PAGE));
		table = GTK_WIDGET (gtk_builder_get_object (builder, PROPERTY_TABLE));

		type = gtk_assistant_get_page_type (assistant, widget);
		gtk_container_remove (GTK_CONTAINER (assistant), widget);
		gtk_assistant_insert_page (GTK_ASSISTANT (druid->window), widget, current + 1);
		gtk_assistant_set_page_type (GTK_ASSISTANT (druid->window), widget, type);
		gtk_assistant_set_page_complete (GTK_ASSISTANT (druid->window), widget, TRUE);
		gtk_widget_destroy (GTK_WIDGET (assistant));

		/* Builder get reference on all built widget, so unref it when all work is done */
		g_object_unref (builder);

		/* Create new page */
		page = npw_page_new (druid->values);
		npw_page_set_widget (page, table);

		/* Add page in cache */
		g_queue_push_tail (druid->page_list, page);
	}

	return page;
}
예제 #22
0
/**
 * meh_simple_popup_run_action runs the underlying action.
 */
static void meh_simple_popup_run_action(App* app, Screen* screen, int selected_action) {
	SimplePopupData* data = meh_simple_popup_get_data(screen);
	SimplePopupAction* action = g_queue_peek_nth(data->actions, selected_action);

	/* then start the action */
	if (action != NULL) {
		action->run(app, screen);
	}

	/* close the popup */
	meh_simple_popup_close(app, screen);
}
예제 #23
0
파일: queue.c 프로젝트: pes0/spop
/***************************
 *** Move into the queue ***
 ***************************/
void queue_next(gboolean notif) {
    int n, p;
    int len = g_queue_get_length(&g_queue);

    g_debug("Switching to next track (current track: %d).", g_current_track);

    if (g_repeat && len == 1) {
        /* Easy case: replay the same track */
        queue_seek(0);
        if (notif) queue_notify();
        return;
    }

    if (g_shuffle) {
        /* Possible cases: g_repeat, g_current_track == -1, g_shuffle_first == -1 */
        if (g_current_track == -1) {
            if (g_shuffle_first == -1) {
                /* Pick a random track */
                n = g_random_int_range(0, len);
                g_shuffle_first = n;
            }
            else {
                n = g_shuffle_first;
            }
        }
        else {
            if (g_shuffle_first == -1) {
                g_warning("g_shuffle_first == -1 in goto_next()");
                g_shuffle_first = g_current_track;
            }

            /* Find the index of the current track in the shuffle queue */
            p = g_queue_index(&g_shuffle_queue, GINT_TO_POINTER(g_current_track));
            if (p == -1) g_error("Can't find current track in shuffle queue");

            /* Find the next track in the shuffle queue */
            p = (p+1) % len;
            n = GPOINTER_TO_INT(g_queue_peek_nth(&g_shuffle_queue, p));

            if ((n == g_shuffle_first) && !g_repeat)
                n = -1;
        }
    }
    else {
        n = g_current_track + 1;
        if (g_repeat)
            n %= len;
    }

    queue_goto(FALSE, n, FALSE);
    if (notif) queue_notify();
}
예제 #24
0
파일: rtf-field.c 프로젝트: ptomato/osxcart
static gboolean
field_fldrslt(ParserContext *ctx, FieldState *state, GError **error)
{
    if(state->ignore_field_result)
        push_new_destination(ctx, &ignore_destination, NULL);
    else
    {
        Destination *outerdest = g_queue_peek_nth(ctx->destination_stack, 1);
        Attributes *attr = g_queue_peek_head(outerdest->state_stack);
        push_new_destination(ctx, &field_result_destination, attr);
    }
    return TRUE;
}
예제 #25
0
파일: queue.c 프로젝트: pes0/spop
/***********************************
 *** Information about the queue ***
 ***********************************/
queue_status queue_get_status(sp_track** current_track, int* current_track_number, int* total_tracks) {
    if (current_track) {
        if (g_current_track >= 0)
            *current_track = g_queue_peek_nth(&g_queue, g_current_track);
        else
            *current_track = NULL;
    }
    if (current_track_number)
        *current_track_number = g_current_track;
    if (total_tracks)
        *total_tracks = g_queue_get_length(&g_queue);

    return g_status;
}
예제 #26
0
파일: cl_log.c 프로젝트: sipwise/heartbeat
gboolean
DumpCircularBuffer(int nsig, gpointer user_data) 
{
	CircularBuffer_t *buffer = user_data;
	CircularBufferEntry_t *entry = NULL;
	
	if(buffer == NULL) {
		/* error */
		cl_log(LOG_ERR, "No buffer supplied to dump.");
		return FALSE;
	}

	if(logging_daemon_chan != NULL
	   && logging_daemon_chan->send_queue->max_qlen < buffer->size) {
		/* We have no hope of getting the whole buffer out via the
		 *  logging daemon.  Use direct log instead so the messages
		 *  come out in the right order.
		 */ 
		cl_log_depth++;
	}
	
	cl_log(LOG_INFO, "Mark: Begin dump of buffer %s", buffer->name);
	if(buffer->empty_after_dump) {
		while(buffer->queue->length > 0) {
			entry = g_queue_pop_head(buffer->queue);
			cl_log(entry->level, "%s", entry->buf);
			cl_free(entry->buf);
			cl_free(entry);
		}

	} else {
#if 1
		cl_log(LOG_ERR, "This requires g_queue_peek_nth() from glib 2.4");
#else
		uint lpc = 0;
		uint queue_len = buffer->queue->length;
		for(lpc = 0; lpc < queue_len; lpc++) {
			entry = g_queue_peek_nth(buffer->queue, lpc);
			cl_log(entry->level, "%s", entry->buf);
		}
#endif
	}
	if(logging_daemon_chan != NULL
	   && logging_daemon_chan->send_queue->max_qlen < buffer->size) {
		/* Return is back to normal */
		cl_log_depth--;
	}
	cl_log(LOG_INFO, "Mark: End dump of buffer %s", buffer->name);
	return TRUE;
}
예제 #27
0
void meh_exec_selection_destroy(Screen* screen) {
	g_assert(screen != NULL);

	ExecutableListData* data = meh_exec_list_get_data(screen);

	/* Selection */
	meh_widget_rect_destroy(data->selection_widget);

	/* Executables */
	for (unsigned int i = 0; i < g_queue_get_length(data->executable_widgets); i++) {
		meh_widget_text_destroy( g_queue_peek_nth( data->executable_widgets, i) );
	}
	g_queue_free(data->executable_widgets);
}
예제 #28
0
/*
 * meh_exec_list_refresh_executables_widget re-creates all the texture
 * in the text widgets for the executables.
 */
void meh_exec_selection_refresh_executables_widgets(App* app, Screen* screen) {
	ExecutableListData* data = meh_exec_list_get_data(screen);

	int page = (data->selected_executable / (MEH_EXEC_LIST_SIZE));

	/* for every executable text widget */
	for (unsigned int i = 0; i < g_queue_get_length(data->executable_widgets); i++) {
		WidgetText* text = g_queue_peek_nth(data->executable_widgets, i);
		text->text = "";

		/* look for the executable text if any */
		int executable_idx = page*(MEH_EXEC_LIST_SIZE) + i;
		if (executable_idx <= data->executables_length) {
			Executable* executable = g_queue_peek_nth(data->executables, executable_idx);
			if (executable != NULL) {
				text->text = executable->display_name;
			}
		}

		/* reload the text texture. */
		meh_widget_text_reload(app->window, text);
	}
}
int
main (void)
{
  Graph *test_graph = graph_new ();

  GraphNode *a = graph_add_node (test_graph, NULL);
  GraphNode *b = graph_add_node (test_graph, NULL);
  GraphNode *c = graph_add_node (test_graph, NULL);
  GraphNode *c1 = graph_add_node (test_graph, NULL);
  GraphNode *c2 = graph_add_node (test_graph, NULL);
  GraphNode *c11 = graph_add_node (test_graph, NULL);
  GraphNode *d = graph_add_node (test_graph, NULL);

  GraphEdge *ab = graph_add_edge (test_graph, a, b, NULL);
  GraphEdge *bc = graph_add_edge (test_graph, b, c, NULL);
  GraphEdge *cd = graph_add_edge (test_graph, c, d, NULL);
  GraphEdge *da = graph_add_edge (test_graph, d, a, NULL);

  graph_add_edge (test_graph, c, c1, NULL);
  graph_add_edge (test_graph, c1, c11, NULL);
  graph_add_edge (test_graph, c, c2, NULL);

  graph_dump_by_edges (test_graph, "test_graph.dot", NULL);

  GQueue *path;
  gboolean result = graph_node_in_cycle (test_graph, a, &path);
  g_assert (result);
  g_assert (g_queue_peek_head (path) == da);
  g_assert (g_queue_peek_nth (path, 1) == cd);
  g_assert (g_queue_peek_nth (path, 2) == bc);
  g_assert (g_queue_peek_tail (path) == ab);

  g_queue_free (path);

  exit (EXIT_SUCCESS);
}
예제 #30
0
static VS_DEV_T *_find_dev_by_ip(struct in_addr *addr)
{
	GQueue *queue = &gl_ctx.queue;
	int len = g_queue_get_length(queue);
	int id;
	VS_DEV_T *pdev;

	for (id = 0; id < len; id++) {
		pdev = g_queue_peek_nth(queue, id);

		if (pdev->ip.s_addr == addr->s_addr)
			return pdev;
	}

	return NULL;
}