1 #include "tabcomplete.h"
7 /* *****************************************************************************
11 * *****************************************************************************/
13 char* complete_from_list(char* completions[], char *text, int state) {
18 for(; completions[idx]; ++ idx) {
19 if(!strncmp(completions[idx],text,strlen(text))) {
20 ++idx; /* skip this entry on the next run */
21 return (char*)strdup(completions[idx-1]);
28 /* *****************************************************************************
30 * code for getting a list of valid strings from the oid subsystem
32 * *****************************************************************************/
43 This is the call back function given to oid_trav... it updates the list of pointers into the oid
47 void oid_loader(struct oident* oid, void* data_) {
48 oid_callback_t* data=(oid_callback_t*) data_;
50 //fprintf(stderr,"ja7: called with %d: %s\n",oid->oclass,oid->desc);
51 if((oid->oclass == CLASS_GENERAL) || (oid->oclass == data->oclass)) {
52 if(data->index==data->max) {
53 data->values=(char**)realloc(data->values,((data->max+1)*2)*sizeof(char*));
54 data->max=(data->max+1)*2 - 1;
56 data->values[data->index]=oid->desc;
61 char** build_list_for_oclass(oid_class oclass) {
63 data.values = calloc(10,sizeof(char*));
68 oid_trav(oid_loader, &data);
70 data.values[data.index]=0;
74 /* *****************************************************************************
76 * the compleater functions
78 * *****************************************************************************/
80 char* complete_querytype(char *text, int state) {
81 char* querytypes[] = {"ccl2rpn","prefix","cclrpn","ccl",0};
82 return complete_from_list(querytypes,text,state);
86 char* complete_format(char* text, int state) {
87 char** list=build_list_for_oclass(CLASS_RECSYN);
88 char* res=complete_from_list(list,text,state);
94 char* complete_schema(char* text, int state) {
95 char** list=build_list_for_oclass(CLASS_SCHEMA);
96 char* res=complete_from_list(list,text,state);
103 char* complete_attributeset(char* text, int state) {
104 char** list=build_list_for_oclass(CLASS_ATTSET);
105 char* res=complete_from_list(list,text,state);