Beispiel #1
0
static void
xml_subprocess_output(pcmk__output_t *out, int exit_status,
                      const char *proc_stdout, const char *proc_stderr) {
    xmlNodePtr node, child_node;
    char *rc_as_str = NULL;
    xml_private_t *priv = out->priv;
    CRM_ASSERT(priv != NULL);

    rc_as_str = crm_itoa(exit_status);

    node = xmlNewNode(g_queue_peek_tail(priv->parent_q), (pcmkXmlStr) "command");
    xmlSetProp(node, (pcmkXmlStr) "code", (pcmkXmlStr) rc_as_str);

    if (proc_stdout != NULL) {
        child_node = xmlNewTextChild(node, NULL, (pcmkXmlStr) "output",
                                     (pcmkXmlStr) proc_stdout);
        xmlSetProp(child_node, (pcmkXmlStr) "source", (pcmkXmlStr) "stdout");
    }

    if (proc_stderr != NULL) {
        child_node = xmlNewTextChild(node, NULL, (pcmkXmlStr) "output",
                                     (pcmkXmlStr) proc_stderr);
        xmlSetProp(node, (pcmkXmlStr) "source", (pcmkXmlStr) "stderr");
    }

    pcmk__xml_add_node(out, node);
    free(rc_as_str);
}
Beispiel #2
0
static gboolean qq_tray_button_press(GtkStatusIcon *tray, GdkEvent *event
                                    , gpointer data)
{
    GdkEventButton *buttonevent = (GdkEventButton*)event;

	/* Only handle left clicked. */
	if(buttonevent -> button != 1 || buttonevent -> type != GDK_BUTTON_PRESS){
		return FALSE;
	}
    
    QQTrayPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(tray, qq_tray_get_type()
                                                    , QQTrayPriv);
    gchar *uin = g_queue_pop_tail(priv -> blinking_queue);
    if(uin == NULL){
		/* If there is no new msg, show or hide the main window. */
		qq_mainwindow_show_hide(main_win);
        return FALSE;
    }
    GtkWidget *cw = gqq_config_lookup_ht(cfg, "chat_window_map", uin);
    if(cw != NULL){
        gtk_widget_show(cw);
    }
    g_free(uin);

    if(g_queue_is_empty(priv -> blinking_queue)){
        gtk_status_icon_set_blinking(tray, FALSE);
        GdkPixbuf *pb = gdk_pixbuf_new_from_file(IMGDIR"/webqq_icon.png"
                                                    , NULL);
        gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(tray), pb);
        g_object_unref(pb);
        return FALSE;
    }
    qq_tray_blinking(QQ_TRAY(tray), g_queue_peek_tail(priv -> blinking_queue));
    return FALSE;
}
Beispiel #3
0
/**
 * rtp_jitter_buffer_get_ts_diff:
 * @jbuf: an #RTPJitterBuffer
 *
 * Get the difference between the timestamps of first and last packet in the
 * jitterbuffer.
 *
 * Returns: The difference expressed in the timestamp units of the packets.
 */
