int List_get_node_data(List list, int idFuente, int idDestino, char *data, unsigned int tminicio, unsigned int tmfin) {
    if (list == NULL) { data = ""; return LISTNULL; }
    if (idFuente > list->count) { data = ""; return NODENULL; }
    if (list->elements[idFuente] == NULL ) { data = ""; return NODENULL; }
    
    struct Consumidor *con = List_get_consumidor(list, idFuente, idDestino);

    if (con == NULL) { data = ""; return DESTNULL; }
    
    struct ListNode *node = list->elements[idFuente];
    
    if (con->tm_inicio != tminicio) {
        con->tm_inicio = tminicio;
        con->data_enviada = tminicio != 0 ? List_search(list, idFuente, tminicio) : 0;
    }
    if (con->tm_fin != tmfin) {
        con->tm_fin = tmfin;
        con->data_fin = tmfin != 0 ? List_search(list, idFuente, tmfin) : ULONG_MAX;
    }
    
    if (node->cant_data > con->data_enviada && con->data_enviada <= con->data_fin) {
        struct Buffer *buffer = node->buffer[con->data_enviada];
        sprintf(data, "%u", buffer->tm);
        strncat(data, ";", 1);
        strncat(data, buffer->data, strlen(buffer->data));
        con->data_enviada++;
    } else {
        data = "";
        return OVER;
    }

    return SUCCESS;
}
예제 #2
0
int main(int argc, char * argv[])
{
  Node * head = NULL; /* must initialize it to NULL */
  head = List_insert(head, 917);
  head = List_insert(head, -504);
  head = List_insert(head, 326);
  List_print(head);
  head = List_delete(head, -504);
  List_print(head);
  head = List_insert(head, 138);
  head = List_insert(head, -64);
  head = List_insert(head, 263);
  List_print(head);

  if (List_search(head, 138) != NULL)
    {
      printf("138 is in the list\n");
    }
  else
    {
      printf("138 is not in the list\n");
    }

  if (List_search(head, 987) != NULL)
    {
      printf("987 is in the list\n");
    }
  else
    {
      printf("987 is not in the list\n");
    }
    

  /* delete the first Node */
  head = List_delete(head, 263);
  List_print(head);

  /* delete the last Node */
  head = List_delete(head, 917);
  List_print(head);

  /* delete all Nodes */
  List_destroy(head);
  return EXIT_SUCCESS;
}
예제 #3
0
파일: test2.c 프로젝트: OPSF/uClinux
static int const *	S(int val)
{
  return List_search(&l, &val, cmp);
}