uint32_t get_min_time_from_neighbor(uint8_t neighbor_main_addr[ETH_ALEN]) {
    if(neighbor_set_ett == NULL) {
        return false;
    }

    // Searching for entry with neighbor_main_addr as key
    olsr_db_neighbors_ett_entry_t* entry;
    HASH_FIND(hh, neighbor_set_ett, neighbor_main_addr, ETH_ALEN, entry);

    if(entry == NULL) {
        return false;
    }

    // searching for the minimum time_int_sw entry
    uint32_t min = INT_MAX;
    int i;

    for(i = 0; i < ETT_SW_SIZE; i++) {
        if(entry->time_int_sw[i] > 0) {
            if(entry->time_int_sw[i] < min) {
                min = entry->time_int_sw[i];
            }
        }
    }

    if(min == INT_MAX) {
        return false;
    }

    return min;
}
uint32_t process_ett_stop_time(uint8_t neighbor_main_addr[ETH_ALEN], struct timeval* ett_stop_time) {
    olsr_db_neighbors_ett_entry_t* entry;

    if(neighbor_set_ett == NULL) {
        return false;
    }

    HASH_FIND(hh, neighbor_set_ett, neighbor_main_addr, ETH_ALEN, entry);

    if(entry == NULL) {
        return false;
    }

    // If no previous ETT-START package was received false is returned
    if(entry->timeval_recv.tv_sec == 0 && entry->timeval_recv.tv_usec == 0) {
        return false;
    }

    // calculates the difference between ett_stop_time and timeval_recv
    struct timeval res;
    timeval_subtract(&res, &(entry->timeval_recv), ett_stop_time);
    // calculates the difference time in usec
    uint32_t result = res.tv_sec * 1000000 + res.tv_usec;
    // deleting the old timeval_recv value
    entry->timeval_recv.tv_sec = 0;
    entry->timeval_recv.tv_usec = 0;
    return result;
}
Esempio n. 3
0
void draw_character(void *screen,int x,int y,int w,uint32_t cin,uint32_t bg,uint32_t fg,int bold,int underline,int italic,int strike) {

    SDL_Texture *texture=0;
 
    lookup_key_t chr;
    chr.c = cin;
    chr.fg = fg;
    chr.bg = bg;
    chr.bold = bold;
    chr.underline = underline;
    chr.italic = italic;
    chr.strike = strike;
    
    char_render_t *mchr=0;
    HASH_FIND( hh, display_cache, &chr, char_render_t_keylen, mchr);
    
    if(!mchr) {
      uint32_t Rmask, Gmask, Bmask, Amask;      /* masks for desired format */
   
      Rmask = 0xff000000;
      Gmask = 0x00ff0000;
      Bmask = 0x0000ff00;
      Amask = 0x000000ff;
    
      int bpp=32;                /* bits per pixel for desired format */
    
 //     SDL_Surface *converted = SDL_CreateRGBSurface(0,w,16,32,0,0,0,0);
      SDL_Surface *converted = SDL_CreateRGBSurface(SDL_SWSURFACE, w, 16, bpp, Rmask, Gmask, Bmask, Amask);
    
      if(converted == NULL) {
        printf("failed to create surface\n");
      }
      
      draw_character_surface(converted,0,0,w,cin,bg,fg,bold,underline,italic,strike);

 //     texture = SDL_CreateTexture(screen,converted->format,0,w,16);
 //     (((uint32_t *) (converted->pixels))[0]) = 0xFFFFFFFF;
 //     SDL_UpdateTexture(texture,NULL,converted->pixels,w*4);
      texture = SDL_CreateTextureFromSurface(screen, converted);
   // SDL_Rect dstRect = { x, y, w, 16 };
   // SDL_RenderCopy(screen, texture, NULL, &dstRect);
    
     // SDL_FreeSurface(converted);

      mchr = malloc(sizeof(char_render_t));
      mchr->c = cin;
      mchr->fg = fg;
      mchr->bg = bg;
      mchr->bold = bold;
      mchr->underline = underline;
      mchr->italic = italic;
      mchr->strike = strike;
      mchr->texture = texture;
        
      HASH_ADD( hh, display_cache, c, char_render_t_keylen, mchr);
    }

    SDL_Rect dstRect = { x, y, w, 16 };
    SDL_RenderCopy(screen, mchr->texture, NULL, &dstRect);
}
struct fl_url_record *get_first_url_record()
{
   struct fl_url_record *s;
   uint64_t lowest = get_first_record_number();
   HASH_FIND(hh, url_map, &lowest, sizeof(uint64_t), s); 
   return(s);
}
Esempio n. 5
0
FcitxInputContext* fcitx_input_context_manager_create_ic(FcitxInputContextManager* manager,
                                                         FcitxInputContextFillDataCallback callback,
                                                         void* userData)
{
    FcitxInputContext* ic = NULL;
    if (manager->freeList) {
        ic = manager->freeList;
        manager->freeList = ic->hh.next;
    } else {
        uint32_t newid;
        while ((newid = ++manager->icid) != 0);
        HASH_FIND(hh, manager->ics, &newid, sizeof(uint32_t), ic);
        if (ic) {
            return NULL;
        }
        ic = fcitx_utils_new(FcitxInputContext);
        ic->id = newid;
        ic->manager = manager;
    }

    if (callback) {
        callback(ic, userData);
    }

    return ic;
}
Esempio n. 6
0
/**
 * Record or update stat value.
 */