guint32
rtp_jitter_buffer_get_ts_diff (RTPJitterBuffer * jbuf)
{
  guint64 high_ts, low_ts;
  GstBuffer *high_buf, *low_buf;
  guint32 result;

  g_return_val_if_fail (jbuf != NULL, 0);

  high_buf = g_queue_peek_head (jbuf->packets);
  low_buf = g_queue_peek_tail (jbuf->packets);

  if (!high_buf || !low_buf || high_buf == low_buf)
    return 0;

  high_ts = gst_rtp_buffer_get_timestamp (high_buf);
  low_ts = gst_rtp_buffer_get_timestamp (low_buf);

  /* it needs to work if ts wraps */
  if (high_ts >= low_ts) {
    result = (guint32) (high_ts - low_ts);
  } else {
    result = (guint32) (high_ts + G_MAXUINT32 + 1 - low_ts);
  }
  return result;
}
Beispiel #4
0
static gboolean
isBalanced(gchar * current_re)
{
	GQueue * stack = g_queue_new();
	guint i;
	for(i = 0; current_re[i] != '\0'; i++)
	{
		switch(current_re[i])
		{
		case '(':
		case '{':
		case '[':
			g_queue_push_tail(stack,&current_re[i]);
			break;
		case ')':
		case '}':
		case ']':
			if(verifyTop(g_queue_peek_tail(stack),current_re[i]))
			{
				g_queue_pop_tail(stack);
			}else return FALSE;
			break;
		}
	}
	
	return g_queue_is_empty(stack);
}
Beispiel #5
0
void changed_callback(G_GNUC_UNUSED GFileMonitor * monitor,
                      GFile * file,
                      G_GNUC_UNUSED GFile * other_file,
                      GFileMonitorEvent event_type,
                      G_GNUC_UNUSED gpointer user_data)
{
    gchar * path = g_file_get_path(file);
    if(event_type == G_FILE_MONITOR_EVENT_CHANGED) g_message("file : %-40s %s", "G_FILE_MONITOR_EVENT_CHANGED", path);
    if(event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) g_message("file : %-40s %s", "G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT", path);
    if(event_type == G_FILE_MONITOR_EVENT_DELETED) g_message("file : %-40s %s", "G_FILE_MONITOR_EVENT_DELETED", path);
    if(event_type == G_FILE_MONITOR_EVENT_CREATED) g_message("file : %-40s %s", "G_FILE_MONITOR_EVENT_CREATED", path);
    if(event_type == G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED) g_message("file : %-40s %s", "G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED", path);
    if(event_type == G_FILE_MONITOR_EVENT_PRE_UNMOUNT) g_message("file : %-40s %s", "G_FILE_MONITOR_EVENT_PRE_UNMOUNT", path);
    if(event_type == G_FILE_MONITOR_EVENT_UNMOUNTED) g_message("file : %-40s %s", "G_FILE_MONITOR_EVENT_UNMOUNTED", path);
    g_free(path);

    switch(event_type)
    {
    case G_FILE_MONITOR_EVENT_CHANGED:
    case G_FILE_MONITOR_EVENT_DELETED:
    case G_FILE_MONITOR_EVENT_CREATED:
    case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
        if(g_queue_is_empty(&event_queue) ||
                !g_file_equal((GFile *)g_queue_peek_tail(&event_queue), file))
        {
            g_object_ref(file);
            g_queue_push_tail(&event_queue, file);
            if(g_queue_get_length(&event_queue) == 1)
                g_idle_add(handle_event_when_idle, NULL);
        }
    default:
        return;
    }
}
Beispiel #6
0
static void
add_url_media_cb (const gchar *url, gpointer user_data)
{
  AddMediaUrlData *amud = (AddMediaUrlData *) user_data;
  SearchData *sd = amud->sd;

  if (url) {
    grl_media_set_url (amud->media, url);
  }

  amud->computed = TRUE;

  /* Try to send in order all the processed elements */
  while ((amud = g_queue_peek_tail (sd->queue)) &&
         amud != NULL &&
         amud->computed) {
    sd->ss->callback (sd->ss->source,
                      sd->ss->operation_id,
                      amud->media,
                      amud->index,
                      sd->ss->user_data,
                      NULL);
    g_queue_pop_tail (sd->queue);
    g_slice_free (AddMediaUrlData, amud);
  }

  /* If there are still elements not processed let's wait for them */
  if (amud == NULL) {
    g_queue_free (sd->queue);
    g_slice_free (SearchData, sd);
  }
}
Beispiel #7
0
/*
  #Nombre: genera_cuadruplo_terminos
  #Descripcion: Genera el cuadruplo para sumar o restar. 
                Las acciones realizadas en esta funcion son las que se llevan a cabo en genera_cuadruplo_factores
*/
void genera_cuadruplo_terminos(){
  if(!g_queue_is_empty(p_operadores)){
    int oper = GPOINTER_TO_INT(g_queue_peek_tail(p_operadores));

    if(oper == o_suma || oper == o_resta){
      g_queue_pop_tail(p_operadores);
      int tipo2 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos));
      int tipo1 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos));
      int tipo_resultado = cubo[oper][tipo1][tipo2];

      if(tipo_resultado != -1){
        int operando2 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos));
        int operando1 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos));
        int resultado;

        if(tipo_resultado == 4)
          resultado = asigna_dir(s_temporal, d_string);
        else
          resultado = asigna_dir(s_temporal, tipo_resultado);

        g_queue_push_tail(p_operandos, GINT_TO_POINTER(resultado));
        g_queue_push_tail(p_tipos, GINT_TO_POINTER(tipo_resultado));

        insertar_cuadruplo(oper, operando1, operando2, resultado);
      }
      else{
        printf("Error en linea %d: Sumas y restas no pueden ser realizadas entre estos tipos de datos\n", yylineno);
        exit(EXIT_FAILURE);
      }
    }
  }
}
static gboolean mjpeg_decoder_queue_frame(VideoDecoder *video_decoder,
                                          SpiceFrame *frame, int32_t latency)
{
    MJpegDecoder *decoder = (MJpegDecoder*)video_decoder;
    SpiceFrame *last_frame;

    last_frame = g_queue_peek_tail(decoder->msgq);
    if (last_frame) {
        if (spice_mmtime_diff(frame->mm_time, last_frame->mm_time) < 0) {
            /* This should really not happen */
            SPICE_DEBUG("new-frame-time < last-frame-time (%u < %u):"
                        " resetting stream",
                        frame->mm_time,
                        last_frame->mm_time);
            mjpeg_decoder_drop_queue(decoder);
        }
    }

    /* Dropped MJPEG frames don't impact the ones that come after.
     * So drop late frames as early as possible to save on processing time.
     */
    if (latency < 0) {
        SPICE_DEBUG("dropping a late MJPEG frame");
        frame->free(frame);
        return TRUE;
    }

    frame->ref_data(frame->data_opaque);
    g_queue_push_tail(decoder->msgq, frame);
    mjpeg_decoder_schedule(decoder);
    return TRUE;
}
Beispiel #9
0
int
bot_gl_scrollplot2d_add_point (BotGlScrollPlot2d *self, const char *name,
        double x, double y)
{
    _plot2d_t *plot = g_hash_table_lookup (self->plots, name);
    if (!plot) return -1;

    while (! g_queue_is_empty (plot->points)) {
        _plot2d_point_t *last_pt = 
            (_plot2d_point_t*) g_queue_peek_tail (plot->points);
        if (last_pt->x > x) {
            g_slice_free (_plot2d_point_t, last_pt);
            g_queue_pop_tail (plot->points);
        } else break;
    }

    _plot2d_point_t *pt = g_slice_new (_plot2d_point_t);
    pt->x = x;
    pt->y = y;
    g_queue_push_tail (plot->points, pt);

    while (g_queue_get_length (plot->points) > plot->max_points) {
        g_slice_free (_plot2d_point_t, g_queue_pop_head (plot->points));
    }
    return 0;
}
Beispiel #10
0
static gboolean
gst_hls_demux_switch_playlist (GstHLSDemux * demux)
{
  GTimeVal now;
  GstClockTime diff;
  gsize size;
  gint bitrate;
  GstFragment *fragment = g_queue_peek_tail (demux->queue);
  GstBuffer *buffer;

  GST_M3U8_CLIENT_LOCK (demux->client);
  if (!demux->client->main->lists) {
    GST_M3U8_CLIENT_UNLOCK (demux->client);
    return TRUE;
  }
  GST_M3U8_CLIENT_UNLOCK (demux->client);

  /* compare the time when the fragment was downloaded with the time when it was
   * scheduled */
  g_get_current_time (&now);
  diff = (GST_TIMEVAL_TO_TIME (now) - GST_TIMEVAL_TO_TIME (demux->next_update));
  buffer = gst_fragment_get_buffer (fragment);
  size = gst_buffer_get_size (buffer);
  bitrate = (size * 8) / ((double) diff / GST_SECOND);

  GST_DEBUG ("Downloaded %d bytes in %" GST_TIME_FORMAT ". Bitrate is : %d",
      size, GST_TIME_ARGS (diff), bitrate);

  gst_buffer_unref (buffer);
  return gst_hls_demux_change_playlist (demux, bitrate * demux->bitrate_limit);
}
Beispiel #11
0
void RenderUniverse() {
	G_LOCK( UNIVERSE_RENDER_BUSY ); {
		if( buffer_clear_requested ) {
			if( buffer_clear_last_good ) {
				// Clear everything in the buffer after buffer_clear_last_good

			} else {
				// Clear the entire buffer
				g_queue_foreach( universe_buffer, Universe_GFuncFree, NULL );
				g_queue_clear( universe_buffer );
			}

			buffer_clear_requested = 0;
		}

		// Find the last Universe
		Universe tail = g_queue_peek_tail( universe_buffer );
		if( tail == NULL ) {
			tail = current;
		}

		// Clone it
		Universe temp = Universe_duplicate( tail );

		// Perform a tick
		Universe_performTick( temp );

		// Add it to the Universe queue
		g_queue_push_tail( universe_buffer, temp );

	} G_UNLOCK( UNIVERSE_RENDER_BUSY );
}
Beispiel #12
0
/*
  #Nombre: genera_cuadruplo_asignacion
  #Descripcion: Genera el cuadruplo para realizar una asignacion entre dos direcciones
*/
void genera_cuadruplo_asignacion(){
  //Regresa el operador que se encuentra en el tope de la pila de tipos.
  int oper = GPOINTER_TO_INT(g_queue_peek_tail(p_operadores));

  //Verifica si se trata de una asignacion
  if( oper == o_iguala ){
    //Quita el operador de la pila de operadores
    g_queue_pop_tail(p_operadores);

    //Accesa, de la pila de tipos, los tipos de los datos que se van a utilizar en la asignacion
    int tipo2 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos));
    int tipo1 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos));

    //Verifica con el cubo de operaciones si la asignacion puede ser realizada entre el tipo de datos involucrados
    int tipo_resultado = cubo[oper][tipo1][tipo2];
    if(tipo_resultado != -1){
      //Saca los operandos involucrados de la pila de operandos
      int operando2 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos));
      int operando1 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos));

      //Genera cuadruplo para la asignacion
      insertar_cuadruplo(oper, operando2, -1, operando1);
    }
    else{
      printf("Error en linea %d: Asignaciones no pueden ser realizadas entre estos tipos de datos\n", yylineno);
      exit(EXIT_FAILURE);
    }
  }
}
Beispiel #13
0
void
pcmk__xml_add_node(pcmk__output_t *out, xmlNodePtr node) {
    xml_private_t *priv = out->priv;

    CRM_ASSERT(priv != NULL);
    CRM_ASSERT(node != NULL);

    xmlAddChild(g_queue_peek_tail(priv->parent_q), node);
}
Beispiel #14
0
void handle_request(struct msg incoming_msg, struct state_info info) {
	// handle Lamport clocks
	char diag[200];
	update_lamport_recv(incoming_msg.timestamp, info.local_clock);

	int *my_weight_ptr = g_hash_table_lookup(info.skiers_weights, &info.mytid);
	int my_weight = *my_weight_ptr;
	int *sender_weight_ptr = g_hash_table_lookup(info.skiers_weights, &incoming_msg.sender_tid);
	int sender_weight = *sender_weight_ptr;

	if (info.phase != PHASE_WAIT_ACCEPTS) {
		// Always send ACCEPT, don't care about priorities in those phases
		send_accept_msg(incoming_msg.sender_tid, info);
	} else {
		// Send ACCEPT only if:
		// a) my priority is worse than the sender's priority,
		// b) or my priority is better but we both can fit
		// c) or I want the other lift
		if (*info.my_lift_number != incoming_msg.lift_number) { // I want the other lift
			send_accept_msg(incoming_msg.sender_tid, info); return;
		}
		// my priority is worse
		else if (*info.my_request_timestamp > incoming_msg.timestamp) {
			send_accept_msg(incoming_msg.sender_tid, info); return;
		}
		else if (*info.my_request_timestamp == incoming_msg.timestamp) {
			if (incoming_msg.timestamp % 2 == 0) { // admit the heavier skier
				if (my_weight > sender_weight) {
					send_accept_msg(incoming_msg.sender_tid, info); return;
				}
			}
			else { // admit the lighter skier
				if (my_weight <= sender_weight) {
					send_accept_msg(incoming_msg.sender_tid, info);	return;
				}
			}
		}

		// my priority is better
		// ELSE
		if (my_weight + sender_weight <= *info.lift_free) {
			send_accept_msg(incoming_msg.sender_tid, info);
		}
		else { // add the sender to the queue of waiting requests for the lift
			int *tid = malloc(sizeof(int));
			memcpy(tid, &incoming_msg.sender_tid, sizeof(int));
			g_queue_push_tail(info.waiting_req_q, tid);
			int *pushed = g_queue_peek_tail(info.waiting_req_q);
			sprintf(diag, "*** pushed tid=%d", *pushed);
			diag_msg(info.mstrtid, info.mytid, diag);
		}

	}
};
Beispiel #15
0
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);
}
Beispiel #16
0
static void
xml_list_item(pcmk__output_t *out, const char *name, const char *content) {
    xml_private_t *priv = out->priv;
    xmlNodePtr item_node = NULL;

    CRM_ASSERT(priv != NULL);

    item_node = xmlNewChild(g_queue_peek_tail(priv->parent_q), NULL,
                            (pcmkXmlStr) "item", (pcmkXmlStr) content);
    xmlSetProp(item_node, (pcmkXmlStr) "name", (pcmkXmlStr) name);
}
Beispiel #17
0
/**
 * rtp_jitter_buffer_peek:
 * @jbuf: an #RTPJitterBuffer
 *
 * Peek the oldest buffer from the packet queue of @jbuf. Register a callback
 * with rtp_jitter_buffer_set_tail_changed() to be notified when an older packet
 * was inserted in the queue.
 *
 * Returns: a #GstBuffer or %NULL when there was no packet in the queue.
 */
