コード例 #1
0
ファイル: yidb.c プロジェクト: hardeasy/yidb
int exptime2(char *key){
	yidbIndexBlock *dbib;
	dbib = index_find(key);
	if(dbib==NULL){
		return -1;
	}
	return store_get_exptime(dbib->fieldId,dbib->blockPos);
}
コード例 #2
0
ファイル: yidb.c プロジェクト: hardeasy/yidb
int get(char *key,char *result){
	yidbIndexBlock *dbib;
	dbib = index_find(key);
	if(dbib==NULL){
		return -1;
	} 
	return store_get_value(dbib->fieldId,dbib->blockPos,result);
 
}
コード例 #3
0
ファイル: ubasic.c プロジェクト: EtchedPixels/ubasic
/*---------------------------------------------------------------------------*/
static void
jump_linenum(int linenum)
{
  char const* pos = index_find(linenum);
  if(pos != NULL) {
    DEBUG_PRINTF("jump_linenum: Going to line %d.\n", linenum);
    tokenizer_goto(pos);
  } else {
    /* We'll try to find a yet-unindexed line to jump to. */
    DEBUG_PRINTF("jump_linenum: Calling jump_linenum_slow %d.\n", linenum);
    jump_linenum_slow(linenum);
  }
}
コード例 #4
0
static void do_tile
(
 const char* im_filename,
 struct index_info* ii,
 struct mozaic_info* mi
)
{
  int s;
  IplImage* im_ini;
  IplImage* im_bin;
  int x;
  int y;
  unsigned char rgb[3];
  unsigned char ycc[3];

  im_ini = do_open(im_filename);

  /* tile count */
  const int ntil = CONFIG_NTIL;
  const int largest =
    im_ini->width > im_ini->height ? im_ini->width : im_ini->height;
  s = largest / ntil;
  im_bin = do_bin(im_ini, s);

  /* turn into ycc */
  mi->ycc_im = bgr_to_ycc(im_bin);

  /* prepare resulting array */
  mi->w = mi->ycc_im->width;
  mi->h = mi->ycc_im->height;
  mi->tile_arr = malloc(mi->w * mi->h * sizeof(struct index_entry*));

  printf("[ do_tile ]\n");

  for (y = 0; y < mi->h; ++y)
  {
    printf("y == %d\n", y); fflush(stdout);

    for (x = 0; x < mi->w; ++x)
    {
      get_pixel_rgb(im_bin, x, y, rgb);
      get_pixel_ycc(mi->ycc_im, x, y, ycc);

      /* find nearest indexed image */
      mi->tile_arr[y * mi->w + x] = index_find(ii, rgb, ycc);
    }
  }

  cvReleaseImage(&im_bin);
  cvReleaseImage(&im_ini);
}
コード例 #5
0
ファイル: search.c プロジェクト: hatt/ir
void query(struct trie *lexicon, FILE *index, struct mapping **map, char *term) {
  struct token *results = malloc(sizeof(struct token));
  struct token *s, *tmp;

  uint32_t ptr = lexicon_find(lexicon, term);
  fseek(index, ptr, SEEK_SET);

  index_find(index, ptr, &results);

  printf("%s\n", term);
  printf("%u\n", HASH_COUNT(results));
  HASH_ITER(hh, results, s, tmp) {
    printf("%s, %u\n", unmap_document(map, s->id), s->count);
  }
コード例 #6
0
ファイル: ubasic.c プロジェクト: EtchedPixels/ubasic
/*---------------------------------------------------------------------------*/
static void index_add(int linenum, char const* sourcepos) {
  struct line_index *new_lidx;

  if(line_index_head != NULL && index_find(linenum)) {
    return;
  }

  new_lidx = malloc(sizeof(struct line_index));
  new_lidx->line_number = linenum;
  new_lidx->program_text_position = sourcepos;
  new_lidx->next = NULL;

  if(line_index_head != NULL) {
    line_index_current->next = new_lidx;
    line_index_current = line_index_current->next;
  } else {
    line_index_current = new_lidx;
    line_index_head = line_index_current;
  }
  DEBUG_PRINTF("index_add: Adding index for line %d: %p.\n", linenum,
               sourcepos);
}
コード例 #7
0
ファイル: mxml-index.c プロジェクト: stden/Mini-XML
mxml_node_t*                /* O - Node or NULL if none found */
mxmlIndexFind(mxml_index_t* ind,    /* I - Index to search */
              const char*   element,    /* I - Element name to find, if any */
              const char*   value) { /* I - Attribute value, if any */
    int       diff,           /* Difference between names */
              current,        /* Current entity in search */
              first,          /* First entity in search */
              last;           /* Last entity in search */


#ifdef DEBUG
    printf("mxmlIndexFind(ind=%p, element=\"%s\", value=\"%s\")\n",
           ind, element ? element : "(null)", value ? value : "(null)");
#endif /* DEBUG */

    /*
     * Range check input...
     */

    if (!ind || (!ind->attr && value)) {
#ifdef DEBUG
        puts("    returning NULL...");
        printf("    ind->attr=\"%s\"\n", ind->attr ? ind->attr : "(null)");
#endif /* DEBUG */

        return (NULL);
    }

    /*
     * If both element and value are NULL, just enumerate the nodes in the
     * index...
     */

    if (!element && !value) {
        return (mxmlIndexEnum(ind));
    }

    /*
     * If there are no nodes in the index, return NULL...
     */

    if (!ind->num_nodes) {
#ifdef DEBUG
        puts("    returning NULL...");
        puts("    no nodes!");
#endif /* DEBUG */

        return (NULL);
    }

    /*
     * If cur_node == 0, then find the first matching node...
     */

    if (ind->cur_node == 0) {
        /*
         * Find the first node using a modified binary search algorithm...
         */

        first = 0;
        last  = ind->num_nodes - 1;

#ifdef DEBUG
        printf("    find first time, num_nodes=%d...\n", ind->num_nodes);
#endif /* DEBUG */

        while ((last - first) > 1) {
            current = (first + last) / 2;

#ifdef DEBUG
            printf("    first=%d, last=%d, current=%d\n", first, last, current);
#endif /* DEBUG */

            if ((diff = index_find(ind, element, value, ind->nodes[current])) == 0) {
                /*
                 * Found a match, move back to find the first...
                */

#ifdef DEBUG
                puts("    match!");
#endif /* DEBUG */

                while (current > 0 &&
                        !index_find(ind, element, value, ind->nodes[current - 1])) {
                    current --;
                }

#ifdef DEBUG
                printf("    returning first match=%d\n", current);
#endif /* DEBUG */

                /*
                 * Return the first match and save the index to the next...
                */

                ind->cur_node = current + 1;

                return (ind->nodes[current]);
            } else if (diff < 0) {
                last = current;
            } else {
                first = current;
            }

#ifdef DEBUG
            printf("    diff=%d\n", diff);
#endif /* DEBUG */
        }

        /*
         * If we get this far, then we found exactly 0 or 1 matches...
         */

        for (current = first; current <= last; current ++)
            if (!index_find(ind, element, value, ind->nodes[current])) {
                /*
                * Found exactly one (or possibly two) match...
                */

#ifdef DEBUG
                printf("    returning only match %d...\n", current);
#endif /* DEBUG */

                ind->cur_node = current + 1;

                return (ind->nodes[current]);
            }

        /*
         * No matches...
         */

        ind->cur_node = ind->num_nodes;

#ifdef DEBUG
        puts("    returning NULL...");
#endif /* DEBUG */

        return (NULL);
    } else if (ind->cur_node < ind->num_nodes &&
               !index_find(ind, element, value, ind->nodes[ind->cur_node])) {
        /*
         * Return the next matching node...
         */

#ifdef DEBUG
        printf("    returning next match %d...\n", ind->cur_node);
#endif /* DEBUG */

        return (ind->nodes[ind->cur_node ++]);
    }

    /*
     * If we get this far, then we have no matches...
     */

    ind->cur_node = ind->num_nodes;

#ifdef DEBUG
    puts("    returning NULL...");
#endif /* DEBUG */

    return (NULL);
}
コード例 #8
0
ファイル: yidb.c プロジェクト: hardeasy/yidb
	return store_get_value(dbib->fieldId,dbib->blockPos,result);
 
}

int exptime2(char *key){
	yidbIndexBlock *dbib;
	dbib = index_find(key);
	if(dbib==NULL){
		return -1;
	}
	return store_get_exptime(dbib->fieldId,dbib->blockPos);
}

int delete(char *key){
	yidbIndexBlock *dbib;
	dbib = index_find(key);
	if(dbib==NULL){
		return -1;
	}
	set(key,"0",2);
	return 0;
}


int execNetStr(char *str,char *result){
	//command
	int exptime;
	char command[10],key[YIDB_MAX_KEYSIZE],value[YIDB_MAX_VALUESIZE];
	sscanf(str,"%s %s %s %d",command,key,value,&exptime);
	//printf("%s %s %s %d\n", command,key,value,exptime);
	if(strcmp(command,"set")==0 && strlen(key)>0 && strlen(value)>0 ){