if (dicfile->status != DICFILE_OK) return SRCH_FAIL;
gint search4string(gint srchtype, GjitenDicfile *dicfile, gchar *srchstrg, guint32 *res_index, gint *hit_pos, gint *res_len, gchar *res_str) { 	gint search_result;  gchar *linestart, *lineend;   gint copySize = 1023;  static gchar *linsrchptr;	if (dicfile->status == DICFILE_NOT_INITIALIZED) {		if (dicfile_init(dicfile) == FALSE) return SRCH_FAIL; 	}  if ((dicfile != conf.mmaped_dicfile) && (conf.mmaped_dicfile != NULL)) {    //free mem of previously used dicfile			munmap(conf.mmaped_dicfile->mem, conf.mmaped_dicfile->size);		conf.mmaped_dicfile->mem = NULL;		conf.mmaped_dicfile = NULL;	}	if (conf.mmaped_dicfile == NULL) {    //mmap dicfile into memory			conf.mmaped_dicfile = dicfile;    dicfile->mem = (gchar *) mmap(NULL, dicfile->size, PROT_READ, MAP_SHARED, dicfile->file, 0);    if (dicfile->mem == NULL) gjiten_abort_with_msg("mmap() failed\n");		conf.mmaped_dicfile = dicfile;  }  if (srchtype == SRCH_START) {    linsrchptr = dicfile->mem;  } bad_hit:  search_result = SRCH_FAIL; // assume search fails   linsrchptr = strstr(linsrchptr, srchstrg);  if (linsrchptr != NULL) {  // if we have a match    linestart = linsrchptr;    while ((*linestart != '\n') && (linestart != dicfile->mem)) linestart--; // find beginning of line    if (linestart == dicfile->mem) {         if ((isKanjiChar(g_utf8_get_char(linestart)) == FALSE) && (isKanaChar(g_utf8_get_char(linestart)) == FALSE)) {				linsrchptr++;				goto bad_hit;      }    }    linestart++;    lineend = linestart;    *hit_pos = linsrchptr - linestart;    while (*lineend != '\n') { // find end of line      lineend++;      if (lineend >= dicfile->mem + dicfile->size) { 				printf("weird.\n");				break;      }    }    linsrchptr++;	    if ((lineend - linestart + 1) < 1023) copySize = lineend - linestart + 1;    else copySize = 1023;    strncpy(res_str, linestart, copySize);    res_str[copySize] = 0;    *res_index  = (guint32)linestart;    search_result = SRCH_OK; // search succeeded   }  return search_result;}