GstBuffer *
rtp_jitter_buffer_peek (RTPJitterBuffer * jbuf)
{
  GstBuffer *buf;

  g_return_val_if_fail (jbuf != NULL, FALSE);

  buf = g_queue_peek_tail (jbuf->packets);

  return buf;
}
Beispiel #18
0
static void
xml_begin_list(pcmk__output_t *out, const char *name,
               const char *singular_noun, const char *plural_noun) {
    xmlNodePtr list_node = NULL;
    xml_private_t *priv = out->priv;

    CRM_ASSERT(priv != NULL);

    list_node = create_xml_node(g_queue_peek_tail(priv->parent_q), "list");
    xmlSetProp(list_node, (pcmkXmlStr) "name", (pcmkXmlStr) name);
    g_queue_push_tail(priv->parent_q, list_node);
}
Beispiel #19
0
/* returns the liBuffer from the last chunk in cq, if the chunk has type BUFFER_CHUNK,
 * and the buffer has at least min_space bytes free and refcount == 1 (NULL otherwise) */
liBuffer* li_chunkqueue_get_last_buffer(liChunkQueue *cq, guint min_space) {
	liChunk *c = g_queue_peek_tail(&cq->queue);
	liBuffer *buf;

	if (!c || c->type != BUFFER_CHUNK) return NULL;
	buf = c->data.buffer.buffer;
	if (g_atomic_int_get(&buf->refcount) != 1 || (buf->alloc_size - buf->used) < min_space) return NULL;
	/* truncate buf->used - we are the only reference, so that is no problem;
	 * but we need to append directly after the current data block
	 */
	buf->used = c->data.buffer.offset + c->data.buffer.length;
	return buf;
}
Beispiel #20
0
/* only call this if li_chunkqueue_get_last_buffer returned a buffer; don't modify the chunkqueue
 * between the two calls
 * updates the buffer and the cq data
 */