void update_stat( char *group, char *key, char *value )
{
    DPRINTF("update_stat ( %s, %s, %s )\n", group, key, value);
    statsd_stat_t *s;
    statsd_stat_name_t l;

    memset(&l, 0, sizeof(statsd_stat_name_t));
    strcpy(l.group_name, group);
    strcpy(l.key_name, key);
    DPRINTF("HASH_FIND '%s' '%s'\n", l.group_name, l.key_name);
    HASH_FIND( hh, stats, &l, sizeof(statsd_stat_name_t), s );

    if (s)
    {
        DPRINTF("Updating old stat entry\n");

        s->value = atol( value );
    }
    else
    {
        DPRINTF("Adding new stat entry\n");
        s = malloc(sizeof(statsd_stat_t));
        memset(s, 0, sizeof(statsd_stat_t));

        strcpy(s->name.group_name, group);
        strcpy(s->name.key_name, key);
        s->value = atol(value);
        s->locked = 0;

        HASH_ADD( hh, stats, name, sizeof(statsd_stat_name_t), s );
    }
}
Esempio n. 7
0
void _xcb_im_handle_sync_reply(xcb_im_t* im, xcb_im_client_t* client, const xcb_im_packet_header_fr_t* hdr, uint8_t* data)
{
    xcb_im_sync_reply_fr_t frame;
    _xcb_im_read_frame_with_error(im, client, frame, data, XIM_MESSAGE_BYTES(hdr));

    do {
        if (client->connect_id != frame.input_method_ID) {
            break;
        }

        xcb_im_input_context_t* ic = NULL;
        HASH_FIND(hh, client->input_contexts, &frame.input_context_ID, sizeof(uint16_t), ic);
        if (!ic) {
            break;
        }

        client->sync = false;
        if (im->sync) {
            im->sync = false;

            if (im->callback) {
                im->callback(im, client, ic, hdr, &frame, NULL, im->user_data);
            }
        }

        _xcb_im_process_queue(im, client);
    } while(0);

    xcb_im_sync_reply_fr_free(&frame);
}
Esempio n. 8
0
PRIVATE int
__AI_heuristic_func ( cluster_type type )
{
	AI_snort_alert  *alert_iterator;
	attribute_key   key;
	attribute_value *values = NULL;
	attribute_value *value  = NULL;
	attribute_value *found  = NULL;
	int             max     = 0;
	
	if ( type == none || !alert_log || !h_root[type] )
		return -1;

	for ( alert_iterator = alert_log; alert_iterator; alert_iterator = alert_iterator->next )
	{
		if ( !alert_iterator->h_node[type] )
			continue;

		key.min = alert_iterator->h_node[type]->min_val;
		key.max = alert_iterator->h_node[type]->max_val;

		if ( values )
		{
			HASH_FIND ( hh, values, &key, sizeof ( attribute_key ), found );
		}

		if ( !found )
		{
			if ( !( value = ( attribute_value* ) malloc ( sizeof ( attribute_value )) ))
			{
				AI_fatal_err ( "Fatal dynamic memory allocation failure", __FILE__, __LINE__ );
			}

			memset ( value, 0, sizeof ( attribute_value ));
			value->key   = key;
			value->type  = type;
			value->count = 1;
			HASH_ADD ( hh, values, key, sizeof ( attribute_key ), value );
		} else {
			found->count++;
		}
	}

	for ( value = values; value; value = ( attribute_value* ) value->hh.next )
	{
		if ( value->count > max )
		{
			max = value->count;
		}
	}

	while ( values )
	{
		value = values;
		HASH_DEL ( values, value );
		free ( value );
	}

	return max;
}		/* -----  end of function __AI_heuristic_func  ----- */
/**
 * Record or update stat value.
 */
