コード例 #1
0
ファイル: u2spewfoo.c プロジェクト: BMNLabs/snort
static int u2dump(char *file) {
    u2record record;
    u2iterator *it = new_iterator(file);

    memset(&record, 0, sizeof(record));

    if(!it) {
        printf("u2dump: Failed to create new iterator with file: %s\n", file);
        return -1;
    }

    while( get_record(it, &record) == SUCCESS ) {
        if(record.type == UNIFIED2_IDS_EVENT) event_dump(&record);
        else if(record.type == UNIFIED2_IDS_EVENT_VLAN) event2_dump(&record);
        else if(record.type == UNIFIED2_PACKET) packet_dump(&record);
        else if(record.type == UNIFIED2_IDS_EVENT_IPV6) event6_dump(&record);
        else if(record.type == UNIFIED2_IDS_EVENT_IPV6_VLAN) event2_6_dump(&record);
        else if(record.type == UNIFIED2_EXTRA_DATA) extradata_dump(&record);
#if defined(FEAT_OPEN_APPID)

        else if(record.type == UNIFIED2_IDS_EVENT_APPID) event3_dump(&record);
        else if(record.type == UNIFIED2_IDS_EVENT_APPID_IPV6) event3_6_dump(&record);
        else if(record.type == UNIFIED2_IDS_EVENT_APPSTAT) appid_dump(&record);
#endif /* defined(FEAT_OPEN_APPID) */
    }

    free_iterator(it);
    if(record.data)
        free(record.data);

    return 0;
}
コード例 #2
0
static void send_to_all(packet_t Item, socket_list *destination_sockets){
  iterator *iter;
  node* aux;
  byte buffer[sizeof(packet_t)];
  
  iter = new_iterator(destination_sockets);
  while(has_next(iter)){
    aux = next(iter);
    memcpy(buffer, & Item, sizeof(packet_t));
    send_bytes(destination_sockets->server_socket_fd, buffer, sizeof(packet_t), (struct sockaddr *) aux->sock, sizeof(struct sockaddr_in));
  }
  destroy_iterator(iter);
}
コード例 #3
0
ファイル: vmcoll.cpp プロジェクト: c4rlo/gargoyle-fedora
/*
 *   Create an iterator 
 */
int CVmObjCollection::getp_create_iter(VMG_ vm_val_t *retval,
                                       const vm_val_t *self_val, uint *argc)
{
    static CVmNativeCodeDesc desc(0);

    /* check arguments */
    if (get_prop_check_argc(retval, argc, &desc))
        return TRUE;

    /* push a self-reference for gc protection */
    G_stk->push(self_val);

    /* create the iterator */
    new_iterator(vmg_ retval, self_val);

    /* discard the gc protection */
    G_stk->discard();

    /* handled */
    return TRUE;
}
コード例 #4
0
void* broker(void * args){
    //pthread_mutex_lock(&mutex);
    char id[11];
    int type, shares, price;
    broker_info * info = (broker_info*) args;
    iterator * iterator = new_iterator(info -> batch_file);

    while(next_operation(iterator, id, &type, &shares, &price)>=0){
        pthread_mutex_lock(&mutex);

        while(operations_queue_full(info -> market -> stock_operations) == 1){
            pthread_cond_wait(&operations, &mutex);
        }
        new_operation(&op, id, type, shares, price);
        enqueue_operation(info -> market -> stock_operations, &op);
        pthread_cond_signal(&not_operations);
        pthread_mutex_unlock(&mutex);
    }
    destroy_iterator(iterator);
    //pthread_mutex_unlock(&mutex);
    pthread_exit(0);
}
コード例 #5
0
ファイル: out1.c プロジェクト: moey509/Compilers
void cubex_main(){
input = get_input();
ref_increment((General_t)input);
a = NULL;
__temp4 = NULL;
__temp0 = NULL;
__temp5 = NULL;
__temp1 = NULL;
__temp6 = NULL;
__temp2 = NULL;
__temp7 = NULL;
__temp3 = NULL;
__temp0 = NULL;
ref_decrement((General_t)__temp0);
__temp0 = new_integer(1);
ref_increment((General_t)__temp0);
ref_decrement((General_t)__temp0);
__temp0 = NULL;
ref_decrement((General_t)__temp1);
__temp1 = new_integer(1);
ref_increment((General_t)__temp1);
if(((Boolean_t)__temp1)->value) {
ref_decrement((General_t)__temp1);
__temp1= NULL;
__temp2 = NULL;
ref_decrement((General_t)__temp2);
__temp2 = new_git_obj_charuni((char) 't');
ref_increment((General_t)__temp2);
__temp3 = NULL;
ref_decrement((General_t)__temp3);
__temp3 = iterable_append((git_t) __temp2,(git_t) NULL);
ref_increment((General_t)__temp3);
ref_decrement((General_t)__temp2);
__temp2 = NULL;
ref_decrement((General_t)a);
a = __temp3;
ref_increment((General_t)a);
ref_decrement((General_t)__temp3);
__temp3 = NULL;
} else {
ref_decrement((General_t)__temp1);
__temp1= NULL;
__temp4 = NULL;
ref_decrement((General_t)__temp4);
__temp4 = new_git_obj_charuni((char) 'f');
ref_increment((General_t)__temp4);
__temp5 = NULL;
ref_decrement((General_t)__temp5);
__temp5 = iterable_append((git_t) __temp4,(git_t) NULL);
ref_increment((General_t)__temp5);
ref_decrement((General_t)__temp4);
__temp4 = NULL;
ref_decrement((General_t)a);
a = __temp5;
ref_increment((General_t)a);
ref_decrement((General_t)__temp5);
__temp5 = NULL;
}
ref_decrement((General_t)__temp6);
__temp6 = new_git_obj((void*) a);
ref_increment((General_t)__temp6);
ref_decrement((General_t)a);
a = NULL;
ref_decrement((General_t)__temp7);
__temp7 = iterable_append((git_t) __temp6,(git_t) NULL);
ref_increment((General_t)__temp7);
ref_decrement((General_t)__temp6);
__temp6 = NULL;
_it1 = new_iterator((__temp7));
ref_increment((General_t)_it1);
while(hasNext(_it1)) {
_return = getNext(_it1);
print_line(charToString(_return), stringLength(_return));
}
ref_decrement((General_t)_it1);
_it1 = NULL;
ref_decrement((General_t)__temp7);
__temp7 = NULL;
ref_decrement((General_t)input);
ending();
return;
}