LI_API void li_chunkqueue_update_last_buffer_size(liChunkQueue *cq, goffset add_length) {
	liChunk *c = g_queue_peek_tail(&cq->queue);
	liBuffer *buf;

	assert(c && c->type == BUFFER_CHUNK);
	buf = c->data.buffer.buffer;
	buf->used += add_length;
	c->data.buffer.length += add_length;

	cq->length += add_length;
	cq->bytes_in += add_length;
	cqlimit_update(cq, add_length);
}
Beispiel #21
0
static void
xml_output_xml(pcmk__output_t *out, const char *name, const char *buf) {
    xmlNodePtr parent = NULL;
    xmlNodePtr cdata_node = NULL;
    xml_private_t *priv = out->priv;

    CRM_ASSERT(priv != NULL);

    parent = xmlNewChild(g_queue_peek_tail(priv->parent_q), NULL,
                         (pcmkXmlStr) name, NULL);
    cdata_node = xmlNewCDataBlock(getDocPtr(parent), (pcmkXmlStr) buf, strlen(buf));
    xmlAddChild(parent, cdata_node);
}
static void hev_serial_port_queue_command_handler(HevSerialPort *self)
{
	HevSerialPortPrivate *priv = HEV_SERIAL_PORT_GET_PRIVATE(self);
	GSimpleAsyncResult *simple = NULL;
	HevSerialPortQueueCommandData *data = NULL;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	simple = g_queue_peek_tail(priv->queue);
	data = g_simple_async_result_get_op_res_gpointer(simple);

	/* Write command */
	hev_serial_port_write_async(self, data->command->data, data->command->len,
				data->cancellable, hev_serial_port_write_async_handler, simple);
}
/**
 * clutter_event_peek:
 * 
 * Returns a pointer to the first event from the event queue but 
 * does not remove it. 
 *
 * Return value: (transfer none): A #ClutterEvent or NULL if queue empty.
 *
 * Since: 0.4
 */