void update_stat( char *group, char *key, char *value ) {
  syslog(LOG_DEBUG, "update_stat ( %s, %s, %s )\n", group, key, value);
  statsd_stat_t *s;
  statsd_stat_name_t l;

  memset(&l, 0, sizeof(statsd_stat_name_t));
  strcpy(l.group_name, group);
  strcpy(l.key_name, key);
  syslog(LOG_DEBUG, "HASH_FIND '%s' '%s'\n", l.group_name, l.key_name);
  HASH_FIND( hh, stats, &l, sizeof(statsd_stat_name_t), s );

  if (s) {
    syslog(LOG_DEBUG, "Updating old stat entry");

    wait_for_stats_lock();
    s->value = atol( value );
    remove_stats_lock();
  } else {
    syslog(LOG_DEBUG, "Adding new stat entry");
    s = malloc(sizeof(statsd_stat_t));
    memset(s, 0, sizeof(statsd_stat_t));

    strcpy(s->name.group_name, group);
    strcpy(s->name.key_name, key);
    s->value = atol(value);
    s->locked = 0;

    wait_for_stats_lock();
    HASH_ADD( hh, stats, name, sizeof(statsd_stat_name_t), s );
    remove_stats_lock();
  }
}
Esempio n. 10
0
int olsr_db_brct_addid(uint8_t shost_ether[ETH_ALEN], uint32_t brc_id, struct timeval* purge_time) {
    olsr_brclog_entry_t* entry;
    timeslot_purgeobjects(brclog_ts);
    HASH_FIND(hh, brclog_set, shost_ether, ETH_ALEN, entry);

    if(entry == NULL) {
        entry = malloc(sizeof(olsr_brclog_entry_t));

        if(entry == NULL) {
            return false;
        }

        memcpy(entry->shost_ether, shost_ether, ETH_ALEN);
        HASH_ADD_KEYPTR(hh, brclog_set, entry->shost_ether, ETH_ALEN, entry);
        entry->brc_id = brc_id;
        timeslot_addobject(brclog_ts, purge_time, entry);
        return true;
    }

    if(entry->brc_id < brc_id) {
        entry->brc_id = brc_id;
        timeslot_addobject(brclog_ts, purge_time, entry);
        return true;
    }

    return false;
}
Esempio n. 11
0
void mgr_on_accept(int fd, event_manager* ev_mgr)
{
    if (internal_threads(ev_mgr->excluded_threads, pthread_self()))
        return;

    uint32_t leader_id = get_leader_id(ev_mgr->con_node);
    if (ev_mgr->node_id == leader_id)
    {
        leader_tcp_pair* new_conn = malloc(sizeof(leader_tcp_pair));
        memset(new_conn,0,sizeof(leader_tcp_pair));

        new_conn->key = fd;
        HASH_ADD_INT(ev_mgr->leader_tcp_map, key, new_conn);

        rsm_op(ev_mgr->con_node, 0, NULL, P_TCP_CONNECT, &new_conn->vs);
    } else {
        request_record* retrieve_data = NULL;
        size_t data_size;
    
        while (retrieve_data == NULL){
            retrieve_record(ev_mgr->db_ptr, sizeof(db_key_type), &ev_mgr->cur_rec, &data_size, (void**)&retrieve_data);
        }
        replica_tcp_pair* ret = NULL;
        HASH_FIND(hh, ev_mgr->replica_tcp_map, &retrieve_data->clt_id, sizeof(view_stamp), ret);
        ret->s_p = fd;
        ret->accepted = 1;
    }

    return;
}
Esempio n. 12
0
void
PinyinEnhanceMapAdd(PyEnhanceMap **map, FcitxMemoryPool *pool,
                    const char *key, unsigned int key_l,
                    const char *word, unsigned int word_l)
{
    PyEnhanceMapWord *py_word;
    PyEnhanceMap *py_map;
#define uthash_malloc(sz) fcitx_memory_pool_alloc_align(pool, sz)
#define uthash_free(ptr)
    word_l++;
    py_word = uthash_malloc(sizeof(PyEnhanceMapWord) + word_l);
    memcpy(py_enhance_map_word(py_word), word, word_l);
    HASH_FIND(hh, *map, key, key_l, py_map);
    if (py_map) {
        py_word->next = py_map->words;
        py_map->words = py_word;
    } else {
        py_map = uthash_malloc(sizeof(PyEnhanceMap) + key_l + 1);
        py_map->words = py_word;
        py_word->next = NULL;
        memcpy(py_enhance_map_key(py_map), key, key_l + 1);
        HASH_ADD_KEYPTR(hh, *map, py_enhance_map_key(py_map), key_l, py_map);
    }
#undef uthash_malloc
#undef uthash_free
}
Esempio n. 13
0
int parse_packet(struct sockaddr_in* addr, char* raw, struct packet_header* header, char* body) {
  struct io_peer *peer = NULL;
  HASH_FIND(hh_addr, peers_addr, addr, sizeof(struct sockaddr_in), peer);
  if (peer == NULL) {
    DPRINTF(DEBUG_SOCKETS, "Unknown peer from %s:%d\n",
            inet_ntoa(addr->sin_addr),
            ntohs(addr->sin_port));
    return -1;
  }

  int peer_id = peer->id;

  memcpy(header, raw, sizeof(struct packet_header));
  packet_ntoh(header);
  if (header->magic != PACKET_MAGIC || header->version != PACKET_VERSION) {
    fprintf(stderr, "Cannot parse unknown packet with MAGIC %d and version %d\n", header->magic, header->version);
    return -1;
  }
  if (header->type == PACKET_ACK) {
    ++header->ack;
  }

  size_t body_len = header->total_len - header->header_len;
  memcpy(body, raw + header->header_len, body_len);

  DPRINTF(DEBUG_SOCKETS, "receive packet from peer:%d type:%d seq:%d ack:%d body_len:%d\n",
          peer_id, header->type, header->seq, header->ack, body_len);

  return peer_id;
}
Esempio n. 14
0
void _xcb_im_handle_reset_ic(xcb_im_t* im, xcb_im_client_t* client, const xcb_im_packet_header_fr_t* hdr, uint8_t* data)
{
    xcb_im_reset_ic_fr_t frame;
    _xcb_im_read_frame_with_error(im, client, frame, data, XIM_MESSAGE_BYTES(hdr));

    do {
        if (client->connect_id != frame.input_method_ID) {
            break;
        }

        xcb_im_input_context_t* ic = NULL;
        HASH_FIND(hh, client->input_contexts, &frame.input_context_ID, sizeof(uint16_t), ic);
        if (!ic) {
            break;
        }

        xcb_im_reset_ic_reply_fr_t reply_frame;
        reply_frame.input_method_ID = frame.input_method_ID;
        reply_frame.input_context_ID = frame.input_context_ID;
        reply_frame.committed_string = NULL;
        reply_frame.byte_length_of_committed_string = 0;

        if (im->callback) {
            im->callback(im, client, ic, hdr, &frame, &reply_frame, im->user_data);
        }

        _xcb_im_send_frame(im, client, reply_frame, true);
        free(reply_frame.committed_string);
    } while(0);

    xcb_im_reset_ic_fr_free(&frame);
}
Esempio n. 15
0
void _xcb_im_handle_forward_event(xcb_im_t* im, xcb_im_client_t* client, const xcb_im_packet_header_fr_t* hdr, uint8_t* data)
{
    xcb_im_forward_event_fr_t frame;
    _xcb_im_read_frame_with_error(im, client, frame, data, XIM_MESSAGE_BYTES(hdr));

    do {
        if (client->connect_id != frame.input_method_ID) {
            break;
        }

        if (XIM_MESSAGE_BYTES(hdr) < xcb_im_forward_event_fr_size(&frame) + sizeof(xcb_key_press_event_t)) {
            break;
        }

        xcb_im_input_context_t* ic = NULL;
        HASH_FIND(hh, client->input_contexts, &frame.input_context_ID, sizeof(uint16_t), ic);
        if (!ic) {
            break;
        }
        if (client->sync) {
            _xcb_im_add_queue(im, client, ic->id, hdr, &frame, data);
        } else {
            xcb_key_press_event_t key_event;
            memcpy(&key_event, data, sizeof(xcb_key_press_event_t));

            if (im->callback) {
                im->callback(im, client, ic, hdr, &frame, &key_event, im->user_data);
            }
        }
    } while(0);

    xcb_im_forward_event_fr_free(&frame);
}
Esempio n. 16
0
int nat_fix_upstream(nat_ctx_t *ctx, unsigned char *buf, size_t buflen,
                     const struct sockaddr *addr, socklen_t addrlen) {
  uint8_t iphdr_len;
  if (buflen < SHADOWVPN_USERTOKEN_LEN + 20) {
    errf("nat: ip packet too short");
    return -1;
  }
  ipv4_hdr_t *iphdr = (ipv4_hdr_t *)(buf + SHADOWVPN_USERTOKEN_LEN);
  if ((iphdr->ver & 0xf0) != 0x40) {
    // check header, currently IPv4 only
    // bypass IPv6
    return 0;
  }
  iphdr_len = (iphdr->ver & 0x0f) * 4;

  // print_hex_memory(buf, SHADOWVPN_USERTOKEN_LEN);
  client_info_t *client = NULL;
  HASH_FIND(hh1, ctx->token_to_clients, buf, SHADOWVPN_USERTOKEN_LEN, client);
  if (client == NULL) {
    errf("nat: client not found for given user token");
    return -1;
  }
  // print_hex_memory(iphdr, buflen - SHADOWVPN_USERTOKEN_LEN);

  // save source address
  client->source_addr.addrlen =  addrlen;
  memcpy(&client->source_addr.addr, addr, addrlen);

  int32_t acc = 0;
  // save tun input ip to client
  client->input_tun_ip = iphdr->saddr;

  // overwrite IP
  iphdr->saddr = client->output_tun_ip;

  // add old, sub new
  acc = client->input_tun_ip - iphdr->saddr;
  ADJUST_CHECKSUM(acc, iphdr->checksum);

  if (0 == (iphdr->frag & htons(0x1fff))) {
    // only adjust tcp & udp when frag offset == 0
    void *ip_payload = buf + SHADOWVPN_USERTOKEN_LEN + iphdr_len;
    if (iphdr->proto == IPPROTO_TCP) {
      if (buflen < iphdr_len + 20) {
        errf("nat: tcp packet too short");
        return -1;
      }
      tcp_hdr_t *tcphdr = ip_payload;
      ADJUST_CHECKSUM(acc, tcphdr->checksum);
    } else if (iphdr->proto == IPPROTO_UDP) {
      if (buflen < iphdr_len + 8) {
        errf("nat: udp packet too short");
        return -1;
      }
      udp_hdr_t *udphdr = ip_payload;
      ADJUST_CHECKSUM(acc, udphdr->checksum);
    }
  }
  return 0;
}
Esempio n. 17
0
void _xcb_im_handle_destroy_ic(xcb_im_t* im,
                               xcb_im_client_t* client,
                               const xcb_im_packet_header_fr_t* hdr,
                               uint8_t* data)
{
    xcb_im_destroy_ic_fr_t frame;
    _xcb_im_read_frame_with_error(im, client, frame, data, XIM_MESSAGE_BYTES(hdr));

    do {
        if (frame.input_method_ID != client->connect_id) {
            break;
        }

        xcb_im_input_context_t* ic = NULL;
        HASH_FIND(hh, client->input_contexts, &frame.input_context_ID, sizeof(uint16_t), ic);
        if (!ic) {
            break;
        }

        xcb_im_destroy_ic_reply_fr_t reply_frame;
        reply_frame.input_method_ID = client->connect_id;
        reply_frame.input_context_ID = frame.input_context_ID;
        xcb_im_destroy_ic_fr_free(&frame);

        _xcb_im_destroy_ic(im, ic);

        _xcb_im_send_frame(im, client, reply_frame, true);
        return;
    } while(0);
    // error
    xcb_im_destroy_ic_fr_free(&frame);
    _xcb_im_send_error_message(im, client);
    return;
}
Esempio n. 18
0
int moloch_plugins_register_internal(const char *            name,
                                     gboolean                storeData,
                                     size_t                  sessionsize,
                                     int                     apiversion)
{
    MolochPlugin_t *plugin;

    if (sizeof(MolochSession_t) != sessionsize) {
        LOG("Plugin '%s' built with different version of moloch.h", name);
        exit(-1);
    }

    if (MOLOCH_API_VERSION != apiversion) {
        LOG("Plugin '%s' built with different version of moloch.h", name);
        exit(-1);
    }

    HASH_FIND(p_, plugins, name, plugin);
    if (plugin) {
        LOG("Plugin %s is already registered", name);
        exit(-1);
    }

    plugin = MOLOCH_TYPE_ALLOC0(MolochPlugin_t);
    plugin->name = strdup(name);
    if (storeData) {
        plugin->num  = config.numPlugins++;
    } else {
        plugin->num  = -1;
    }
    HASH_ADD(p_, plugins, name, plugin);
    return plugin->num;
}
Esempio n. 19
0
/**
 * Computes the bag distance of two strings. The distance approximates
 * and lower bounds the Levenshtein distance.
 * @param x first string 
 * @param y second string
 * @return Bag distance
 */
