Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Feb 2021 16:39:27 +0000 (UTC)
From:      Mikhail Teterin <mi@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r565518 - in head/lang/siod: . files
Message-ID:  <202102171639.11HGdRbO024992@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mi
Date: Wed Feb 17 16:39:27 2021
New Revision: 565518
URL: https://svnweb.freebsd.org/changeset/ports/565518

Log:
  Add the (optional) support for the Oracle-module. Untested beyond
  "it loads", this is only available on i386 -- because the port of
  databases/oracle8-client is i386 only.
  
  Worse, because the oracle8-client only installs a static library
  -- hacked from Oracle Linux binary -- further (minor) hackery is
  required to link the shared sql_oracle.so with it...
  
  Sponsored by:	United Marsupials

Added:
  head/lang/siod/files/patch-sql_oracle   (contents, props changed)
Modified:
  head/lang/siod/Makefile
  head/lang/siod/files/BSDmakefile.module
  head/lang/siod/pkg-plist

Modified: head/lang/siod/Makefile
==============================================================================
--- head/lang/siod/Makefile	Wed Feb 17 16:35:44 2021	(r565517)
+++ head/lang/siod/Makefile	Wed Feb 17 16:39:27 2021	(r565518)
@@ -19,6 +19,7 @@ USE_LDCONFIG=	${PREFIX}/lib ${PREFIX}/lib/siod
 
 DOS2UNIX_FILES=	sql_oracle.c ss.c
 OPTIONS_DEFINE=	SQL_SYBASE GD NDBM REGEX SS DOCS
+OPTIONS_DEFINE_i386=SQL_ORACLE	# oracle-client port only available for i386
 OPTIONS_DEFAULT=NDBM REGEX SS
 SQL_SYBASE_DESC=Build Sybase (and MS-SQL) client-module (using FreeTDS)
 SS_DESC=	Sockets support - required for any network programs
@@ -38,6 +39,7 @@ SQL_SYBASE_LIB_DEPENDS=	libct.so:databases/freetds	# O
 GD_LIB_DEPENDS=		libgd.so:graphics/gd	# Or ukrainian/gd
 REGEX_LIB_DEPENDS=	libgnuregex.so:devel/libgnuregex
 OPTIONS_SUB=	yes
+SQL_ORACLE_BUILD_DEPENDS=${LOCALBASE}/oracle8-client/lib/libclntsh.a:databases/oracle8-client
 
 .if "${PREFIX}" != "/usr/local"
 post-patch:

Modified: head/lang/siod/files/BSDmakefile.module
==============================================================================
--- head/lang/siod/files/BSDmakefile.module	Wed Feb 17 16:35:44 2021	(r565517)
+++ head/lang/siod/files/BSDmakefile.module	Wed Feb 17 16:39:27 2021	(r565518)
@@ -10,9 +10,14 @@ regex_CFLAGS=	-isystem ${LOCALBASE}/include
 regex_LDADD=	-L${LOCALBASE}/lib -lgnuregex
 sql_sybase_CFLAGS=-isystem ${LOCALBASE}/include
 sql_sybase_LDADD=-L${LOCALBASE}/lib -lct
+sql_oracle_CFLAGS=-isystem ${LOCALBASE}/oracle8-client/rdbms/demo
+sql_oracle_LDADD=-L${LOCALBASE}/oracle8-client/lib -lclntsh
 
 CFLAGS+=	-DHAVE_SYS_PARAM_H ${%%MODULE%%_CFLAGS}
 LDADD=		${%%MODULE%%_LDADD}
+.if "%%MODULE%%" == "sql_oracle"
+LD_FATAL_WARNINGS=no	# Oracle client 8 only provides static library
+.endif
 
 SRCS=	%%MODULE%%.c
 

