* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tabcomplete.c,v 1.10 2005-01-15 19:47:08 adam Exp $
+ * $Id: tabcomplete.c,v 1.11 2005-06-24 19:56:52 adam Exp $
*/
#include <string.h>
char* complete_from_list(char* completions[], const char *text, int state)
{
- static int idx;
-
- if(!completions) return NULL;
- if(state==0) {
- idx = 0;
- }
- for(; completions[idx]; ++ idx) {
- if(!
+ static int idx;
+
+ if(!completions) return NULL;
+ if(state==0) {
+ idx = 0;
+ }
+ for(; completions[idx]; ++ idx) {
+ if(!
#ifdef WIN32
- _strnicmp
+ _strnicmp
#else
- strncasecmp
+ strncasecmp
#endif
- (completions[idx],text,strlen(text))) {
- ++idx; /* skip this entry on the next run */
- return (char*)strdup(completions[idx-1]);
- };
- };
- return NULL;
+ (completions[idx],text,strlen(text))) {
+ ++idx; /* skip this entry on the next run */
+ return (char*)strdup(completions[idx-1]);
+ };
+ };
+ return NULL;
}
typedef struct {
- oid_class oclass;
- char** values;
- size_t index;
- size_t max;
+ oid_class oclass;
+ char** values;
+ size_t index;
+ size_t max;
} oid_callback_t;
/*!
void oid_loader(struct oident* oid, void* data_)
{
- oid_callback_t* data=(oid_callback_t*) data_;
-
-
- if((oid->oclass == CLASS_GENERAL) || (oid->oclass == data->oclass)) {
- if(data->index==data->max) {
+ oid_callback_t* data=(oid_callback_t*) data_;
+
+
+ if((oid->oclass == CLASS_GENERAL) || (oid->oclass == data->oclass)) {
+ if(data->index==data->max) {
data->values=(char**)realloc(data->values,((data->max+1)*2)*sizeof(char*));
data->max=(data->max+1)*2 - 1;
- };
- data->values[data->index]=oid->desc;
- ++data->index;
- }
+ };
+ data->values[data->index]=oid->desc;
+ ++data->index;
+ }
}
char** build_list_for_oclass(oid_class oclass) {
- oid_callback_t data;
- data.values = (char **) calloc(10,sizeof(char*));
- data.index = 0;
- data.max = 9;
- data.oclass = oclass;
-
- oid_trav(oid_loader, &data);
-
- data.values[data.index]=0;
- return data.values;
+ oid_callback_t data;
+ data.values = (char **) calloc(10,sizeof(char*));
+ data.index = 0;
+ data.max = 9;
+ data.oclass = oclass;
+
+ oid_trav(oid_loader, &data);
+
+ data.values[data.index]=0;
+ return data.values;
}
/* ***************************************************************************
char* complete_format(const char* text, int state)
{
- char** list=build_list_for_oclass(CLASS_RECSYN);
- char* res=complete_from_list(list,text,state);
-
- free(list);
- return res;
+ char** list=build_list_for_oclass(CLASS_RECSYN);
+ char* res=complete_from_list(list,text,state);
+
+ free(list);
+ return res;
}
char* complete_schema(const char* text, int state)
{
- char** list=build_list_for_oclass(CLASS_SCHEMA);
- char* res=complete_from_list(list,text,state);
-
- free(list);
- return res;
+ char** list=build_list_for_oclass(CLASS_SCHEMA);
+ char* res=complete_from_list(list,text,state);
+
+ free(list);
+ return res;
}
char* complete_attributeset(const char* text, int state)
{
- char** list=build_list_for_oclass(CLASS_ATTSET);
- char* res=complete_from_list(list,text,state);
-
- free(list);
- return res;
+ char** list=build_list_for_oclass(CLASS_ATTSET);
+ char* res=complete_from_list(list,text,state);
+
+ free(list);
+ return res;
}
char* default_completer(const char* text, int state)
{
- return complete_from_list(curret_global_list,text,state);
+ return complete_from_list(curret_global_list,text,state);
}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
/* CCL print rpn tree - infix notation
* Europagate, 1995
*
- * $Id: cclptree.c,v 1.4 2004-12-30 00:22:25 adam Exp $
+ * $Id: cclptree.c,v 1.5 2005-06-24 19:56:52 adam Exp $
*
* Old Europagate Log:
*
void fprintSpaces(int indent,FILE * fd_out)
{
- char buf[100];
- sprintf(buf,"%%%d.s",indent);
- fprintf(fd_out,buf," ");
+ char buf[100];
+ sprintf(buf,"%%%d.s",indent);
+ fprintf(fd_out,buf," ");
}
void ccl_pr_tree_as_qrpn(struct ccl_rpn_node *rpn, FILE *fd_out, int indent)
{
- if(indent>0) fprintSpaces(indent,fd_out);
+ if(indent>0)
+ fprintSpaces(indent,fd_out);
switch (rpn->kind)
{
case CCL_RPN_TERM:
{
struct ccl_rpn_attr *attr;
for (attr = rpn->u.t.attr_list; attr; attr = attr->next)
- {
- if (attr->set)
- fprintf(fd_out, "@attr %s ", attr->set);
- else
- fprintf(fd_out, "@attr ");
- switch(attr->kind)
- {
- case CCL_RPN_ATTR_NUMERIC:
+ {
+ if (attr->set)
+ fprintf(fd_out, "@attr %s ", attr->set);
+ else
+ fprintf(fd_out, "@attr ");
+ switch(attr->kind)
+ {
+ case CCL_RPN_ATTR_NUMERIC:
fprintf (fd_out, "%d=%d ", attr->type,
attr->value.numeric);
- break;
- case CCL_RPN_ATTR_STRING:
+ break;
+ case CCL_RPN_ATTR_STRING:
fprintf (fd_out, "%d=%s ", attr->type,
- attr->value.str);
- }
- }
+ attr->value.str);
+ }
+ }
}
- fprintf (fd_out, "\"%s\"\n", rpn->u.t.term);
+ fprintf (fd_out, "\"%s\"\n", rpn->u.t.term);
break;
case CCL_RPN_AND:
fprintf (fd_out, "@and \n");
ccl_pr_tree_as_qrpn (rpn->u.p[1], fd_out,indent+2);
break;
default:
- fprintf(stderr,"Internal Error Unknown ccl_rpn node type %d\n",rpn->kind);
+ fprintf(stderr,"Internal Error Unknown ccl_rpn node type %d\n",rpn->kind);
}
}
void ccl_pr_tree (struct ccl_rpn_node *rpn, FILE *fd_out)
{
- ccl_pr_tree_as_qrpn(rpn,fd_out,0);
+ ccl_pr_tree_as_qrpn(rpn,fd_out,0);
}
{
case CCL_RPN_AND:
wrbuf_puts(w, "@and ");
- break;
+ break;
case CCL_RPN_OR:
wrbuf_puts(w, "@or ");
- break;
+ break;
case CCL_RPN_NOT:
wrbuf_puts(w, "@not ");
- break;
+ break;
case CCL_RPN_PROX:
if (p->u.p[2] && p->u.p[2]->kind == CCL_RPN_TERM)
{
}
else
wrbuf_puts(w, "@prox 0 2 0 1 k 2 ");
- break;
+ break;
default:
- wrbuf_puts(w, "@ bad op (unknown) ");
+ wrbuf_puts(w, "@ bad op (unknown) ");
}
ccl_pquery(w, p->u.p[0]);
ccl_pquery(w, p->u.p[1]);
case CCL_RPN_NOT:
case CCL_RPN_PROX:
ccl_pquery_complex (w, p);
- break;
+ break;
case CCL_RPN_SET:
- wrbuf_puts (w, "@set ");
- wrbuf_puts (w, p->u.setname);
- wrbuf_puts (w, " ");
- break;
+ wrbuf_puts (w, "@set ");
+ wrbuf_puts (w, p->u.setname);
+ wrbuf_puts (w, " ");
+ break;
case CCL_RPN_TERM:
for (att = p->u.t.attr_list; att; att = att->next)
- {
- char tmpattr[128];
- wrbuf_puts (w, "@attr ");
- if (att->set)
- {
- wrbuf_puts (w, att->set);
- wrbuf_puts (w, " ");
- }
- switch(att->kind)
- {
- case CCL_RPN_ATTR_NUMERIC:
- sprintf(tmpattr, "%d=%d ", att->type, att->value.numeric);
- wrbuf_puts (w, tmpattr);
- break;
- case CCL_RPN_ATTR_STRING:
- sprintf(tmpattr, "%d=", att->type);
- wrbuf_puts (w, tmpattr);
- wrbuf_puts(w, att->value.str);
- wrbuf_puts (w, " ");
- break;
- }
- }
- for (cp = p->u.t.term; *cp; cp++)
- {
- if (*cp == ' ' || *cp == '\\')
- wrbuf_putc (w, '\\');
- wrbuf_putc (w, *cp);
- }
- wrbuf_puts (w, " ");
- break;
+ {
+ char tmpattr[128];
+ wrbuf_puts (w, "@attr ");
+ if (att->set)
+ {
+ wrbuf_puts (w, att->set);
+ wrbuf_puts (w, " ");
+ }
+ switch(att->kind)
+ {
+ case CCL_RPN_ATTR_NUMERIC:
+ sprintf(tmpattr, "%d=%d ", att->type, att->value.numeric);
+ wrbuf_puts (w, tmpattr);
+ break;
+ case CCL_RPN_ATTR_STRING:
+ sprintf(tmpattr, "%d=", att->type);
+ wrbuf_puts (w, tmpattr);
+ wrbuf_puts(w, att->value.str);
+ wrbuf_puts (w, " ");
+ break;
+ }
+ }
+ for (cp = p->u.t.term; *cp; cp++)
+ {
+ if (*cp == ' ' || *cp == '\\')
+ wrbuf_putc (w, '\\');
+ wrbuf_putc (w, *cp);
+ }
+ wrbuf_puts (w, " ");
+ break;
}
}
-
-/*
- * Local variables:
- * tab-width: 8
- * c-basic-offset: 4
- * End:
- */