float dist_bag_compare(hstring_t x, hstring_t y)
{
    float d = 0;
    bag_t *xh, *yh, *xb, *yb;

    xh = bag_create(x);
    yh = bag_create(y);

    int missing = y.len;
    for (xb = xh; xb != NULL; xb = xb->hh.next) {
        HASH_FIND(hh, yh, &(xb->sym), sizeof(sym_t), yb);
        if (!yb) {
            d += xb->cnt;
        } else {
            d += fabs(xb->cnt - yb->cnt);
            missing -= yb->cnt;
        }
    }
    d += missing;

    bag_destroy(xh);
    bag_destroy(yh);

    return lnorm(n, d, x, y);
}
Esempio n. 20
0
static void do_action_tcp_connect(view_stamp clt_id,void* arg){
    event_manager* ev_mgr = arg;
    replica_tcp_pair* ret;

    HASH_FIND(hh, ev_mgr->replica_tcp_map, &clt_id, sizeof(view_stamp), ret);
    if(NULL==ret){
        ret = malloc(sizeof(replica_tcp_pair));
        memset(ret,0,sizeof(replica_tcp_pair));
        ret->key = clt_id;
        ret->accepted = 0;
        HASH_ADD(hh, ev_mgr->replica_tcp_map, key, sizeof(view_stamp), ret);
    }

    int fd = socket(AF_INET, SOCK_STREAM, 0);

    connect(fd, (struct sockaddr*)&ev_mgr->sys_addr.s_addr,ev_mgr->sys_addr.s_sock_len);

    ret->p_s = fd;

    SYS_LOG(ev_mgr, "EVENT MANAGER sets up socket connection with server application.\n");
    set_blocking(fd, 0);

    int enable = 1;
    if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&enable, sizeof(enable)) < 0)
        printf("TCP_NODELAY SETTING ERROR!\n");
    keep_alive(fd);
    while (!ret->accepted);

    return;
}
Esempio n. 21
0
bool_t IRType_IsSubclassOf(IRType* pType, IRType* pParentType)
{
	if (pType == pParentType) return TRUE;
	if (pParentType->IsInterface)
	{
		IRInterfaceImpl* lookupType = NULL;
		HASH_FIND(HashHandle, pType->InterfaceTable, pParentType, sizeof(void*), lookupType);
		if (lookupType) return TRUE;
	}

	if (pType->TypeDefinition->Extends.TypeDefinition == NULL) return FALSE;
	switch(pType->TypeDefinition->TypeOfExtends)
	{
		case TypeDefRefOrSpecType_TypeDefinition:
			return IRType_IsSubclassOf(pType->TypeDefinition->Extends.TypeDefinition->File->Assembly->Types[pType->TypeDefinition->Extends.TypeDefinition->TableIndex - 1], pParentType);
			break;
		case TypeDefRefOrSpecType_TypeReference:
			return IRType_IsSubclassOf(pType->TypeDefinition->Extends.TypeReference->ResolvedType->File->Assembly->Types[pType->TypeDefinition->Extends.TypeReference->ResolvedType->TableIndex - 1], pParentType);
			break;
		case TypeDefRefOrSpecType_TypeSpecification:
			Panic("This isn't supported yet, cannot determine the inheritence chain of a generic class yet.");
			break;
	}
	Panic("Invalid TypeOfExtends!");
}
Esempio n. 22
0
void hash_add(int key, long payload, int *id_ctr){
  record_t *s;
  HASH_FIND(hh, records, &key, sizeof(int),s);
  //When true, no record with same key exists
  if(s==NULL)
    {
      record_t *r = (record_t*)malloc( sizeof(record_t) );
      memset(r, 0, sizeof(record_t));
      r->key=key;
      r->payload=payload;
      r->id=(*id_ctr)++;
      r->count=1;
      HASH_ADD(hh, records, key, sizeof(int), r);
      ll_add(r->id);
    }
  else
    {
      //record with same key exists. need to find out if it's the same payload
      if (s->payload == payload)
	{
	  s->count++;
	  ll_add(s->id);
	}
      else
	{
	  //key collision for different payloads...what to do?
	  //kinda want to linear probe. maybe chaining
	  

	}
      
    }
}
Esempio n. 23
0
STATIC UByte PancakeAuthenticationBackendConfiguration(UByte step, config_setting_t *setting, PancakeConfigurationScope **scope) {
	PancakeAuthenticationConfiguration *config = (PancakeAuthenticationConfiguration*) setting->parent->hook;

	if(step == PANCAKE_CONFIGURATION_INIT) {
		UInt32 length = strlen(setting->value.sval);

		HASH_FIND(hh, PancakeAuthenticationBackends, setting->value.sval, length, config->backend);

		if(config->backend == NULL) {
			PancakeLoggerFormat(PANCAKE_LOGGER_ERROR, 0, "Unknown authentication backend %s", setting->value.sval);
			return 0;
		}

		// Call onConfiguration handler
		if(config->backend->onConfiguration) {
			config->backend->onConfiguration(config);
		}

		// Save some memory
		free(setting->value.sval);
		setting->type = CONFIG_TYPE_NONE;
	}

	return 1;
}
struct fl_url_record *find_url(uint64_t url_id) 
{
    struct fl_url_record *s;