Added: head/lang/siod/files/patch-sql_oracle
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lang/siod/files/patch-sql_oracle	Wed Feb 17 16:39:27 2021	(r565518)
@@ -0,0 +1,299 @@
+--- sql_oracle.c	2014-03-25 04:10:42.000000000 -0400
++++ sql_oracle.c	2021-02-17 11:09:57.584010000 -0500
+@@ -48,4 +48,5 @@
+ #include <math.h>
+ #include <stdarg.h>
++#include <ociapr.h>
+ 
+ #include "siod.h"
+@@ -68,32 +69,4 @@
+ */
+ 
+-struct lda_def
+-{short v2_rc;
+- unsigned char fill1[10];
+- unsigned short rc;
+- unsigned char fill2[19];
+- unsigned int ose;
+- unsigned char chk;
+- unsigned char sysparm[26];};
+-
+-struct cda_def
+-{short v2_rc;
+- short ft;
+- unsigned long rpc;
+- short peo;
+- unsigned char fc;
+- unsigned char fill1;
+- unsigned short rc;
+- unsigned char wrn;
+- unsigned char flg;
+- unsigned int cn;
+- unsigned char rid[13];
+- unsigned int ose;
+- unsigned char chk;
+- unsigned char sysparm[26];};
+-
+-struct hda_def
+-{char fill[256];};
+-
+ #define ORACLE_ETYPE_CHAR       1
+ #define ORACLE_ITYPE_NUMBER     2
+@@ -130,6 +103,6 @@
+    in an association data structure returned by l_orlon */
+ 
+-static struct lda_def lda;
+-static struct hda_def hda;
++static Lda_Def lda; /* As shown in Oracle8 client demos */
++static ub4 hda[HDA_SIZE/sizeof(ub4)];
+ 
+ static long orlon_ok = 0;
+@@ -164,5 +137,5 @@
+  struct select *selects;};
+ 
+-static char *errmsg(long code)
++static const char *errmsg(long code)
+ {char *ptr;
+  if (errmsg_str0 == NULL)
+@@ -170,20 +143,19 @@
+     memset(errmsg_str0,0,ORACLE_MAX_STRING+1);}
+  oerhms(&lda,code,errmsg_str0,ORACLE_MAX_STRING);
+- if (ptr = strchr(errmsg_str0,'\n')) *ptr = 0;
++ if ((ptr = strchr(errmsg_str0,'\n')) == NULL) *ptr = '\0';
+  return(errmsg_str0);}
+ 
+-char *cda_errmsg(struct cda_def *cur)
++static const char *cda_errmsg(const struct cda_def *cur)
+ {return(errmsg(cur->rc));}
+ 
+-char *lda_errmsg()
++static const char *lda_errmsg()
+ {return(errmsg(lda.rc));}
+ 
+-LISP ferr(LISP obj,char *format, ...)
++static void ferr(LISP obj, const char *format, ...)
+ {va_list restargs;
+  if (errmsg_str1 == NULL)
+-   {errmsg_str1 = (char *) malloc((ORACLE_MAX_STRING*3)+1);
+-    memset(errmsg_str1,0,(ORACLE_MAX_STRING*3)+1);}
++   {errmsg_str1 = malloc((ORACLE_MAX_STRING*3)+1);}
+  va_start(restargs,format);
+- vsprintf(errmsg_str1,format,restargs);
++ vsnprintf(errmsg_str1, ORACLE_MAX_STRING * 3 + 1, format,restargs);
+  va_end(restargs);
+  err(errmsg_str1,obj);}
+@@ -201,5 +173,5 @@
+  return(s);}
+ 
+-struct cda_def *allocate_cursor(void)
++static struct cda_def *allocate_cursor(void)
+ {struct cda_def *cur;
+  unsigned short rc;
+@@ -213,5 +185,5 @@
+  return(cur);}
+ 
+-void free_cursor(struct cda_def *cur)
++static void free_cursor(struct cda_def *cur)
+ {long result;
+  unsigned short rc;
+@@ -221,9 +193,9 @@
+  if (result) ferr(NIL,"oclose: %s",errmsg(rc));}
+ 
+-LISP l_orlon(LISP username,LISP password)
++static LISP l_orlon(LISP username, LISP password)
+ {long retval,flag;
+- char *c_username,*c_password;
+- c_username = get_c_string(username);
+- c_password = NNULLP(password) ? get_c_string(password) : NULL;
++ char *c_username, *c_password; /* Cannot pass const char* to orlon() */
++ c_username = get_string_data(username);
++ c_password = NNULLP(password) ? get_string_data(password) : NULL;
+  if (orlon_ok)
+    /* calling orlon twice will corrupt your process badly. */
+@@ -231,5 +203,5 @@
+  else
+    {flag = no_interrupt(1);
+-    retval = orlon(&lda,&hda,
++    retval = orlon(&lda, (void *)&hda,
+ 		   c_username,strlen(c_username),
+ 		   c_password,(c_password) ? strlen(c_password) : -1,
+@@ -242,5 +214,5 @@
+  return(NIL);}
+ 
+-LISP l_ologof(void)
++static LISP l_ologof(void)
+ {long flag;
+  flag = no_interrupt(1);
+@@ -254,25 +226,25 @@
+  return(NIL);}
+ 
+-void freeloc(void ** x)
++static void freeloc(void ** x)
+ {if (*x)
+    {free(*x);
+     *x = NULL;}}
+ 
+-void release_statement(struct cstatement *c)
++static void release_statement(struct cstatement *c)
+ {long j;
+  if (c->params)
+    {for(j = 1;j <= c->nparams;++j)
+-      freeloc(&c->params[j-1].buf);
+-    freeloc(&c->params);}
++      freeloc((void **)&c->params[j-1].buf);
++    freeloc((void **)&c->params);}
+  if (c->selects)
+    {for(j = 1; j <= c->nselects; ++j)
+-      {freeloc(&c->selects[j-1].colnam);
+-       freeloc(&c->selects[j-1].buf);}
+-    freeloc(&c->selects);}
++      {freeloc((void **)&c->selects[j-1].colnam);
++       freeloc((void **)&c->selects[j-1].buf);}
++    freeloc((void **)&c->selects);}
+  if (c->cursor)
+    free_cursor(c->cursor);
+  c->cursor = NULL;}
+ 
+-void prepare_statement(char *sql_str,struct cstatement *c)
++static void prepare_statement(char *sql_str,struct cstatement *c)
+      /* assumptions:
+ 	nparams gives range of params from :1 to :nparams
+@@ -282,5 +254,5 @@
+  short colnamlen;
+  char colnam[ORACLE_MAX_STRING+1];
+- char *err;
++ const char *err;
+  c->cursor = allocate_cursor();
+  if (osql3(c->cursor,sql_str,-1))
+@@ -348,6 +320,6 @@
+ 	       c->selects[j-1].etype = ORACLE_ETYPE_FLOAT;
+ 	       c->selects[j-1].buflen = sizeof(double);
+-	       c->selects[j-1].buf = (double *) malloc(c->selects[j-1].buflen);
+-	       *((double *)c->selects[j-1].buf) = 0.0;
++	       c->selects[j-1].buf = malloc(c->selects[j-1].buflen);
++	       *((double *)(void *)c->selects[j-1].buf) = 0.0;
+ 	       break;
+ 	     case ORACLE_ETYPE_DATE:
+@@ -355,10 +327,10 @@
+ 	       c->selects[j-1].etype = ORACLE_ETYPE_DATE;
+ 	       c->selects[j-1].buflen = sizeof(struct oracle_date);
+-	       c->selects[j-1].buf = (char *) malloc(c->selects[j-1].buflen);
++	       c->selects[j-1].buf = malloc(c->selects[j-1].buflen);
+ 	       break;
+ 	     default:
+ 	       c->selects[j-1].etype = ORACLE_ETYPE_STRING;
+ 	       c->selects[j-1].buflen =  ORACLE_MAX_STRING;
+-	       c->selects[j-1].buf = (char *) malloc(c->selects[j-1].buflen+1);
++	       c->selects[j-1].buf = malloc(c->selects[j-1].buflen+1);
+ 	       c->selects[j-1].buf[0] = 0;}
+ 	  if (odefin(c->cursor,j,
+@@ -379,5 +351,5 @@
+    c->selects = NULL;}
+ 
+-LISP oracle_sql_prepare(LISP str)
++static LISP oracle_sql_prepare(LISP str)
+ {long iflag;
+  LISP result;
+@@ -385,8 +357,8 @@
+  iflag = no_interrupt(1);
+  result = extcons(sizeof(struct cstatement),extra_tc_statement);
+- c = (struct cstatement *) result->storage_as.string.data;
++ c = (struct cstatement *)(void *)result->storage_as.string.data;
+  c->nparams = 0;
+  c->nselects = -1;
+- prepare_statement(get_c_string(str),c);
++ prepare_statement(get_string_data(str), c);
+  no_interrupt(iflag);
+  return(result);}
+@@ -397,10 +369,10 @@
+      (st->storage_as.string.dim != extra_tc_statement))
+    err("not a statement",st);
+- c = (struct cstatement *)st->storage_as.string.data;
++ c = (struct cstatement *)(void *)st->storage_as.string.data;
+  if (!c->cursor)
+    err("statement has been released",st);
+  return(c);}
+ 
+-LISP oracle_sql_release(LISP s)
++static LISP oracle_sql_release(LISP s)
+ {long iflag;
+  iflag = no_interrupt(1);
+@@ -409,5 +381,5 @@
+  return(NIL);}
+ 
+-LISP oracle_execute(LISP s)
++static LISP oracle_execute(LISP s)
+ {long iflag;
+  struct cstatement *c;
+@@ -419,8 +391,8 @@
+  return(NIL);}
+ 
+-LISP oracle_nselects(LISP s)
++static LISP oracle_nselects(LISP s)
+ {return(flocons((get_cstatement(s))->nselects));}
+ 
+-LISP oracle_select_column_name(LISP s,LISP n)
++static LISP oracle_select_column_name(LISP s,LISP n)
+ {long j;
+  struct cstatement *c;
+@@ -431,5 +403,5 @@
+  return(rintern(c->selects[j].colnam));}
+ 
+-char *oracle_date_to_string(struct oracle_date *d)
++static const char *oracle_date_to_string(const struct oracle_date *d)
+      /* make it look like the string returned by RDB SQL Services */
+ {static char buff[100];
+@@ -440,9 +412,9 @@
+  return(buff);}
+ 
+-LISP oracle_select_column_value(LISP s,LISP n)
++static LISP oracle_select_column_value(LISP s,LISP n)
+ {long j;
+  struct cstatement *c;
+  struct select *sel;
+- char *str;
++ const char *str;
+  j = get_c_long(n);
+  c = get_cstatement(s);
+@@ -454,7 +426,7 @@
+  switch(sel->etype)
+    {case ORACLE_ETYPE_FLOAT:
+-      return(flocons(*((double *)sel->buf)));
++      return(flocons(*((double *)(void *)sel->buf)));
+     case ORACLE_ETYPE_DATE:
+-      str = oracle_date_to_string(sel->buf);
++      str = oracle_date_to_string((void *)sel->buf);
+       return(strcons(strlen(str),str));
+     case ORACLE_ETYPE_STRING:
+@@ -463,5 +435,5 @@
+       return(errswitch());}}
+ 
+-LISP oracle_fetch(LISP s)
++static LISP oracle_fetch(LISP s)
+ {long iflag;
+  struct cstatement *c;
+@@ -478,5 +450,5 @@
+ static void extra_gc_free(LISP ptr)
+ {struct cstatement *c;
+- c = (struct cstatement *) ptr->storage_as.string.data;
++ c = (struct cstatement *)(void *)ptr->storage_as.string.data;
+  release_statement(c);
+  free(c);}
+@@ -487,8 +459,8 @@
+  switch(ptr->storage_as.string.dim)
+    {case extra_tc_statement:
+-      c = (struct cstatement *) ptr->storage_as.string.data;
++      c = (struct cstatement *)(void *)ptr->storage_as.string.data;
+       if (c->cursor)
+ 	sprintf(buff,"#{SQL STATEMENT %p cursor %d}",
+-		c,c->cursor->cn);
++		c,c->cursor->rcs3 /* Is rcs3 really the cursor ID? XXX */);
+       else
+ 	sprintf(buff,"#{SQL STATEMENT %p released}",c);
+@@ -498,4 +470,6 @@
+       errswitch();}}
+ 
++void init_sql_oracle(void); /* Our sole exported symbol */
++
+ void init_sql_oracle(void)
+ {long j;

Modified: head/lang/siod/pkg-plist
==============================================================================
--- head/lang/siod/pkg-plist	Wed Feb 17 16:35:44 2021	(r565517)
+++ head/lang/siod/pkg-plist	Wed Feb 17 16:39:27 2021	(r565518)
@@ -37,6 +37,7 @@ lib/siod/sql_msql.scm
 %%NDBM%%lib/siod/ndbm.so
 %%SS%%lib/siod/ss.so
 lib/siod/tar.so
+%%SQL_ORACLE%%lib/siod/sql_oracle.so
 %%SQL_SYBASE%%lib/siod/sql_sybase.so
 %%REGEX%%lib/siod/regex.so
 lib/siod/parser_pratt.so



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102171639.11HGdRbO024992>