#define xzero(lvalue) ((void) memset (&(lvalue), '\0', sizeof (lvalue)))
+CHISE_Char_ID
+chise_char_id_parse_c_string (unsigned char *str, int len)
+{
+ int i = 0;
+
+ if ( (len >= 2) && (str[i++] == '?') )
+ {
+ unsigned char c = str[i++];
+ int counter;
+ CHISE_Char_ID cid;
+
+ if (c == '\\')
+ {
+ if (len < 3)
+ return -1;
+ c = str[i++];
+ if (c == '^')
+ {
+ if (len < 4)
+ return -1;
+ c = str[i++];
+ if (c == '?')
+ return 0x7F;
+ else
+ return c & (0x80 | 0x1F);
+ }
+ }
+ if ( c < 0xC0 )
+ {
+ cid = c;
+ counter = 0;
+ }
+ else if ( c < 0xE0 )
+ {
+ cid = c & 0x1f;
+ counter = 1;
+ }
+ else if ( c < 0xF0 )
+ {
+ cid = c & 0x0f;
+ counter = 2;
+ }
+ else if ( c < 0xF8 )
+ {
+ cid = c & 0x07;
+ counter = 3;
+ }
+ else if ( c < 0xFC )
+ {
+ cid = c & 0x03;
+ counter = 4;
+ }
+ else
+ {
+ cid = c & 0x01;
+ counter = 5;
+ }
+
+ if (counter + 2 <= len)
+ {
+ int j;
+
+ for (j = 0; j < counter; j++)
+ cid = (cid << 6) | (str[j + i] & 0x3F);
+ return cid;
+ }
+ }
+ return -1;
+}
int
chise_open_data_source (CHISE_DS *ds, CHISE_DS_Type type, char *location)
unsigned char *str
= (unsigned char *)chise_value_data (&valdatum);
int len = strnlen (str, chise_value_size (&valdatum));
- int i = 0;
- if ( (len >= 2) && (str[i++] == '?') )
- {
- unsigned char c = str[i++];
- int counter;
- CHISE_Char_ID cid;
-
- if (c == '\\')
- {
- if (len < 3)
- return -1;
- c = str[i++];
- if (c == '^')
- {
- if (len < 4)
- return -1;
- c = str[i++];
- if (c == '?')
- return 0x7F;
- else
- return c & (0x80 | 0x1F);
- }
- }
- if ( c < 0xC0 )
- {
- cid = c;
- counter = 0;
- }
- else if ( c < 0xE0 )
- {
- cid = c & 0x1f;
- counter = 1;
- }
- else if ( c < 0xF0 )
- {
- cid = c & 0x0f;
- counter = 2;
- }
- else if ( c < 0xF8 )
- {
- cid = c & 0x07;
- counter = 3;
- }
- else if ( c < 0xFC )
- {
- cid = c & 0x03;
- counter = 4;
- }
- else
- {
- cid = c & 0x01;
- counter = 5;
- }
-
- if (counter + 2 <= len)
- {
- int j;
-
- for (j = 0; j < counter; j++)
- cid = (cid << 6) | (str[j + i] & 0x3F);
- return cid;
- }
- }
+ return chise_char_id_parse_c_string (str, len);
}
return -1;
}
chise_get_attribute_table (db, key_buf, valdatum);
}
+void
+chise_ft_iterate (CHISE_Feature_Table *dbp,
+ int (*func) (CHISE_Feature_Table *db,
+ CHISE_Char_ID cid, CHISE_Value *valdatum))
+{
+ DBT keydatum, valdatum;
+ DBC *dbcp;
+ int status;
+
+ xzero (keydatum);
+ xzero (valdatum);
+
+ status = dbp->cursor (dbp, NULL, &dbcp, 0);
+ for (status = dbcp->c_get (dbcp, &keydatum, &valdatum, DB_FIRST);
+ status == 0;
+ status = dbcp->c_get (dbcp, &keydatum, &valdatum, DB_NEXT))
+ {
+ unsigned char *key_str = (unsigned char *)keydatum.data;
+ int key_len = strnlen (key_str, keydatum.size);
+ CHISE_Char_ID key = chise_char_id_parse_c_string (key_str, key_len);
+ int ret;
+
+ if (ret = func (dbp, key, &valdatum))
+ break;
+ }
+ dbcp->c_close (dbcp);
+}
int
chise_open_attribute_table (CHISE_Attribute_Table **db,