    HASH_FIND(hh, url_map, &url_id, sizeof(url_id), s);  /* s: output pointer */
    return s;
}
Esempio n. 25
0
void _xcb_im_handle_ext_forward_keyevent(xcb_im_t* im, xcb_im_client_t* client, const xcb_im_packet_header_fr_t* hdr, uint8_t* data)
{
    xcb_im_ext_forward_keyevent_fr_t frame;
    _xcb_im_read_frame_with_error(im, client, frame, data, XIM_MESSAGE_BYTES(hdr));

    do {
        if (client->connect_id != frame.input_method_ID) {
            break;
        }

        xcb_im_input_context_t* ic = NULL;
        HASH_FIND(hh, client->input_contexts, &frame.input_context_ID, sizeof(uint16_t), ic);
        if (!ic) {
            break;
        }

        xcb_key_press_event_t key_event;
        memset(&key_event, 0, sizeof(key_event));
        key_event.response_type = frame.xEvent_u_u_type;
        key_event.sequence = frame.sequence_number;
        key_event.root = im->default_screen->root;
        key_event.time = frame.time;
        key_event.detail = frame.keycode;
        key_event.state = frame.state;
        key_event.event = frame.window;

        if (im->callback) {
            im->callback(im, client, ic, hdr, &frame, &key_event, im->user_data);
        }
    } while(0);

    xcb_im_ext_forward_keyevent_fr_free(&frame);
}
Esempio n. 26
0
static int check_symloop_enter(const char *path, dirkey_t *outkey) {
#ifdef _WIN32
    return SYMLOOP_OK;
#else
    struct stat buf;
    symdir_t *item_found = NULL;
    symdir_t *new_item = NULL;

    memset(outkey, 0, sizeof(dirkey_t));
    outkey->dev = 0;
    outkey->ino = 0;

    int res = stat(path, &buf);
    if (res != 0) {
        log_err("Error stat()ing: %s", path);
        return SYMLOOP_ERROR;
    }

    outkey->dev = buf.st_dev;
    outkey->ino = buf.st_ino;

    HASH_FIND(hh, symhash, outkey, sizeof(dirkey_t), item_found);
    if (item_found) {
        return SYMLOOP_LOOP;
    }

    new_item = (symdir_t*)malloc(sizeof(symdir_t));
    memcpy(&new_item->key, outkey, sizeof(dirkey_t));
    HASH_ADD(hh, symhash, key, sizeof(dirkey_t), new_item);
    return SYMLOOP_OK;
#endif
}
Esempio n. 27
0
int moloch_field_by_exp(char *exp)
{
    MolochFieldInfo_t *info = 0;
    HASH_FIND(e_, fieldsByExp, exp, info);
    if (info)
        return info->pos;
    return -1;
}
Esempio n. 28
0
int moloch_field_by_db(char *dbField)
{
    MolochFieldInfo_t *info = 0;
    HASH_FIND(d_, fieldsByDb, dbField, info);
    if (info)
        return info->pos;
    return -1;
}
Esempio n. 29
0
void fcitx_input_context_manager_focus_in(FcitxInputContextManager* manager, uint32_t id)
{
    FcitxInputContext* ic = NULL;
    HASH_FIND(hh, manager->ics, &id, sizeof(uint32_t), ic);
    if (ic) {
        manager->currentIC = ic;
    }
}
Esempio n. 30
0
/* Retrieve a pointer to the window structure for specified id */
window_t *window_get(Window id)
{
	window_t *window;
	
	HASH_FIND(hh, window_map, &id, sizeof(Window), window);
	
	return window;
}