ClutterEvent *
clutter_event_peek (void)
{
  ClutterMainContext *context = _clutter_context_get_default ();

  g_return_val_if_fail (context != NULL, NULL);
  
  if (context->events_queue == NULL)
    return NULL;

  if (g_queue_is_empty (context->events_queue))
    return NULL;

  return g_queue_peek_tail (context->events_queue);
}
Beispiel #24
0
/**
 * Return the edge cluster of the specified edge from the specified end
 * point. THE EDGES IN THE CLUSTER MUST BE UNREFFED!
 * @param[in] P The point which is shared between all edges of the cluster
 * @param[in] E The edge whose cluster should be returned
 * @return The cluster of @ref E from the point @ref P
 */
P2trCluster*
p2tr_cluster_get_for (P2trPoint   *P,
                      P2trEdge    *E)
{
  P2trCluster *cluster = g_slice_new (P2trCluster);
  gdouble temp_angle;
  P2trEdge *current, *next;
  
  cluster->min_angle = G_MAXDOUBLE;
  g_queue_init (&cluster->edges);

  if (P == E->end)
    P = P2TR_EDGE_START (E);
  else if (P != P2TR_EDGE_START (E))
    p2tr_exception_programmatic ("Unexpected point for the edge!");

  g_queue_push_head (&cluster->edges, E);

  current = E;
  next = p2tr_point_edge_cw (P, current);
  
  while (next != g_queue_peek_head (&cluster->edges)
      && (temp_angle = p2tr_edge_angle_between (current->mirror, next)) <= P2TR_CLUSTER_LIMIT_ANGLE
      && p2tr_cluster_cw_tri_between_is_in_domain (current, next))
    {
      g_queue_push_tail (&cluster->edges, next);
      p2tr_edge_ref (next);
      current = next;
      next = p2tr_point_edge_cw (P, current);
      cluster->min_angle = MIN (cluster->min_angle, temp_angle);
    }

  current = E;
  next = p2tr_point_edge_ccw(P, current);
  while (next != g_queue_peek_tail (&cluster->edges)
      && (temp_angle = p2tr_edge_angle_between (current->mirror, next)) <= P2TR_CLUSTER_LIMIT_ANGLE
      && p2tr_cluster_cw_tri_between_is_in_domain (next, current))
    {
      g_queue_push_head (&cluster->edges, next);
      p2tr_edge_ref (next);
      current = next;
      next = p2tr_point_edge_ccw (P, current);
      cluster->min_angle = MIN(cluster->min_angle, temp_angle);
    }

  return cluster;
}
Beispiel #25
0
int main(int argc, char** argv) {
 GQueue* q = g_queue_new();
 g_queue_push_tail(q, "Alice");
 g_queue_push_tail(q, "Bob");
 g_queue_push_tail(q, "Fred");
 printf("Queue is Alice, Bob, and Fred; removing Bob\n");
 int fred_pos = g_queue_index(q, "Fred");
 g_queue_remove(q, "Bob");
 printf("Fred moved from %d to %d\n", fred_pos, g_queue_index(q, "Fred"));
 printf("Bill is cutting in line\n");
 GList* fred_ptr = g_queue_peek_tail_link(q);
 g_queue_insert_before(q, fred_ptr, "Bill");
 printf("Middle person is now %s\n", g_queue_peek_nth(q, 1));
 printf("%s is still at the end\n", g_queue_peek_tail(q));
 g_queue_free(q);
 return 0;
}
Beispiel #26
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";
}
Beispiel #27
0
void qq_tray_blinking_for(QQTray *tray, const gchar *uin)
{
    if(tray == NULL || uin == NULL){
        return;
    }

    QQTrayPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(tray, qq_tray_get_type()
                                                    , QQTrayPriv);

    if(NULL != g_queue_find_custom(priv -> blinking_queue, uin
                                    , (GCompareFunc)g_strcmp0)){
        // already blinking
        return;
    }
    g_queue_push_head(priv -> blinking_queue, g_strdup(uin));
    qq_tray_blinking(tray, g_queue_peek_tail(priv -> blinking_queue));
}
Beispiel #28
0
/*
  #Nombre: genera_cuadruplo_factores
  #Descripcion: Genera el cuadruplo para multiplicar o dividir 
*/
void genera_cuadruplo_factores(){
  //Regresa el operador que se encuentra en el tope de la pila de tipos.
  int oper = GPOINTER_TO_INT(g_queue_peek_tail(p_operadores));

  //Verifica si se trata de una multiplicacion o division
  if(oper == o_mult || oper == o_div){
    //Quita el operador de la pila de operadores
    g_queue_pop_tail(p_operadores);

    //Accesa, de la pila de tipos, los tipos de los datos que se van a utilizar en la operacion
    int tipo2 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos));
    int tipo1 = GPOINTER_TO_INT(g_queue_pop_tail(p_tipos));

    //Verifica con el cubo de operaciones si la operacion puede ser realizada entre el tipo de datos involucrados
    int tipo_resultado = cubo[oper][tipo1][tipo2];
    if(tipo_resultado != -1){

      //Saca los operandos involucrados de la pila de operandos
      int operando2 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos));
      int operando1 = GPOINTER_TO_INT(g_queue_pop_tail(p_operandos));
      int resultado;

      //Si el tipo de dato es del tipo COLOR, se le asigna una direccion de los strings
      if(tipo_resultado == 4)
        resultado = asigna_dir(s_temporal, d_string);
      else //Si no, se le asigna la direccion temporal dependiendo de su tipo
        resultado = asigna_dir(s_temporal, tipo_resultado);

      //Mete a la pila de operandos y tipos el resultado de la operacion realizada
      g_queue_push_tail(p_operandos, GINT_TO_POINTER(resultado));
      g_queue_push_tail(p_tipos, GINT_TO_POINTER(tipo_resultado));

      //Inserta cuadruplo para realizar la operacion
      insertar_cuadruplo(oper, operando1, operando2, resultado);
    }
    else{
      printf("Error en linea %d: Multiplicaciones y divisiones no pueden ser realizadas entre estos tipos de datos 1: %d Y 2: %d\n", yylineno, tipo1, tipo2);
      exit(EXIT_FAILURE);
    }
  }
}
Beispiel #29
0
static gboolean sexp_xmitter(GIOChannel *io, GIOCondition cond, gpointer data)
{
    GString *sexp = g_queue_peek_tail( &out_queue );
    int      fd   = g_io_channel_unix_get_fd( io );

    if( sexp )
    {
        ssize_t sent = write( fd, sexp->str, sexp->len );

        // no point trying to cope with errors other than EAGAIN & EINTR:
        // and EAGAIN means we have nothing to do here:
        if( sent < 0 )
        {
            switch( errno )
            {
              case EAGAIN:
              case EINTR :
                return TRUE;
              default:
                perror( "during write to output fd" );
                close( fd );
                return FALSE;
            }
        }

        // hooray: we sent the whole sexp. free it and remove from the queue
        if( sent == sexp->len )
        {
            g_string_free   ( sexp, TRUE );
            g_queue_pop_tail( &out_queue );
        }
        else if( sent )
        {
            g_string_erase( sexp, 0, sent );
        }
    }

    // remove ourselves if nothing is left in the queue:
    return g_queue_is_empty( &out_queue ) ? FALSE : TRUE;
}
Beispiel #30
0
int __ofono_sms_txq_set_submit_notify(struct ofono_sms *sms,
					struct ofono_uuid *uuid,
					ofono_sms_txq_submit_cb_t cb,
					void *data,
					ofono_destroy_func destroy)
{
	GList *l;
	struct tx_queue_entry *entry = g_queue_peek_tail(sms->txq);

	if (memcmp(&entry->uuid, uuid, sizeof(entry->uuid))) {
		l = g_queue_find_custom(sms->txq, uuid, entry_compare_by_uuid);

		if (l == NULL)
			return -ENOENT;

		entry = l->data;
	}

	tx_queue_entry_set_submit_notify(entry, cb, data, destroy);

	return 0;
}