From: Marco van Wieringen Date: Wed, 3 Mar 2010 17:37:37 +0000 (+0100) Subject: Lets generate ingres code by calling esqlcc and not esqlc as we want c++ code. X-Git-Tag: Release-5.0.2~176^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=16f1443c221735808d1b2a9bbf99f5918b06f582;p=bacula%2Fbacula Lets generate ingres code by calling esqlcc and not esqlc as we want c++ code. Replaced some strncpy by bstrncpy calls. Add dependency in Makefile of generated code on it source file. --- diff --git a/bacula/src/cats/Makefile.in b/bacula/src/cats/Makefile.in index 1fa9d510f5..76f8a61978 100644 --- a/bacula/src/cats/Makefile.in +++ b/bacula/src/cats/Makefile.in @@ -56,10 +56,15 @@ all: Makefile libbacsql$(DEFAULT_ARCHIVE_TYPE) @echo "==== Make of sqllib is good ====" @echo " " -# SRE: embeddedSQL precompiler run -esql: - $(II_SYSTEM)/ingres/bin/esqlc -omyingres.c myingres.sc - $(II_SYSTEM)/ingres/bin/esqlc -omyingres.h myingres.sh +myingres.c: myingres.sc + @echo "Generating $@ from $<" + $(NO_ECHO)$(II_SYSTEM)/ingres/bin/esqlcc -extension=c $< + +myingres.h: myingres.sh + @echo "Generating $@ from $<" + $(NO_ECHO)$(II_SYSTEM)/ingres/bin/esqlcc -extension=h $< + +esql: myingres.c myingres.h libbacsql.a: $(LIBBACSQL_OBJS) @echo "Making $@ ..." diff --git a/bacula/src/cats/myingres.c b/bacula/src/cats/myingres.c index 72ff6ccfbb..53cfd64d80 100644 --- a/bacula/src/cats/myingres.c +++ b/bacula/src/cats/myingres.c @@ -1,8 +1,10 @@ #include "bacula.h" /* # line 3 "myingres.sc" */ #ifdef HAVE_INGRES +#include +#include #include - extern IISQLCA sqlca; /* SQL Communications Area */ +extern IISQLCA sqlca; /* SQL Communications Area */ #include #include #include @@ -28,7 +30,7 @@ short INGgetCols(const char *stmt) memset(sqlda, 0, (IISQDA_HEAD_SIZE + (number * IISQDA_VAR_SIZE))); sqlda->sqln = number; stmtd = (char*)malloc(strlen(stmt)+1); - strncpy(stmtd,stmt,strlen(stmt)+1); + bstrncpy(stmtd,stmt,strlen(stmt)+1); /* # line 38 "myingres.sc" */ /* prepare */ { IIsqInit(&sqlca); @@ -69,7 +71,7 @@ IISQLDA *INGgetDescriptor(short numCols, const char *stmt) memset(sqlda, 0, (IISQDA_HEAD_SIZE + (numCols * IISQDA_VAR_SIZE))); sqlda->sqln = numCols; stmtd = (char *)malloc(strlen(stmt)+1); - strncpy(stmtd,stmt,strlen(stmt)+1); + bstrncpy(stmtd,stmt,strlen(stmt)+1); /* # line 74 "myingres.sc" */ /* prepare */ { IIsqInit(&sqlca); @@ -150,7 +152,7 @@ INGresult *INGgetINGresult(IISQLDA *sqlda) memset(result->fields, 0, sizeof(INGRES_FIELD) * result->num_fields); for (i = 0; i < result->num_fields; ++i) { memset(result->fields[i].name, 0, 34); - strncpy(result->fields[i].name, sqlda->sqlvar[i].sqlname.sqlnamec, sqlda->sqlvar[i].sqlname.sqlnamel); + bstrncpy(result->fields[i].name, sqlda->sqlvar[i].sqlname.sqlnamec, sqlda->sqlvar[i].sqlname.sqlnamel); result->fields[i].max_length = INGgetTypeSize(&sqlda->sqlvar[i]); result->fields[i].type = abs(sqlda->sqlvar[i].sqltype); result->fields[i].flags = (abs(sqlda->sqlvar[i].sqltype)<0) ? 1 : 0; @@ -283,9 +285,9 @@ int INGfetchAll(const char *stmt, INGresult *ing_res) /* # line 309 "myingres.sc" */ /* open */ { IIsqInit(&sqlca); - IIcsOpen((char *)"c2",17878,21884); + IIcsOpen((char *)"c2",4824,17405); IIwritio(0,(short *)0,1,32,0,(char *)"s2"); - IIcsQuery((char *)"c2",17878,21884); + IIcsQuery((char *)"c2",4824,17405); } /* # line 310 "myingres.sc" */ /* host code */ if ((check = INGcheck()) < 0) { @@ -296,7 +298,7 @@ int INGfetchAll(const char *stmt, INGresult *ing_res) /* # line 316 "myingres.sc" */ /* fetch */ { IIsqInit(&sqlca); - if (IIcsRetScroll((char *)"c2",17878,21884,-1,-1) != 0) { + if (IIcsRetScroll((char *)"c2",4824,17405,-1,-1) != 0) { IIcsDaGet(0,desc); IIcsERetrieve(); } /* IIcsRetrieve */ @@ -306,7 +308,7 @@ int INGfetchAll(const char *stmt, INGresult *ing_res) /* # line 318 "myingres.sc" */ /* close */ { IIsqInit(&sqlca); - IIcsClose((char *)"c2",17878,21884); + IIcsClose((char *)"c2",4824,17405); } /* # line 319 "myingres.sc" */ /* host code */ return check; @@ -330,7 +332,7 @@ int INGfetchAll(const char *stmt, INGresult *ing_res) /* # line 340 "myingres.sc" */ /* close */ { IIsqInit(&sqlca); - IIcsClose((char *)"c2",17878,21884); + IIcsClose((char *)"c2",4824,17405); } /* # line 342 "myingres.sc" */ /* host code */ ing_res->status = ING_COMMAND_OK; @@ -404,7 +406,7 @@ int INGexec(INGconn *conn, const char *query) /* # line 420 "myingres.sc" */ stmt = (char *)malloc(strlen(query)+1); - strncpy(stmt,query,strlen(query)+1); + bstrncpy(stmt,query,strlen(query)+1); rowcount = -1; /* # line 426 "myingres.sc" */ /* execute */ { @@ -506,10 +508,10 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd) IILQisInqSqlio((short *)0,1,30,sizeof(sess_id),&sess_id,11); } /* # line 508 "myingres.sc" */ /* host code */ - strncpy(dbconn->dbname, ingdbname, sizeof(dbconn->dbname)); - strncpy(dbconn->user, ingdbuser, sizeof(dbconn->user)); - strncpy(dbconn->password, ingdbpasw, sizeof(dbconn->password)); - strncpy(dbconn->connection_name, conn_name, sizeof(dbconn->connection_name)); + bstrncpy(dbconn->dbname, ingdbname, sizeof(dbconn->dbname)); + bstrncpy(dbconn->user, ingdbuser, sizeof(dbconn->user)); + bstrncpy(dbconn->password, ingdbpasw, sizeof(dbconn->password)); + bstrncpy(dbconn->connection_name, conn_name, sizeof(dbconn->connection_name)); dbconn->session_id = sess_id; dbconn->msg = (char*)malloc(257); memset(dbconn->msg, 0, 257); diff --git a/bacula/src/cats/myingres.h b/bacula/src/cats/myingres.h index e2b8871be5..dc204c83ca 100644 --- a/bacula/src/cats/myingres.h +++ b/bacula/src/cats/myingres.h @@ -1,15 +1,9 @@ -<<<<<<< HEAD:bacula/src/cats/myingres.h -# include "/opt/Ingres/IngresII/ingres/files/eqdefc.h" #ifndef _MYINGRES_SH #define _MYINGRES_SH -# include "/opt/Ingres/IngresII/ingres/files/eqsqlda.h" -======= -#ifndef _MYINGRES_SH -#define _MYINGRES_SH -#include +#include +#include #include /* # line 6 "myingres.sh" */ /* host code */ ->>>>>>> 289e3c7... Added patch from Stefan Reddig -- fixed date types, errmsg:bacula/src/cats/myingres.h /* ---typedefs--- */ typedef struct ing_field { char name[34]; diff --git a/bacula/src/cats/myingres.sc b/bacula/src/cats/myingres.sc index dbf784d97b..9f7f380ec0 100644 --- a/bacula/src/cats/myingres.sc +++ b/bacula/src/cats/myingres.sc @@ -33,7 +33,7 @@ short INGgetCols(const char *stmt) sqlda->sqln = number; stmtd = (char*)malloc(strlen(stmt)+1); - strncpy(stmtd,stmt,strlen(stmt)+1); + bstrncpy(stmtd,stmt,strlen(stmt)+1); EXEC SQL PREPARE s1 from :stmtd; if (INGcheck() < 0) { @@ -69,7 +69,7 @@ IISQLDA *INGgetDescriptor(short numCols, const char *stmt) sqlda->sqln = numCols; stmtd = (char *)malloc(strlen(stmt)+1); - strncpy(stmtd,stmt,strlen(stmt)+1); + bstrncpy(stmtd,stmt,strlen(stmt)+1); EXEC SQL PREPARE s2 INTO :sqlda FROM :stmtd; @@ -159,7 +159,7 @@ INGresult *INGgetINGresult(IISQLDA *sqlda) for (i = 0; i < result->num_fields; ++i) { memset(result->fields[i].name, 0, 34); - strncpy(result->fields[i].name, sqlda->sqlvar[i].sqlname.sqlnamec, sqlda->sqlvar[i].sqlname.sqlnamel); + bstrncpy(result->fields[i].name, sqlda->sqlvar[i].sqlname.sqlnamec, sqlda->sqlvar[i].sqlname.sqlnamel); result->fields[i].max_length = INGgetTypeSize(&sqlda->sqlvar[i]); result->fields[i].type = abs(sqlda->sqlvar[i].sqltype); result->fields[i].flags = (abs(sqlda->sqlvar[i].sqltype)<0) ? 1 : 0; @@ -420,7 +420,7 @@ int INGexec(INGconn *conn, const char *query) EXEC SQL END DECLARE SECTION; stmt = (char *)malloc(strlen(query)+1); - strncpy(stmt,query,strlen(query)+1); + bstrncpy(stmt,query,strlen(query)+1); rowcount = -1; EXEC SQL EXECUTE IMMEDIATE :stmt; @@ -505,10 +505,10 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd) EXEC SQL INQUIRE_SQL(:conn_name = connection_name); EXEC SQL INQUIRE_SQL(:sess_id = session); - strncpy(dbconn->dbname, ingdbname, sizeof(dbconn->dbname)); - strncpy(dbconn->user, ingdbuser, sizeof(dbconn->user)); - strncpy(dbconn->password, ingdbpasw, sizeof(dbconn->password)); - strncpy(dbconn->connection_name, conn_name, sizeof(dbconn->connection_name)); + bstrncpy(dbconn->dbname, ingdbname, sizeof(dbconn->dbname)); + bstrncpy(dbconn->user, ingdbuser, sizeof(dbconn->user)); + bstrncpy(dbconn->password, ingdbpasw, sizeof(dbconn->password)); + bstrncpy(dbconn->connection_name, conn_name, sizeof(dbconn->connection_name)); dbconn->session_id = sess_id; dbconn->msg = (char*)malloc(257); memset(dbconn->msg, 0, 257);