From: Viktor M. <mih...@us...> - 2005-06-03 10:32:11
|
Update of /cvsroot/sblim/sfcb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13949 Modified Files: Makefile.am cimXmlRequest.c configure.ac control.c httpAdapter.c providerMgr.c sfcBroker.c sfcVersion.h trace.h Added Files: avltree.c avltree.h dbpAdapter.c sqlLexer.l sqlParser.y sqlStatement.c sqlStatement.h Log Message: Bug fixed 1214077: Added SQL Support (for JDBC). Index: cimXmlRequest.c =================================================================== RCS file: /cvsroot/sblim/sfcb/cimXmlRequest.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- cimXmlRequest.c 6 May 2005 02:11:58 -0000 1.10 +++ cimXmlRequest.c 3 Jun 2005 10:31:56 -0000 1.11 @@ -339,7 +339,6 @@ {0, iResponseIntro3}, {2, (char*)sb}, {0, iResponseTrailer1}} }; - _SFCB_ENTER(TRACE_CIMXMLPROC, "iMethodResponse"); _SFCB_RETURN(rs); }; @@ -761,7 +760,6 @@ _SFCB_TRACE(1, ("--- Calling Providers")); resp = invokeProviders(&binCtx, &err, &l); _SFCB_TRACE(1, ("--- Back from Provider")); - closeProviderContext(&binCtx); if (err == 0) { _SFCB_RETURN(genResponses(&binCtx, resp, l)); @@ -773,7 +771,6 @@ _SFCB_RETURN(ctxErrResponse(hdr, &binCtx,0)); } - static RespSegments enumClasses(CimXmlRequestContext * ctx, RequestHdr * hdr) { @@ -1038,9 +1035,9 @@ sreq->operation=OPS_ModifyInstance; sreq->count=req->properties+3; - for (i=0; i<req->properties; i++) + for (i=0; i<req->properties; i++){ sreq->properties[i]=setCharsMsgSegment(req->propertyList[i]); - + } xci = &req->namedInstance.instance; xco = &req->namedInstance.path; @@ -1050,6 +1047,7 @@ xco->bindings.keyBindings[i].value, &xco->bindings.keyBindings[i].ref, &val, &type); + CMAddKey(path, xco->bindings.keyBindings[i].name, valp, type); } @@ -1090,6 +1088,7 @@ _SFCB_RETURN(ctxErrResponse(hdr, &binCtx,0)); } + static RespSegments enumInstanceNames(CimXmlRequestContext * ctx, RequestHdr * hdr) { @@ -1101,8 +1100,8 @@ BinRequestContext binCtx; memset(&binCtx,0,sizeof(BinRequestContext)); - XtokEnumInstanceNames *req = (XtokEnumInstanceNames *) hdr->cimRequest; + XtokEnumInstanceNames *req = (XtokEnumInstanceNames *) hdr->cimRequest; path = NewCMPIObjectPath(req->op.nameSpace.data, req->op.className.data, NULL); sreq.objectPath = setObjectPathMsgSegment(path); sreq.principal = setCharsMsgSegment(ctx->principal); @@ -1149,6 +1148,7 @@ BinRequestContext binCtx; memset(&binCtx,0,sizeof(BinRequestContext)); + XtokEnumInstances *req = (XtokEnumInstances *) hdr->cimRequest; if (req->properties) sreqSize+=req->properties*sizeof(MsgSegment); @@ -1170,9 +1170,11 @@ binCtx.rHdr = hdr; binCtx.bHdrSize = sreqSize; binCtx.commHndl = ctx->commHndl; + binCtx.type=CMPI_instance; binCtx.xmlAs=binCtx.noResp=0; binCtx.chunkFncs=ctx->chunkFncs; + if (noChunking) hdr->chunkedMode=binCtx.chunkedMode=0; else { --- NEW FILE: avltree.c --- /* * avltree.c * * (C) Copyright IBM Corp. 2005 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. * * You can obtain a current copy of the Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * Author: Sebastian Seyrich <se...@de...> * * Description: * AVL-Tree Datatype * * * */ #include <stdlib.h> #include "avltree.h" static void freeAvl(AvlTree **t); static void *insertAvl(AvlTree *this, void *item); static void *findAvl(AvlTree *this, void *item); static void *findMinAvl(AvlTree *this); static void *deleteAvl(AvlTree *this, void *item); static void *deleteMinAvl(AvlTree *this); AvlTree *newAvlTree(int (* compar)(const void *, const void *)) { AvlTree *this; this = (AvlTree*)calloc(1,sizeof(AvlTree)); this->root = NULL; this->compar = compar; this->stack = malloc(AVL_STACK_SIZE * sizeof(AvlNode *)); this->pathInfo = malloc(AVL_STACK_SIZE * sizeof(signed char)); this->n = 0; this->free = freeAvl; this->insert = insertAvl; this->find = findAvl; this->findMin = findMinAvl; this->delete = deleteAvl; this->deleteMin = deleteMinAvl; return this; } static void freeAvl(AvlTree **this) { //printf("1\n"); AvlTree * t = *this; // printf("2\n"); int tos; AvlNode *p, **stack; //printf("3\n"); if(t->root) { //printf("4\n"); stack = t->stack; stack[0] = t->root; tos = 1; //printf("5\n"); while(tos) { //printf("6\n"); p = stack[--tos]; if(p->left) { stack[tos++] = p->left; } if(p->right) { stack[tos++] = p->right; } free(p); } } //printf("7\n"); free(t->stack); //printf("8\n"); free(t->pathInfo); //printf("9\n"); free(t); //printf("10\n"); } static void *insertAvl(AvlTree *this, void *item) { int (* compar)(const void *, const void *); int cmpres; void *res; AvlNode *x, *p, *q, *r, **attachX; AvlNode **stack; int tos, stackN; signed char *pathInfo; compar = this->compar; stack = this->stack; pathInfo = this->pathInfo; tos = 0; if((p = this->root)) { for(;;) { stack[tos] = p; cmpres = compar(item, p->item); if(cmpres < 0) { pathInfo[tos] = -1; tos++; p = p->left; if(!p) { attachX = &stack[tos-1]->left; break; } } else if(cmpres > 0) { pathInfo[tos] = 1; tos++; p = p->right; if(!p) { attachX = &stack[tos-1]->right; break; } } else { return p->item; } } } else { attachX = &this->root; } res = NULL; x = malloc(sizeof(AvlNode)); x->left = x->right = NULL; x->balance = 0; x->item = item; *attachX = x; this->n++; stackN = tos; while(tos) { p = stack[--tos]; if(p->balance == 0) { p->balance += pathInfo[tos]; } else { p->balance += pathInfo[tos]; if(p->balance == 0) { break; } else { q = stack[tos + 1]; if(pathInfo[tos] == pathInfo[tos + 1]) { if(pathInfo[tos] == 1) { p->right = q->left; q->left = p; } else { p->left = q->right; q->right = p; } p->balance = q->balance = 0; if(tos != 0) { if(pathInfo[tos-1] == 1) { stack[tos-1]->right = q; } else { stack[tos-1]->left = q; } } else { this->root = q; } break; } else { if(tos + 2 != stackN) { r = stack[tos + 2]; } else { r = x; } if(pathInfo[tos] == 1) { q->left = r->right; p->right = r->left; r->right = q; r->left = p; if(r->balance == 1) { p->balance = -1; q->balance = 0; } else if(r->balance == -1) { p->balance = 0; q->balance = 1; } else { p->balance = q->balance = 0; } } else { q->right = r->left; p->left = r->right; r->left = q; r->right = p; if(r->balance == 1) { p->balance = 0; q->balance = -1; } else if(r->balance == -1) { p->balance = 1; q->balance = 0; } else { p->balance = q->balance = 0; } } r->balance = 0; if(tos != 0) { if(pathInfo[tos-1] == 1) { stack[tos-1]->right = r; } else { stack[tos-1]->left = r; } } else { this->root = r; } break; } } } } return res; } static void *findAvl(AvlTree *this, void *item) { int (* compar)(const void *, const void *); int cmpres; AvlNode *p, *nextP; if((nextP = this->root)) { compar = this->compar; do { p = nextP; cmpres = compar(item, p->item); if(cmpres < 0) { nextP = p->left; } else if(cmpres > 0) { nextP = p->right; } else { return p->item; } } while(nextP); } return NULL; } void *findMinAvl(AvlTree *this) { AvlNode *p, *nextP; if((nextP = this->root)) { do { p = nextP; nextP = p->left; } while(nextP); } else { return NULL; } return p->item; } static void *deleteAvl(AvlTree *this, void *item) { void *res; int (* compar)(const void *, const void *); int cmpres; AvlNode *p, *prevP; AvlNode *m, *prevM; AvlNode *q, *r; AvlNode **stack; int tos, stackP; signed char *pathInfo; if(!(p = this->root)) return NULL; compar = this->compar; stack = this->stack; pathInfo = this->pathInfo; tos = 0; for(;;) { cmpres = compar(item, p->item); if(cmpres < 0) { pathInfo[tos] = -1; stack[tos++] = p; p = p->left; } else if(cmpres > 0) { pathInfo[tos] = 1; stack[tos++] = p; p = p->right; } else { break; } if(!p) { return NULL; } } if(!p->left) { if(tos == 0) { this->root = p->right; } else { prevP = stack[tos-1]; if(p == prevP->left) { prevP->left = p->right; } else { prevP->right = p->right; } } } else if(!p->right) { if(tos == 0) { this->root = p->left; } else { prevP = stack[tos-1]; if(p == prevP->left) { prevP->left = p->left; } else { prevP->right = p->left; } } } else { pathInfo[tos] = 1; stack[tos] = p; stackP = tos++; m = p->right; do { pathInfo[tos] = -1; stack[tos++] = m; m = m->left; } while(m); m = stack[--tos]; if(stackP == 0) { this->root = m; } else { prevP = stack[stackP - 1]; if(p == prevP->left) { prevP->left = m; } else { prevP->right = m; } } prevM = stack[tos-1]; if(prevM != p) { prevM->left = m->right; m->right = p->right; } m->left = p->left; m->balance = p->balance; stack[stackP] = m; } res = p->item; free(p); this->n--; while(tos) { p = stack[--tos]; if(p->balance == 0) { p->balance -= pathInfo[tos]; break; } else { p->balance -= pathInfo[tos]; if(p->balance != 0) { if(pathInfo[tos] == 1) { q = p->left; } else { q = p->right; } if(pathInfo[tos] != q->balance) { if(pathInfo[tos] != 1) { p->right = q->left; q->left = p; } else { p->left = q->right; q->right = p; } if(tos != 0) { if(pathInfo[tos-1] == 1) { stack[tos-1]->right = q; } else { stack[tos-1]->left = q; } } else { this->root = q; } if(q->balance == 0) { p->balance = p->balance > 0 ? 1 : -1; q->balance = -p->balance; break; } else { p->balance = q->balance = 0; } } else { if(pathInfo[tos] != 1) { r = q->left; q->left = r->right; p->right = r->left; r->right = q; r->left = p; if(r->balance == 1) { p->balance = -1; q->balance = 0; } else if(r->balance == -1) { p->balance = 0; q->balance = 1; } else { p->balance = q->balance = 0; } } else { r = q->right; q->right = r->left; p->left = r->right; r->left = q; r->right = p; if(r->balance == 1) { p->balance = 0; q->balance = -1; } else if(r->balance == -1) { p->balance = 1; q->balance = 0; } else { p->balance = q->balance = 0; } } r->balance = 0; if(tos != 0) { if(pathInfo[tos-1] == 1) { stack[tos-1]->right = r; } else { stack[tos-1]->left = r; } } else { this->root = r; } } } } } return res; } static void *deleteMinAvl(AvlTree *this) { void *res; AvlNode *p; AvlNode *q, *r; AvlNode **stack; int tos; stack = this->stack; tos = 0; if((p = this->root)) { do { stack[tos++] = p; p = p->left; } while(p); p = stack[--tos]; } else { return NULL; } if(tos == 0) { this->root = p->right; } else { stack[tos-1]->left = p->right; } res = p->item; free(p); this->n--; while(tos) { p = stack[--tos]; if(p->balance == 0) { p->balance++;; break; } else { p->balance++; if(p->balance != 0) { q = p->right; if(q->balance != -1) { p->right = q->left; q->left = p; if(tos != 0) { stack[tos-1]->left = q; } else { this->root = q; } if(q->balance == 0) { p->balance = 1; q->balance = -1; break; } else { p->balance = q->balance = 0; } } else { r = q->left; q->left = r->right; p->right = r->left; r->right = q; r->left = p; if(r->balance == 1) { p->balance = -1; q->balance = 0; } else if(r->balance == -1) { p->balance = 0; q->balance = 1; } else { p->balance = q->balance = 0; } r->balance = 0; if(tos != 0) { stack[tos-1]->left = r; } else { this->root = r; } } } } } return res; } --- NEW FILE: avltree.h --- /* * avltree.h * * (C) Copyright IBM Corp. 2005 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. * * You can obtain a current copy of the Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * Author: Sebastian Seyrich <se...@de...> * * Description: * AVL-Tree Datatype * * * */ #ifndef AVL_H #define AVL_H #define AVL_STACK_SIZE 1000 struct avlTree; typedef struct avlTree AvlTree; struct avlNode; typedef struct avlNode AvlNode; typedef struct avlNode { void *item; struct avlNode *left, *right; signed char balance; }; typedef struct avlTree { AvlNode *root; int n; int (* compar)(const void * a, const void *b); AvlNode **stack; void (*free)(AvlTree **this); void* (*insert)(AvlTree *this, void *item); void* (*find)(AvlTree *this, void *item); void* (*findMin)(AvlTree *this); void* (*delete)(AvlTree *this, void *item); void* (*deleteMin)(AvlTree *this); signed char *pathInfo; }; AvlTree *newAvlTree(int (* compar)(const void *, const void *)); #endif Index: sfcBroker.c =================================================================== RCS file: /cvsroot/sblim/sfcb/sfcBroker.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- sfcBroker.c 29 Apr 2005 11:35:31 -0000 1.11 +++ sfcBroker.c 3 Jun 2005 10:31:57 -0000 1.12 @@ -306,6 +306,32 @@ return 0; } + +extern int dbpDaemon(int argc, char *argv[], int sslMode, int sfcbPid); +int startDbpd(int argc, char *argv[], int sslMode) +{ + int pid,sfcPid=currentProc; + //sleep(2); + pid= fork(); + if (pid < 0) { + perror("dbpd fork"); + exit(2); + } + if (pid == 0) { + currentProc=getpid(); + dbpDaemon(argc, argv, sslMode, sfcPid); + closeSocket(&sfcbSockets,cRcv,"startHttpd"); + closeSocket(&resultSockets,cAll,"startHttpd"); + } + else { + addStartedAdapter(pid); + return 0; + } + return 0; +} + + + int main(int argc, char *argv[]) { int c, i; @@ -435,6 +461,15 @@ startHttpd(argc, argv,0); } + //Start dbProtocol-Daemon + if (startHttp) { + if (sslMode) + startDbpd(argc, argv,1); + if (!sslOMode) + startDbpd(argc, argv,0); + } + + setSignal(SIGSEGV, handleSigSegv,SA_ONESHOT); setSignal(SIGCHLD, handleSigChld,0); Index: sfcVersion.h =================================================================== RCS file: /cvsroot/sblim/sfcb/sfcVersion.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- sfcVersion.h 9 Mar 2005 12:25:14 -0000 1.1.1.1 +++ sfcVersion.h 3 Jun 2005 10:31:57 -0000 1.2 @@ -28,11 +28,13 @@ #define sfcBrokerVersion PACKAGE_VERSION #define sfcHttpDaemonVersion PACKAGE_VERSION +#define sfcdbpDaemonVersion "0.1.0" #else /* this should never be used - but who knows */ #define sfcBrokerVersion "0.8.1" #define sfcHttpDaemonVersion "0.8.1" +#define sfcdbpDaemonVersion "0.1.0" #endif --- NEW FILE: sqlParser.y --- /* **============================================================================== ** ** Includes ** **============================================================================== */ %{ /* * sqlParser.y * * (C) Copyright IBM Corp. 2005 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. [...1669 lines suppressed...] %% static UtilList* cloneAL(){ UtilList * res = newList(); int i; ExpressionLight* exl; for(exl = (ExpressionLight*)assignmentList->ft->getFirst(assignmentList);exl;exl = (ExpressionLight*)assignmentList->ft->getNext(assignmentList)){ res->ft->append(res,newExpressionLight(exl->name,UNDEF,NULL)); } return res; } static char* semanticError(char* s1, char* s2, char* s3){ char *message = (char *) malloc(strlen(s1)+strlen(s2)+strlen(s3)+1); strcpy(message,s1); strcat(message,s2); strcat(message,s3); return message; } //int main() {printf("hm\n");return yyparse(); } Index: providerMgr.c =================================================================== RCS file: /cvsroot/sblim/sfcb/providerMgr.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- providerMgr.c 30 May 2005 01:32:24 -0000 1.10 +++ providerMgr.c 3 Jun 2005 10:31:57 -0000 1.11 @@ -1287,3 +1287,5 @@ _SFCB_RETURN(ul); } + + Index: configure.ac =================================================================== RCS file: /cvsroot/sblim/sfcb/configure.ac,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- configure.ac 27 Apr 2005 11:53:13 -0000 1.10 +++ configure.ac 3 Jun 2005 10:31:57 -0000 1.11 @@ -21,7 +21,7 @@ # Process this file with autoconf to produce a configure script. -AC_INIT(Small Footprint CIM Broker, 0.8.8, sc...@de..., sblim-sfcb) +AC_INIT(Small Footprint CIM Broker, 0.8.9, sc...@de..., sblim-sfcb) AC_CONFIG_SRCDIR([providerDrv.c]) AM_INIT_AUTOMAKE --- NEW FILE: sqlStatement.h --- /* * sqlStatement.h * * (C) Copyright IBM Corp. 2005 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. * * You can obtain a current copy of the Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * Author: Sebastian Seyrich <se...@de...> * * Description: * * * * */ #include "utilft.h" //#include "cimXmlParser.h" //Provider operationen //#include "cmpidt.h" //#include "objectImpl.h" //#include "cmpimacs.h" //#include "genericlist.h" #include "avltree.h" #define DEFAULTDB "root/cimv2" /* SqlStatement.type: */ #define SELECT 0 #define INSERT 1 #define UPDATE 2 #define DELETE 3 #define CREATE 4 #define DROP 5 #define CALL 6 #define SUB 10 #define FUL 11 #define INITFUL 12 #define SIGMA 13 //#define FINISHFS 14 #define INSTUPEL 14 #define PRJ 20 #define ALL 21 #define DIST 22 #define ASC 30 #define DSC 31 #define UNION 50 #define UNIONALL 51 #define EXCEPT 52 #define EXCEPTALL 53 #define INTERSECT 54 #define INTERSECTALL 55 #define PLUS 60 //#define SUB 61 #define MUL 62 #define DIV 63 //assignment String #define ASS 64 //assignment Number #define ASN 65 #define CONCAT 66 #define EQ 71 #define NOT 70 #define NE 72 #define GT 73 #define LT 74 #define GE 75 #define LE 76 #define AND 80 #define OR 81 #define ISNULL 82 #define NOTNULL 83 #define BETWEEN 84 #define NOTBETWEEN 85 #define INNER 90 #define LEFT 91 #define RIGHT 92 #define FULL 93 #define EMPTY 100 #define KEY 101 #define NKEY 102 #define UNDEF -1 #define OK 1 //falls die Anzahl der Spalten der verschiedenen Spalten ungleich ist #define CCOUNTERR 2000 //die erste Spalte, die nicht vereingbar ist. die mod 2000 999 Stellen codieren die Spaltennr #define CDEFERR 3000 struct sqlWarning; typedef struct sqlWarning SqlWarning; struct resultSet; typedef struct resultSet ResultSet; struct sqlStatement; typedef struct sqlStatement SqlStatement; struct fullSelect; typedef struct fullSelect FullSelect; struct subSelect; typedef struct subSelect SubSelect; struct projection; typedef struct projection Projection; struct column; typedef struct column Column; struct selection; typedef struct selection Selection; struct crossJoin; typedef struct crossJoin CrossJoin; struct row; typedef struct row Row; struct classDef; typedef struct classDef ClassDef; struct order; typedef struct order Order; struct sigma; typedef struct sigma Sigma; struct expressionLight; typedef struct expressionLight ExpressionLight; struct updIns; typedef struct updIns UpdIns; struct insert; typedef struct insert Insert; struct updIns { char * tname; UtilList * colList; UtilList * assignmentList; UtilList * where; void (*free)(); }; struct insert { char * tname; FullSelect* fs; UtilList * tupelList; void (*free)(); }; struct expressionLight { int op; int sqltype; char * name; char * value; void (*free)(); }; struct classDef { int fieldCount; char * className; UtilList * fieldNameList; //Columns stecken da drin int fNameLength; char * superclass; char * description; }; struct sqlWarning { char* sqlstate; char* reason; void (*setWarning)(); void (*free)(); }; struct resultSet { SqlWarning *sw; char* query; char* meta; char* tupel; void (*setWarning)(ResultSet *this, char* s, char *r); void (*addMeta)(ResultSet *this, Projection* prj); int (*addSet)(ResultSet *this, FullSelect* fs); void (*free)(); }; struct sqlStatement { int type;//select, insert, update... ResultSet* rs; void* stmt; char* db;//namespace //int currentType; UtilList* cnode; FullSelect * lasttos;//um Sigma in fs einfügen zu können. wenn der parser das sigma erstellt hat ist aber setB schon gefüllt und das aktuelle fs schon vom stack genommen. //void* clipboard; //int prevType; //void* prevnode; void (*free)(); //void (*setClipBoard)(SqlStatement* this, void * value); //void* (*getClipBoard)(SqlStatement* this); int (*addNode)(SqlStatement* this, int type, void * value); int (*calculate)(); }; struct fullSelect { void* setA; int typeA;//fullselect oder subselect int type; //UNION, EXCEPT, ... Projection *pi;//hier wird eine Referenz auf eines der Subselects //gespeichert zum schnellen Vergleich, ob die weiteren //Subselects konform dazu sind! void* setB; Selection *sigma; int typeB; void (*free)(); AvlTree* (*calculate)(); }; struct subSelect { Projection* pi; Selection* sigma; CrossJoin* cross; int isSet; AvlTree* set; char* setName; char* aliasName; void (*free)(); void (*addNode)(SubSelect* this,int type, void* value); void (*addWhereList)(SubSelect* this, UtilList *ul); AvlTree* (*calculate)(); }; struct projection { int mode;//ALL, DISTINKT //Könnte auch in Selection passen?? //int colCount; void (*free)(); UtilList* col; }; struct column { char* tableName; char* tableAlias; char* colName; char* colAlias; int colSQLType; int isKey; char *description; void (*free)(); }; struct selection { int fetchFirst; //oderBy und fetch first sind nicht wirklich eigenschaften //dieses objekts, allerdings passen sie hier dazu. UtilList *orderBy; UtilList * where; void (*free)(); }; struct crossJoin { SubSelect* setA; SubSelect* setB; int type; void (*free)(); AvlTree* (*calculate)(); }; struct order{ int column; int order; int colSQLType; void (*free)(); }; struct row { char** row; int doublette;//hack. da avl-baum doubletten nicht unterstützt int size; Selection * sigma; void (*free)(); }; struct sigma{ int link; //AND OR int op; //== != < ... Column* colA; char* value; //mit was der wert verglichen werden soll char* valueB;//falls joinbedingung, oder between (dann steht hier der zweite wert, daher auch double...) Column* colB; void (*negate)(Sigma* this); void (*free)(); }; ResultSet* newResultSet(char* query); SqlStatement* newSqlStatement(int type, ResultSet* rs); FullSelect* newFullSelect(); SubSelect* newSubSelect(); SubSelect* newSubSelectC(SubSelect* sbsA,SubSelect* sbsB, int type); Projection* newProjection(int mode, UtilList* ul); Column* newColumn(char* tableName,char* tableAlias, char* colName, char* colAlias, int colSQLType,int isKey); Selection* newSelection(UtilList* orderBy, int fetchFirst); CrossJoin* newCrossJoin(SubSelect* sbsA,SubSelect* sbsB, int type); Row* newRow(int size); Order *newOrder(int nr, int type, int order); Sigma* newSigmachar(Column* colA, int op,char* value, Column* colB,char* valueB); ExpressionLight* newExpressionLight(char* name, int op,char* value); UpdIns* newUpdIns(char* tname, UtilList* colList,UtilList* assignmentList,UtilList* where); Insert* newInsert(char* tname); ClassDef* newClassDef(int fieldCount, char * className, UtilList * fieldNameList, int fNameLength, char * superclass); //int item_cmp(const void *item1, const void *item2); //char* type2sqlString(int type); //char * int2String(int v) Index: httpAdapter.c =================================================================== RCS file: /cvsroot/sblim/sfcb/httpAdapter.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- httpAdapter.c 9 May 2005 16:24:18 -0000 1.8 +++ httpAdapter.c 3 Jun 2005 10:31:57 -0000 1.9 @@ -415,7 +415,6 @@ int i,len,ls[8]; char str[256]; RespSegments rs; - _SFCB_ENTER(TRACE_HTTPDAEMON, "writeChunkResponse"); switch (ctx->chunkedMode) { case 1: @@ -518,6 +517,7 @@ writeChunkResponse, }; + #undef PrintF static void getHdrs(CommHndl conn_fd, Buffer * b) --- NEW FILE: dbpAdapter.c --- /* * dbpAdapter.c * * (C) Copyright IBM Corp. 2005 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. * * You can obtain a current copy of the Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * Author: Sebastian Seyrich <se...@de...> * * Description: * * * * */ #include <unistd.h> #include <stdlib.h> #include <stdarg.h> #include <stdio.h> #include <string.h> #include <limits.h> #include <errno.h> #include <fcntl.h> #include <signal.h> #include <ctype.h> #include <time.h> #include <sys/wait.h> #include <sys/socket.h> #include <netdb.h> #include "msgqueue.h" #include "utilft.h" #include "trace.h" #include "cimXmlRequest.h" //#include "cimXmlParser.h" #include "queryOperation.h" #include <pthread.h> #include <semaphore.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include "httpComm.h" #include "sfcVersion.h" #include "sqlStatement.h" #include "control.h" //unsigned long exFlags = 0; static char *name; int sfcbSSLMode = 0; static int doFork = 0; static int doBa; int noChunking = 0; static int dbpProcSem; static int dbpWorkSem; static int running=0; static int debug; extern char * configfile; static int stopAccepting=0; static int hBase; static int hMax; static int dbpProcId; #define PROTOCOL 1 #define SQL 2 #define META 3 #define SPOOLIN 4 #define SPOOLOUT 5 //Meta Parameter #define METADB 1 #define TABLES 2 #define STABLES 3 #define KEYS 4 #define COLS 5 //Protokoll Parameter #define LOGOUT 2 #define CONNECT 1 #define HEADER 2 #define CONTINUE 0 #define test 1 //#define printd(x) if(test) printf("%s",x) #define printd(...) if(test) printf(__VA_ARGS__) static const char *metaDB = "version=0.1;name=sfcb;maxcon=1000;mathfunc=keine,nochnich;sqlkeywords=selbe,wie,in,db2;sqlstate=nochnichtstandartisiert;stringfunc=comma,list;systemfunc=noch,nichts;datetimefunc=noch,nichts$$\n"; static key_t dbpProcSemKey; static key_t dbpWorkSemKey; static int dbpProcSem; static int dbpWorkSem; extern int setupControl(char *); extern int getControlNum(char *id, long *val); extern int getControlBool(char *id, int *val); extern int semGetValue(int semid, int semnum); void initDbpProcCtl(int p) { dbpProcSemKey=ftok(".",'D'); dbpWorkSemKey=ftok(".",'E'); char emsg[256]; union semun sun; int i; printf("--- Max dbp procs: %d\n",p); if ((dbpProcSem=semget(dbpProcSemKey,1,0666))!=-1) semctl(dbpProcSem,0,IPC_RMID,sun); if ((dbpProcSem=semget(dbpProcSemKey,1+p,IPC_CREAT | 0666))==-1) { sprintf(emsg,"Dbp Proc semaphore create %d",getpid()); perror(emsg); abort(); } sun.val=p; semctl(dbpProcSem,0,SETVAL,sun); sun.val=0; for (i=1; i<=p; i++) semctl(dbpProcSem,p,SETVAL,sun); if ((dbpWorkSem=semget(dbpWorkSemKey,1,0666))!=-1) semctl(dbpWorkSem,0,IPC_RMID,sun); if ((dbpWorkSem=semget(dbpWorkSemKey,1,IPC_CREAT | 0666))==-1) { sprintf(emsg,"Dpb ProcWork semaphore create %d",getpid()); perror(emsg); abort(); } sun.val=1; semctl(dbpWorkSem,0,SETVAL,sun); } char* processSQLQuery(char *query,CommHndl conn_fd){ int stat = 0; char *res = NULL; ResultSet *rs; //printf("1\n"); rs = parseSql(query,&stat); if(!stat){ printd("Parsen erfolgreich\n"); res = (char *) malloc(strlen(rs->meta)+strlen(rs->tupel)+strlen(rs->sw->reason)+strlen(rs->sw->sqlstate)+4+1+3+3+3+1); strcpy(res,"2 1\n"); strcat(res,rs->sw->sqlstate); strcat(res,";"); strcat(res,rs->sw->reason); strcat(res,"$$\n"); strcat(res,rs->meta); strcat(res,"$$\n"); strcat(res,rs->tupel); strcat(res,"$$\n"); } else{ printd("Parse Error %d!!\n",stat); printd("###%s \n###%s!!\n",rs->sw->reason,rs->sw->sqlstate); res = (char *) malloc(strlen(rs->sw->reason)+strlen(rs->sw->sqlstate)+4+1+3+1);printd("Parse Error 2!!\n"); strcpy(res,"2 0\n"); strcat(res,rs->sw->sqlstate); strcat(res,";"); strcat(res,rs->sw->reason); strcat(res,"$$\n"); //printd("Parse Error 2!!\n"); } //printf("return...\n"); return res; } //CommHndl conn_fd; /* * S E M A P H O R E */ static void handleDbpSession(int connFd) { CommHndl conn_fd; struct sembuf procReleaseUnDo = {0,1,SEM_UNDO}; int r,b2,c, by=0, h, sqlStat; char buffer[1024],bc[1]; char buffer2[500]; char *response=NULL; //Fehlermeldung reinschreiben und an Client zurückschicken. //Vermutlich später nicht mehr notwendig!! char *header=NULL;char *payload; int nbytes; ResultSet *rs; _SFCB_ENTER(TRACE_DBPDAEMON, "handledbpRequest"); _SFCB_TRACE(1, ("--- Forking sql handler")); printf("dbpProcSem %p dbpProcId: %d hMax: %d doFork: %d\n",dbpProcSem,dbpProcId,hMax,doFork); printf("dbpProcId: %d hMax: %d doFork: %d\n",dbpProcId,hMax,doFork); if (doFork) { semAcquire(dbpWorkSem,0); semAcquire(dbpProcSem,0); for (dbpProcId=0; dbpProcId<hMax; dbpProcId++) if (semGetValue(dbpProcSem,dbpProcId+1)==0) break; printf("dbpProcId: %d hMax: %d\n",dbpProcId,hMax); procReleaseUnDo.sem_num=dbpProcId+1; r = fork(); if (r==0) { currentProc=getpid(); processName="CIMSQL-Processor"; semRelease(dbpProcSem,0); semAcquireUnDo(dbpProcSem,0); semReleaseUnDo(dbpProcSem,dbpProcId+1); semRelease(dbpWorkSem,0); if (sfcbSSLMode) { #if defined USE_SSL conn_fd.socket=-2; conn_fd.bio=BIO_new(BIO_s_socket()); BIO_set_fd(conn_fd.bio,connFd,BIO_CLOSE); if (!(conn_fd.ssl = SSL_new(ctx))) intSSLerror("Error creating SSL context"); SSL_set_bio(conn_fd.ssl, conn_fd.bio, conn_fd.bio); if (SSL_accept(conn_fd.ssl) <= 0) intSSLerror("Error accepting SSL connection"); #endif } else { conn_fd.socket=connFd; #if defined USE_SSL conn_fd.bio=NULL; conn_fd.ssl=NULL; #endif } } else if (r>0) { running++; _SFCB_EXIT(); } } else r = 0; if (r < 0) { char *emsg=strerror(errno); mlogf(M_ERROR,M_SHOW,"--- fork handler: %s\n",emsg); exit(1); } if (r == 0) { if (doFork) { _SFCB_TRACE(1,("--- Forked sql handler %d", currentProc)) resultSockets=sPairs[hBase+dbpProcId]; } _SFCB_TRACE(1,("--- Started sql handler %d %d", currentProc, resultSockets.receive)); if (getenv("SFCB_PAUSE_HTTP")) for (;;) { fprintf(stderr,"-#- Pausing - pid: %d\n",currentProc); sleep(5); } conn_fd.socket=connFd; #if defined USE_SSL conn_fd.bio=NULL; conn_fd.ssl=NULL; #endif for(;;){ //c onn_fd.socket=connFd; // doHttpRequest(conn_fd); nbytes = read (connFd, buffer, HEADER); header = (char *) malloc(nbytes);//sowas wie \n Steuerzeichen strncpy(header,buffer,nbytes); header[nbytes]=0; h = atoi(header); printd("Ein Client h: %d header: %s nbytes: %d\n",h,header,nbytes); //Sonderfall, noch nicht eingeloggt if(by&h){ //login nbytes = read(connFd, buffer, 2); c = atoi(&buffer); if(c==CONNECT){ printd("Ein Client hat sich korrekt angemeldet\n"); response = "1 1 1\n";//"Sie sind angemeldet. Warte auf Anfragen:\n"; write(connFd, response , strlen(response)); by=0; h=CONTINUE;//dummy, um switch sofort zu verlassen } else{ printd("Ein Client hat sich NICHT korrekt angemeldet %d\n",c); response = "1 1 0\n";//"Sie sind nicht angemeldet. Auf wiedersehen.\n"; write(connFd, response , strlen(response)); break; } while((nbytes = read(connFd, bc, 1))>0)// if(bc[0]=='\n') break; } if(by){ printd("Ein Client hat sich NICHT korrekt angemeldet %d\n",h); response = "1 1 0\n";//"Sie sind nicht angemeldet. Auf wiedersehen.\n"; write(connFd, response , strlen(response)); break; } switch(h){ case CONTINUE: break; case PROTOCOL: { nbytes = read(connFd, buffer, 2); c = atoi(&buffer); //Pipe leersaugen while((nbytes = read(connFd, bc, 1))>0)// if(bc[0]=='\n') break; if(c==CONNECT){ response = "1 1 0\n"; //"Sie sind bereits angemeldet, Operation wird ignoriert:\n"; write(connFd, response , strlen(response)); } else if(c==LOGOUT){ printd("Der Client hat die Verbindung beendet\n"); response = "1 2 1\n";//"By\n"; write(connFd, response ,strlen(response)); by=1; } else{ b2 = sprintf("%d %d %d",1,c,0);//sprintf(buffer2, "Syntxfehler: Operation %d ist keine Protokolloperation\n",c); printd("%s",buffer2); write(connFd, buffer2 , b2); } break; } case SQL: while((nbytes = read(connFd, buffer, 1024))>0){ if(buffer[nbytes-1]=='\n') break; //falls Anweisung laenerg als 1024, muss buffer mit vorgaengerbuffer konkadiniert werden. vgl. adrian } // abschlieÃendes $ finden: //printd("SQL: %d\n",nbytes); nbytes--; while((nbytes>0) && (buffer[nbytes]!='$')) nbytes--; //printf("malloc %d bytes",nbytes); payload = (char *) malloc(nbytes+1+1); //ein \n voranstellen, yyerror()s wegen //*payload = '\n'; strcpy(payload,"\n"); strncat(payload,buffer,nbytes); response = processSQLQuery(payload,conn_fd); //--> Datenstruktur, in die das Statement reinkommt free(payload);payload=NULL; //ResultMetaData write(connFd, response , strlen(response)); free(response);response=NULL; break; case META: nbytes = read(connFd, buffer, 2); c = atoi(&buffer); if(c==METADB){ response = (char *) malloc(strlen(metaDB)+7); response = strcpy(response,"3 1 1\n"); response = strcat(response,metaDB); write(connFd, response , strlen(response)); free(response); break; } if(c==TABLES||c==STABLES||c==KEYS||c==COLS){ printf("UND los\n"); while((nbytes = read(connFd, buffer, 1024))>0){ if(buffer[nbytes-1]=='\n') break; //falls Anweisung laenerg als 1024, muss buffer mit vorgaengerbuffer konkadiniert werden. vgl. adrian } // abschlieÃendes $ finden: printd("SQL: %d\n",nbytes); nbytes--; while((nbytes>0) && (buffer[nbytes]!='$')) nbytes--; //printf("malloc %d bytes",nbytes); buffer[nbytes] = 0; if(nbytes==0) payload = NULL; else{ payload = (char *) malloc(nbytes+1); strcpy(payload,buffer); //printd(">%s< %d\n",payload,c); } if(c==TABLES) response = processMetaTables(payload,"root/cimv2"); else if(c==STABLES) response = processSuperTables(payload,"root/cimv2"); else if(c==KEYS) response = processKeyTable(payload,"root/cimv2"); else if(c==COLS){ char *arg2 = strstr(payload,"::"); char *arg1 = strtok(payload,"::"); //printf("lllllll\n"); //printf(">%s< >%s< >%s< >%s<\n",payload,arg2,arg1,arg2+2); response = processMetaColumns(arg1,arg2+2,"root/cimv2"); //printf("zurück\n"); } //printf(">>%s<<",response); free(payload);payload=NULL; write(connFd, response , strlen(response)); //free(response); //dieses free tut nicht, weil irgendwo anders was nicht stimmt!!! break; } break; case SPOOLIN: break; case SPOOLOUT: break; default: printd("Unbekannter Befehl: \"%s\"\n",header); b2 = sprintf(buffer2,"Fehler: unbekannter Befehl: %s \n", header); //strncpy(response,buffer2,b2); //response = "Fehler: Unbekannter Befehl\n"; write(connFd, buffer2 , b2); break; } free(header); if(by) break; } if (!doFork) return; _SFCB_TRACE(1, ("--- SQL handler exiting %d", currentProc)); printf("--- SQL handler exiting %d\n", currentProc); dumpTiming(currentProc); exit(0); } } /*kopiert!!*/ static void handleSigChld(int sig) { const int oerrno = errno; pid_t pid; int status; for (;;) { pid = wait4(0, &status, WNOHANG, NULL); if ((int) pid == 0) break; if ((int) pid < 0) { if (errno == EINTR || errno == EAGAIN) { // fprintf(stderr, "pid: %d continue \n", pid); continue; } if (errno != ECHILD) perror("child wait"); break; } else { running--; fprintf(stderr, "%s: SIGCHLD signal %d - %s(%d)\n", name, pid, __FILE__, __LINE__); } } errno = oerrno; } static void handleSigUsr1(int sig) { stopAccepting=1; fprintf(stderr, "%s: handleSigUsr1 signal %d - %s(%d)\n", name,sig, __FILE__, __LINE__); } /* * Von httpDaemon aus httpAdapter abgeschrieben. * */ int dbpDaemon(int argc, char *argv[], int sslMode, int sfcbPid) {//int argc, char *argv[], int sslMode) { struct sockaddr_in sin; int sz,i,sin_len,ru; char *cp; long procs, port; int listenFd, connFd; name = argv[0]; debug = 1; doFork = 1; _SFCB_ENTER(TRACE_DBPDAEMON, "dbpDaemon"); setupControl(configfile); sfcbSSLMode=sslMode; if (sslMode) processName="DBPS-Daemon"; else processName="DBP-Daemon"; if (sslMode) { if (getControlNum("dbpsPort", &port)) port = 5981; hBase=stBase; hMax=stMax; } else { if (getControlNum("dbpPort", &port)) port = 5980; hBase=htBase; hMax=htMax; } if (getControlNum("dbpProcs", &procs)) procs = 10; initDbpProcCtl(procs); // if (getControlBool("doBasicAuth", &doBa)) // doBa=0; // // i = 1; // while (i < argc && argv[i][0] == '-') { // if (strcmp(argv[i], "-D") == 0) // debug = 1; // else if (strcmp(argv[i], "-nD") == 0) // debug = 0; // else if (strcmp(argv[i], "-p") == 0 && i + 1 < argc) { // ++i; // port = (unsigned short) atoi(argv[i]); // } // else if (strcmp(argv[i], "-tm") == 0) { // if (isdigit(*argv[i + 1])) { // ++i; // } // } // else if (strcmp(argv[i], "-F") == 0) // doFork = 1; // else if (strcmp(argv[i], "-nF") == 0) // doFork = 0; // else if (strcmp(argv[i], "-H") == 0); // ++i; // } // // if (getControlBool("useChunking", &noChunking)) // noChunking=0; // noChunking=noChunking==0; cp = strrchr(name, '/'); if (cp != NULL) ++cp; else cp = name; name = cp; if (sslMode) mlogf(M_INFO,M_SHOW,"--- %s DBPS Daemon V" sfcdbpDaemonVersion " started - %d - port %ld\n", name, currentProc,port); else mlogf(M_INFO,M_SHOW,"--- %s DBP Daemon V" sfcdbpDaemonVersion " started - %d - port %ld\n", name, currentProc,port); if (doBa) mlogf(M_INFO,M_SHOW,"--- Using Basic Authentication\n"); listenFd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); sin_len = sizeof(sin); ru = 1; setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, (char *) &ru, sizeof(ru)); bzero(&sin, sin_len); sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = htons(port); if (bind(listenFd, (struct sockaddr *) &sin, sin_len) || listen(listenFd, 0)) { mlogf(M_ERROR,M_SHOW,"--- Cannot listen on port %ld\n", port); kill(sfcbPid,3); } if (!debug) { int rc = fork(); if (rc == -1) { char *emsg=strerror(errno); mlogf(M_ERROR,M_SHOW,"--- fork daemon: %s",emsg); exit(1); } else if (rc) exit(0); } // memInit(); currentProc=getpid(); setSignal(SIGCHLD, handleSigChld,0); setSignal(SIGUSR1, handleSigUsr1,0); setSignal(SIGINT, SIG_IGN,0); setSignal(SIGTERM, SIG_IGN,0); setSignal(SIGHUP, SIG_IGN,0); // commInit(); #if defined USE_SSL if (sfcbSSLMode) { char *fnc,*fnk; ctx = SSL_CTX_new(SSLv23_method()); getControlChars("sslCertificateFilePath", &fnc); if (SSL_CTX_use_certificate_chain_file(ctx, fnc) != 1) intSSLerror("Error loading certificate from file"); getControlChars("sslKeyFilePath", &fnk); if (SSL_CTX_use_PrivateKey_file(ctx, fnk, SSL_FILETYPE_PEM) != 1) intSSLerror("Error loading private key from file"); } #endif for (;;) { char *emsg; listen(listenFd, 1); sz = sizeof(sin); if ((connFd = accept(listenFd, (__SOCKADDR_ARG) & sin, &sz))<0) { if (errno == EINTR || errno == EAGAIN) { if (stopAccepting) break; continue; } emsg=strerror(errno); mlogf(M_ERROR,M_SHOW,"--- accept error %s\n",emsg); _SFCB_ABORT(); } _SFCB_TRACE(1, ("--- Processing dbp request")); handleDbpSession(connFd); close(connFd); } printf("--- %s draining %d\n",processName,running); for (;;) { if (running==0) { mlogf(M_INFO,M_SHOW,"--- %s terminating %d\n",processName,getpid()); exit(0); } sleep(1); } /* struct sockaddr_in sin; int sz,i,sin_len,ru; char *cp;//?? long procs, port; int listenFd, connFd; name = "sfcBroker"; //debug = 1; //doFork = 1; _SFCB_ENTER(TRACE_DBPDAEMON, "dbpDaemon"); //setupControl(NULL); processName="DBP Daemon"; //Variable aus sfcBroker, dieser neue Prozess hat noch keinen zugewiesen bekommen //if (getControlNum("httpPort", &port)) port = 5980; //hBase=htBase; //hMax=htMax; //initndpProcCtl(procs); cp = strrchr(name, '/'); if (cp != NULL) ++cp; else cp = name; name = cp; printf("--- %s DBP Daemon V" sfcdbpDaemonVersion " started - %d - port %ld\n", name, getpid(),port); listenFd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); sin_len = sizeof(sin); ru = 1; setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, (char *) &ru, sizeof(ru)); bzero(&sin, sin_len); sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = htons(port); if (bind(listenFd, (struct sockaddr *) &sin, sin_len) || listen(listenFd, 0)) {//Test, ob Port frei ist printf("cannot listen on port %ld", port); exit(3); } //if (!debug) { int rc = fork(); if (rc == -1) { perror("fork daemon"); exit(1); } else if (rc) exit(0); //} // memInit(); //printf("jetzt kann sich jemand verbinden\n"); // setSignal(SIGCHLD, handleSigChld,0); for (;;) { listen(listenFd, 1); sz = sizeof(sin); if ((connFd = accept(listenFd, (__SOCKADDR_ARG) & sin, &sz))<0) { if (errno == EINTR || errno == EAGAIN) continue; perror("accept error"); // _SFCB_ABORT(); } _SFCB_TRACE(1, ("--- Processing dbp request")); printd("es hat sich glaub ich jemand verbunden\n"); handleDbpSession(connFd); close(connFd); } */ } --- NEW FILE: sqlStatement.c --- #include "sqlStatement.h" #include "utilft.h" #include "cimXmlParser.h" //Provider operationen #include "cmpidt.h" #include "objectImpl.h" #include "cmpimacs.h" #include <stdio.h> #include <string.h> #include <malloc.h> #define SbS sbs = (SubSelect*)this->cnode; sbs #define FS fs = (FullSelect*)this->cnode; fs #define FREE(zgr){ \ [...3288 lines suppressed...] rs->addSet(rs,t);//mussvor addMeta ausgefuhert werden, da hier pi bei joins geandert wird rs->addMeta(rs,pi); rs->sw->reason = "Successful Completion"; rs->sw->sqlstate = "0000000"; char * res = (char *) malloc(strlen(rs->meta)+strlen(rs->tupel)+strlen(rs->sw->reason)+strlen(rs->sw->sqlstate)+4+1+3+3+3+1); strcpy(res,"3 4 1\n"); strcat(res,rs->sw->sqlstate); strcat(res,";"); strcat(res,rs->sw->reason); strcat(res,"$$\n"); strcat(res,rs->meta); strcat(res,"$$\n"); strcat(res,rs->tupel); strcat(res,"$$\n"); return res; } Index: trace.h =================================================================== RCS file: /cvsroot/sblim/sfcb/trace.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- trace.h 26 May 2005 14:58:55 -0000 1.4 +++ trace.h 3 Jun 2005 10:31:57 -0000 1.5 @@ -114,6 +114,7 @@ #define TRACE_MEMORYMGR 8192 #define TRACE_MSGQUEUE 16384 #define TRACE_XMLPARSING 32768 +#define TRACE_DBPDAEMON 65536 typedef void sigHandler(int); Index: control.c =================================================================== RCS file: /cvsroot/sblim/sfcb/control.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- control.c 26 Apr 2005 21:58:47 -0000 1.6 +++ control.c 3 Jun 2005 10:31:57 -0000 1.7 @@ -48,9 +48,12 @@ Control init[] = { {"httpPort", 1, "5988"}, + {"dbpPort", 1, "5980"}, {"enableHttp", 2, "true"}, {"httpProcs", 1, "8"}, + {"dbpProcs", 1, "8"}, {"httpsPort", 1, "5989"}, + {"httpsPort", 1, "5981"}, {"enableHttps", 2, "false"}, {"httpsProcs", 1, "8"}, {"provProcs", 1, "32"}, Index: Makefile.am =================================================================== RCS file: /cvsroot/sblim/sfcb/Makefile.am,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Makefile.am 2 Jun 2005 17:23:52 -0000 1.22 +++ Makefile.am 3 Jun 2005 10:31:47 -0000 1.23 @@ -26,7 +26,7 @@ sfcbdocdir=$(datadir)/doc/sfcb-$(VERSION) initdir=$(sysconfdir)/init.d -BUILT_SOURCES=queryParser.c queryLexer.c +BUILT_SOURCES=queryParser.c queryLexer.c sqlParser.c sqlLexer.c AM_YFLAGS=-d @@ -86,10 +86,21 @@ queryStatement.c \ cimXmlGen.c \ mrwlock.c \ - mlog.c + mlog.c \ + dbpAdapter.c \ + sqlLexer.c \ + sqlParser.c \ + sqlStatement.c \ + avltree.c libsfcBrokerCore_la_CFLAGS = @SFCB_CMPI_OS@ @SFCB_CMPI_PLATFORM@ +sqlLexer.c: sqlLexer.l sqlParser.y + lex -t sqlLexer.l | sed -e "s/yy/sfcSql/g" > sqlLexer.c + +sqlParser.c: sqlLexer.l sqlParser.y + bison -p sfcSql -d -o sqlParser.c sqlParser.y + queryLexer.c: queryLexer.l queryParser.y lex -t queryLexer.l | sed -e "s/yy/sfcQuery/g" > queryLexer.c --- NEW FILE: sqlLexer.l --- %option never-interactive %{ /* * sqlLexer.l * * (C) Copyright IBM Corp. 2005 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. * * You can obtain a current copy of the Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * Author: Sebastian Seyrich <se...@de...> * * Description: * * * * */ extern int sqlInput(char* buffer, int* numRead, int numRequested); extern int yyErr(const char*); extern char * yyStrcpy(char *txt, int len); extern void setSqlWarning(char* s, char *r); #undef YY_INPUT #define YY_INPUT(BUF, NREAD, NREQUESTED) sqlInput(BUF, &NREAD, NREQUESTED) #include "queryOperation.h" #include "sqlParser.h" #include "sqlStatement.h" #include <stdio.h> #include <string.h> #if 0 # define QL_TRACE(X) printf X #else # define QL_TRACE(X) #endif //extern SqlWarning* Sw; #define MAXBUF 500 char linebuf[MAXBUF]; int lineno=0; int tokenpos=0; %} POSITIVE_DECIMAL_DIGIT [1-9] DECIMAL_DIGIT [0-9] BLANK [ \t] IDENT_CHAR [A-Za-z_] %% "--".* /* comment */ \n.* { strcpy(linebuf, yytext+1);//save next line lineno++; tokenpos = 0; yyless(1);//alles auÃer dem \n zum erneuten Scannen zurückgeben } [Cc][Aa][Ll][Ll] { tokenpos+=yyleng; return TOK_CALL; } [Ss][Mm][Aa][Ll][Ll][Ii][Nn][Tt] { tokenpos+=yyleng; return TOK_SINTDT; } [Ii][Nn][Tt]([Ee][Gg][Ee][Rr])? { tokenpos+=yyleng; return TOK_INTDT; } [Bb][Ii][Gg][Ii][Nn][Tt] { tokenpos+=yyleng; return TOK_BINTDT; } [Rr][Ee][Aa][Ll] { tokenpos+=yyleng; return TOK_REALDT; } [Dd][Oo][Uu][Bb][Ll][Ee] { tokenpos+=yyleng; return TOK_DOUBLEDT; } (([Dd][Ee][Cc]([Ii][Mm][Aa][Ll])?)|([Nn][Uu][Mm]([Ee][Rr][Ii][Cc])?)) { tokenpos+=yyleng; return TOK_DECDT; } [Cc][Hh][Aa][Rr] { tokenpos+=yyleng; return TOK_CHARDT; } [Vv][Aa][Rr][Cc][Hh][Aa][Rr] { tokenpos+=yyleng; return TOK_VCHARDT; } [Dd][Aa][Tt][Ee] { tokenpos+=yyleng; return TOK_DATEDT; } [Tt][Ii][Mm][Ee] { tokenpos+=yyleng; return TOK_TIMEDT; } [Tt][Ii][Mm][Ee][Ss][Tt][Aa][Mm][Pp] { tokenpos+=yyleng; return TOK_TSTAMPDT; } [Ss][Ee][Ll][Ee][Cc][Tt] { QL_TRACE(("LEX: %s [TOK_SELECT]\n", yytext)); tokenpos+=yyleng; return TOK_SELECT; } [Ff][Rr][Oo][Mm] { QL_TRACE(("LEX: %s [TOK_FROM]\n", yytext)); tokenpos+=yyleng; return TOK_FROM; } [Ww][Hh][Ee][Rr][Ee] { QL_TRACE(("LEX: %s [TOK_WHERE]\n", yytext)); tokenpos+=yyleng; return TOK_WHERE; } [Tt][Rr][Uu][Ee] { QL_TRACE(("LEX: %s [TOK_TRUE]\n", yytext)); tokenpos+=yyleng; return TOK_TRUE; } [Ff][Aa][Ll][Ss][Ee] { QL_TRACE(("LEX: %s [TOK_FALSE]\n", yytext)); tokenpos+=yyleng; return TOK_FALSE; } [Nn][Uu][Ll][Ll] { QL_TRACE(("LEX: %s [TOK_NULL]\n", yytext)); tokenpos+=yyleng; return TOK_NULL; } [Cc][Oo][Nn][Cc][Aa][Tt] { QL_TRACE(("LEX: %s [TOK_CONCAT]\n", yytext)); tokenpos+=yyleng; return TOK_CONCAT; } "||" { QL_TRACE(("LEX: %s [TOK_CONCAT]\n", yytext)); tokenpos+=yyleng; return TOK_CONCAT; } [Nn][Oo][Tt] { QL_TRACE(("LEX: %s [TOK_NOT]\n", yytext)); tokenpos+=yyleng; return TOK_NOT; } [Aa][Nn][Dd] { QL_TRACE(("LEX: %s [TOK_AND]\n", yytext)); tokenpos+=yyleng; return TOK_AND; } [Oo][Rr] { QL_TRACE(("LEX: %s [TOK_OR]\n", yytext)); tokenpos+=yyleng; return TOK_OR; } [Ii][Ss] { QL_TRACE(("LEX: %s [TOK_IS]\n", yytext)); tokenpos+=yyleng; return TOK_IS; } [Aa][Ll][Ll] { QL_TRACE(("LEX: %s [TOK_ALL]\n", yytext)); tokenpos+=yyleng; return TOK_ALL; } [Aa][Ss] { QL_TRACE(("LEX: %s [TOK_AS]\n", yytext)); tokenpos+=yyleng; return TOK_AS; } [Dd][Ii][Ss][Tt][Ii][Nn][Cc][Tt] { QL_TRACE(("LEX: %s [TOK_DISTINCT]\n", yytext)); tokenpos+=yyleng; return TOK_DISTINCT; } [Jj][Oo][Ii][Nn] { QL_TRACE(("LEX: %s [TOK_JOIN]\n", yytext)); tokenpos+=yyleng; return TOK_JOIN; } [Oo][Nn] { QL_TRACE(("LEX: %s [TOK_ON]\n", yytext)); tokenpos+=yyleng; return TOK_ON; } [Ll][Ee][Ff][Tt]([ ][Oo][Uu][Tt][Ee][Rr])? { QL_TRACE(("LEX: %s [TOK_LEFT]\n", yytext)); tokenpos+=yyleng; return TOK_LEFT; } [Rr][Ii][Gg][Hh][Tt]([ ][Oo][Uu][Tt][Ee][Rr])? { QL_TRACE(("LEX: %s [TOK_RIGHT]\n", yytext)); tokenpos+=yyleng; return TOK_RIGHT; } [Ff][Uu][Ll][Ll]([ ][Oo][Uu][Tt][Ee][Rr])? { QL_TRACE(("LEX: %s [TOK_FULL]\n", yytext)); tokenpos+=yyleng; return TOK_FULL; } [\*(),.+-] { QL_TRACE(("LEX: %s [???]\n", yytext)); tokenpos+=yyleng; return yytext[0]; } "="|"==" { QL_TRACE(("LEX: %s [TOK_EQ]\n", yytext)); tokenpos+=yyleng; return TOK_EQ; } "!="|"<>" { QL_TRACE(("LEX: %s [TOK_NE]\n", yytext)); tokenpos+=yyleng; return TOK_NE; } "<=" { QL_TRACE(("LEX: %s [TOK_LE]\n", yytext)); tokenpos+=yyleng; return TOK_LE; } "<" { QL_TRACE(("LEX: %s [TOK_LT]\n", yytext)); tokenpos+=yyleng; return TOK_LT; } ">=" { QL_TRACE(("LEX: %s [TOK_GE]\n", yytext)); tokenpos+=yyleng; return TOK_GE; } ">" { QL_TRACE(("LEX: %s [TOK_GT]\n", yytext)); tokenpos+=yyleng; return TOK_GT; } [Dd][Rr][Oo][Pp] { QL_TRACE(("LEX: %s [TOK_DROP]\n", yytext)); tokenpos+=yyleng; return TOK_DROP; } [Tt][Aa][Bb][Ll][Ee] { QL_TRACE(("LEX: %s [TOK_TABLE]\n", yytext)); tokenpos+=yyleng; return TOK_TABLE; } [Aa][Ll][Tt][Ee][Rr] { QL_TRACE(("LEX: %s [TOK_ALTER]\n", yytext)); tokenpos+=yyleng; return TOK_ALTER; } [Cc][Rr][Ee][Aa][Tt][Ee] { QL_TRACE(("LEX: %s [TOK_CREATE]\n", yytext)); tokenpos+=yyleng; return TOK_CREATE; } [Kk][Ee][Yy] { QL_TRACE(("LEX: %s [TOK_KEY]\n", yytext)); tokenpos+=yyleng; return TOK_KEY; } [Ff][Oo][Rr][Ee][Ii][Gg][Nn] { QL_TRACE(("LEX: %s [TOK_FOREIGN]\n", yytext)); tokenpos+=yyleng; return TOK_FOREIGN; } [Uu][Nn][Ii][Qq][Uu][Ee] { QL_TRACE(("LEX: %s [TOK_UNIQUE]\n", yytext)); tokenpos+=yyleng; return TOK_UNIQUE; } [Pp][Rr][Ii][Mm][Ee][Rr][Yy] { QL_TRACE(("LEX: %s [TOK_PRIMARY]\n", yytext)); tokenpos+=yyleng; return TOK_PRIMARY; } [Cc][Oo][Nn][Ss][Tt][Rr][Aa][Ii][Nn][Tt] { QL_TRACE(("LEX: %s [TOK_CONSTRAINT]\n", yytext)); tokenpos+=yyleng; return TOK_CONSTRAINT; } [Rr][Ee][Ff][Ee][Rr][Ee][Nn][Cc][Ee][Ss] { QL_TRACE(("LEX: %s [TOK_REFERENCES]\n", yytext)); tokenpos+=yyleng; return TOK_REFERENCES; } [Cc][Hh][Ee][Cc][Kk] { QL_TRACE(("LEX: %s [TOK_CHECK]\n", yytext)); tokenpos+=yyleng; return TOK_CHECK; } [Pp][Rr][Ii][Mm][Aa][Rr][Yy] { QL_TRACE(("LEX: %s [TOK_PRIMARY]\n", yytext)); tokenpos+=yyleng; return TOK_PRIMARY; } [Ii][Nn][Ss][Ee][Rr][Tt] { QL_TRACE(("LEX: %s [TOK_INSERT]\n", yytext)); tokenpos+=yyleng; return TOK_INSERT; } [Ss][Ee][Tt] { QL_TRACE(("LEX: %s [TOK_SET]\n", yytext)); tokenpos+=yyleng;printf("set\n"); return TOK_SET; } [Uu][Pp][Dd][Aa][Tt][Ee] { QL_TRACE(("LEX: %s [TOK_UPDATE]\n", yytext)); tokenpos+=yyleng; return TOK_UPDATE; } [Dd][Ee][Ll][Ee][Tt][Ee] { QL_TRACE(("LEX: %s [TOK_DELETE]\n", yytext)); tokenpos+=yyleng; return TOK_DELETE; } [Ii][Nn][Tt][Oo] { QL_TRACE(("LEX: %s [TOK_INTO]\n", yytext)); tokenpos+=yyleng; return TOK_INTO; } [Vv][Aa][Ll][Uu][Ee][Ss] { QL_TRACE(("LEX: %s [TOK_VALUES]\n", yytext)); tokenpos+=yyleng; return TOK_VALUES; } [Dd][Ee][Ff][Aa][Uu][Ll][Tt] { QL_TRACE(("LEX: %s [TOK_DEFAULT]\n", yytext)); tokenpos+=yyleng; return TOK_DEFAULT; } [Ii][Nn] { QL_TRACE(("LEX: %s [TOK_IN]\n", yytext)); tokenpos+=yyleng; return TOK_IN; } [Ll][Ii][Kk][Ee] { QL_TRACE(("LEX: %s [TOK_LIKE]\n", yytext)); tokenpos+=yyleng; return TOK_LIKE; } [Ss][Oo][Mm][Ee] { QL_TRACE(("LEX: %s [TOK_SOME]\n", yytext)); tokenpos+=yyleng; return TOK_SOME; } [Aa][Nn][Yy] { QL_TRACE(("LEX: %s [TOK_ANY]\n", yytext)); tokenpos+=yyleng; return TOK_ANY; } [Ee][Xx][Ii][Ss][Tt][Ss] { QL_TRACE(("LEX: %s [TOK_EXISTS]\n", yytext)); tokenpos+=yyleng; return TOK_EXISTS; } [Bb][Ee][Tt][Ww][Ee][Ee][Nn] { QL_TRACE(("LEX: %s [TOK_BETWEEN]\n", yytext)); tokenpos+=yyleng; return TOK_BETWEEN; } [Gg][Rr][Oo][Uu][Pp] { QL_TRACE(("LEX: %s [TOK_GROUP]\n", yytext)); tokenpos+=yyleng; return TOK_GROUP; } [Ff][Ee][Tt][Cc][Hh] { QL_TRACE(("LEX: %s [TOK_FETCH]\n", yytext)); tokenpos+=yyleng; return TOK_FETCH; } [Oo][Nn][Ll][Yy] { QL_TRACE(("LEX: %s [TOK_ONLY]\n", yytext)); tokenpos+=yyleng; return TOK_ONLY; } [Aa][Ss][Cc] { QL_TRACE(("LEX: %s [TOK_ASC]\n", yytext)); tokenpos+=yyleng; return TOK_ASC; } [Dd][Ee][Ss][Cc] { QL_TRACE(("LEX: %s [TOK_DESC]\n", yytext)); tokenpos+=yyleng; return TOK_DESC; } [Bb][Yy] { QL_TRACE(("LEX: %s [TOK_BY]\n", yytext)); tokenpos+=yyleng; return TOK_BY; } [Rr][Oo][Ww][Ss]? { QL_TRACE(("LEX: %s [TOK_ROWS]\n", yytext)); tokenpos+=yyleng; return TOK_ROW; } [Oo][Rr][Dd][Ee][Rr] { QL_TRACE(("LEX: %s [TOK_ORDER]\n", yytext)); tokenpos+=yyleng; return TOK_ORDER; } [Ff][Ii][Rr][Ss][Tt] { QL_TRACE(("LEX: %s [TOK_FIRST]\n", yytext)); tokenpos+=yyleng; return TOK_FIRST; } [Hh][Aa][Vv][Ii][Nn][Gg] { QL_TRACE(("LEX: %s [TOK_HAVING]\n", yytext)); tokenpos+=yyleng; return TOK_HAVING; } [Uu][Nn][Ii][Oo][Nn] { QL_TRACE(("LEX: %s [TOK_UNION]\n", yytext)); tokenpos+=yyleng; return TOK_UNION; } [Uu][Nn][Ii][Oo][Nn][Aa][Ll][Al] { QL_TRACE(("LEX: %s [TOK_UNIONALL]\n", yytext)); tokenpos+=yyleng; return TOK_UNIONALL; } [Ee][Xx][Cc][Ee][Pp][Tt] { QL_TRACE(("LEX: %s [TOK_EXCEPT]\n", yytext)); tokenpos+=yyleng; return TOK_EXCEPT; } [Ee][Xx][Cc][Ee][Pp][Tt][Aa][Ll][Ll] { QL_TRACE(("LEX: %s [TOK_EXCEPTALL]\n", yytext)); tokenpos+=yyleng; return TOK_EXCEPTALL; } [Ii][Nn][Tt][Ee][Rr][Ss][Ee][Cc][Tt] { QL_TRACE(("LEX: %s [TOK_INTERSECT]\n", yytext)); tokenpos+=yyleng; return TOK_INTERSECT; } [Ii][Nn][Tt][Ee][Rr][Ss][Ee][Cc][Tt][Aa][Ll][Ll] { QL_TRACE(("LEX: %s [TOK_INTERSECTALL]\n", yytext)); tokenpos+=yyleng; return TOK_INTERSECTALL; } [Ww][Ii][Tt][Hh] { QL_TRACE(("LEX: %s [TOK_WITH]\n", yytext)); tokenpos+=yyleng; return TOK_WITH; } {BLANK}+ { tokenpos+=yyleng; /* Ignore blanks */ } [-+]?{POSITIVE_DECIMAL_DIGIT}{DECIMAL_DIGIT}* { QL_TRACE(("LEX: %s [???1]\n", yytext)); yylval.intValue = strtol(yytext, (char**)0, 10); tokenpos+=yyleng; retu... [truncated message content] |