[PATCH] VMS build update

"Craig A. Berry" <[email protected]> Fri, 12 Jul 2013 22:05:40 -0500
Newsgroups gmane.comp.db.unixodbc.devel
Message-ID <[email protected]>
There are two patches attached against current SVN.  It looks like it's only been eleven years since my last patch, but why wait? :-)

The one called vmsupdate.patch does some touch-ups to vmsbuild.com to make it find things that have moved, to add some missing configuration entries, and to play nicer on the ODS-5 filesystem, which can preserve case, have multiple dots in filenames, etc.  The patch also adds some missing symbol names to the linker options file used to build shareable images (dynamic libraries).

The other patch (assorted_code_nits.patch) fixes some miscellaneous things that the VMS C compiler complained about:

DriverManager/SQLConnect.c

It wasn't including sys/time.h, leaving time_t an unknown type.

DriverManager/SQLDriverConnect.c

There were a lot of signedness mismatches due to the fact that SQLCHAR is typedef'd to unsigned char but gets used in various places that expect char.

DriverManager/SQLDriverConnectW.c

More signedness mismatches.

DriverManager/__info.c

Similar signedness mismatches, notably in calls to ansi_to_unicode_copy, the second argument of which is pointer to char, but there were many casts coercing it to pointer to SQLCHAR.

The call to gettimeofday did not match the standard prototype.  The standard at <http://pubs.opengroup.org/onlinepubs/009695399/functions/gettimeofday.html> says the second argument to gettimeofday() must be a pointer to void and must be null, so I made it do what the standard says.

exe/iusql.c

CloseDatabase() was missing a prototype, so I added one.

I think that's it.  Let me know if there are any questions or problems with the patches.
________________________________________
Craig A. Berry
mailto:[email protected]

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

_______________________________________________
unixODBC-dev mailing list
[email protected]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev
assorted_code_nits.patch (application/octet-stream, 7.5 KB)
--- DriverManager/SQLConnect.c;-0	2013-04-11 21:15:32 -0500
+++ DriverManager/SQLConnect.c	2013-04-14 18:17:15 -0500
@@ -587,6 +587,11 @@
  **********************************************************************/
 
 #include <config.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#elif defined(HAVE_TIME_H)
+#include <time.h>
+#endif
 #include "drivermanager.h"
 
 static char const rcsid[]= "$RCSfile: SQLConnect.c,v $ $Revision: 1.66 $";
--- DriverManager/SQLDriverConnect.c;-0	2013-04-07 16:38:01 -0500
+++ DriverManager/SQLDriverConnect.c	2013-04-14 18:15:27 -0500
@@ -845,7 +845,7 @@ SQLRETURN SQLDriverConnect(
 			else 
 			{
 				prefix = returned_dsn;
-				target = (SQLCHAR*)strchr( returned_dsn, '=' );
+				target = (SQLCHAR*)strchr( (char*)returned_dsn, '=' );
 				if ( target ) 
 				{
 					*target = '\0';
@@ -1059,7 +1059,7 @@ SQLRETURN SQLDriverConnect(
                    				sprintf( str1, "%s=%s", cp -> keyword, cp -> attribute );
 							}
 
-                            if ( strlen( conn_str_in ) + strlen( str1 ) < conn_str_out_max ) {
+                            if ( strlen( (char*)conn_str_in ) + strlen( str1 ) < conn_str_out_max ) {
                 			    strcat((char*) conn_str_in, str1 );
                             }
                             else {
@@ -1114,7 +1114,7 @@ SQLRETURN SQLDriverConnect(
 							{
                             	sprintf( str1, "%s=%s", cp -> keyword, cp -> attribute );
 							}
-                            if ( strlen( conn_str_in ) + strlen( str1 ) < conn_str_out_max ) {
+                            if ( strlen( (char*)conn_str_in ) + strlen( str1 ) < conn_str_out_max ) {
                                 strcat((char*) conn_str_in, str1 );
                             }
                             else {
--- DriverManager/SQLDriverConnectW.c;-0	2013-04-07 16:38:01 -0500
+++ DriverManager/SQLDriverConnectW.c	2013-04-16 22:17:11 -0500
@@ -423,24 +423,24 @@ SQLRETURN SQLDriverConnectW(
 			else 
 			{
 				prefix = returned_dsn;
-				target = strchr( returned_dsn, '=' );
+				target = (SQLCHAR*)strchr( (char*)returned_dsn, '=' );
 				if ( target ) 
 				{
 					*target = '\0';
 					target ++;
-        			__append_pair( &con_struct, prefix, target );
+        			__append_pair( &con_struct, (char*)prefix, (char*)target );
 				}
 				else {
-        			__append_pair( &con_struct, "DSN", returned_dsn );
+        			__append_pair( &con_struct, "DSN", (char*)returned_dsn );
 				}
 			}
 
 			/*
 			 * regenerate to pass to driver
 			 */
-			__generate_connection_string( &con_struct, local_conn_str_in, sizeof( local_conn_str_in ));
+			__generate_connection_string( &con_struct, (char*)local_conn_str_in, sizeof( local_conn_str_in ));
         	len_conn_str_in = strlen((char*) local_conn_str_in );
-			ansi_to_unicode_copy( local_conn_string, local_conn_str_in, len_conn_str_in, connection );
+			ansi_to_unicode_copy( local_conn_string, (char*)local_conn_str_in, len_conn_str_in, connection );
 			conn_str_in = local_conn_string;
 		}
 	}
--- DriverManager/__info.c;-0	2013-04-07 16:38:01 -0500
+++ DriverManager/__info.c	2013-04-14 20:56:25 -0500
@@ -3856,7 +3856,7 @@ void __post_internal_error_ex( EHEAD *er
     e1 -> native_error = native_error;
     e2 -> native_error = native_error;
     ansi_to_unicode_copy(e1 -> sqlstate,
-                         sqlstate, SQL_NTS, __get_connection( error_header ));
+                         (char*)sqlstate, SQL_NTS, __get_connection( error_header ));
     wide_strcpy( e2 -> sqlstate, e1 -> sqlstate );
 
     e1 -> msg = ansi_to_unicode_alloc( msg, SQL_NTS, __get_connection( error_header ) );
@@ -3897,26 +3897,26 @@ void __post_internal_error_ex( EHEAD *er
     e2 -> diag_row_number = 0;
 
     if ( class_origin == SUBCLASS_ODBC )
-    	ansi_to_unicode_copy( e1 -> diag_class_origin, (SQLCHAR*) "ODBC 3.0",
+    	ansi_to_unicode_copy( e1 -> diag_class_origin, (char*) "ODBC 3.0",
 			      SQL_NTS, __get_connection( error_header ) );
     else
-    	ansi_to_unicode_copy( e1 -> diag_class_origin, (SQLCHAR*) "ISO 9075",
+    	ansi_to_unicode_copy( e1 -> diag_class_origin, (char*) "ISO 9075",
 			      SQL_NTS, __get_connection( error_header ) );
     wide_strcpy( e2 -> diag_class_origin, e1 -> diag_class_origin );
 
     if ( subclass_origin == SUBCLASS_ODBC )
-    	ansi_to_unicode_copy( e1 -> diag_subclass_origin, (SQLCHAR*) "ODBC 3.0",
+    	ansi_to_unicode_copy( e1 -> diag_subclass_origin, (char*) "ODBC 3.0",
 			      SQL_NTS, __get_connection( error_header ) );
     else
-    	ansi_to_unicode_copy( e1 -> diag_subclass_origin, (SQLCHAR*) "ISO 9075",
+    	ansi_to_unicode_copy( e1 -> diag_subclass_origin, (char*) "ISO 9075",
 			      SQL_NTS, __get_connection( error_header ) );
     wide_strcpy( e2 -> diag_subclass_origin, e1 -> diag_subclass_origin );
 
-    ansi_to_unicode_copy( e1 -> diag_connection_name, (SQLCHAR*) "", SQL_NTS,
+    ansi_to_unicode_copy( e1 -> diag_connection_name, (char*) "", SQL_NTS,
 			  __get_connection( error_header ) );
     wide_strcpy( e2 -> diag_connection_name, e1 -> diag_connection_name );
 
-    ansi_to_unicode_copy( e1 -> diag_server_name, (SQLCHAR*) "", SQL_NTS,
+    ansi_to_unicode_copy( e1 -> diag_server_name, (char*) "", SQL_NTS,
 			  __get_connection( error_header ) );
     wide_strcpy( e2 -> diag_server_name, e1 -> diag_server_name );
 
@@ -3948,7 +3948,7 @@ void __post_internal_error_ex_w( EHEAD *
      * add our prefix
      */
 
-    ansi_to_unicode_copy(msg, (SQLCHAR*) ERROR_PREFIX, SQL_NTS,
+    ansi_to_unicode_copy(msg, (char*) ERROR_PREFIX, SQL_NTS,
 			 __get_connection( error_header ));
     wide_strcat( msg, message_text );
 
@@ -3993,18 +3993,18 @@ void __post_internal_error_ex_w( EHEAD *
     e2 -> diag_row_number = 0;
 
     if ( class_origin == SUBCLASS_ODBC )
-        ansi_to_unicode_copy( e1 -> diag_class_origin, (SQLCHAR*) "ODBC 3.0",
+        ansi_to_unicode_copy( e1 -> diag_class_origin, (char*) "ODBC 3.0",
 							  SQL_NTS, __get_connection( error_header ) );
     else
-        ansi_to_unicode_copy( e1 -> diag_class_origin, (SQLCHAR*) "ISO 9075",
+        ansi_to_unicode_copy( e1 -> diag_class_origin, (char*) "ISO 9075",
 							  SQL_NTS, __get_connection( error_header ) );
     wide_strcpy( e2 -> diag_class_origin, e1 -> diag_class_origin );
 
     if ( subclass_origin == SUBCLASS_ODBC )
-        ansi_to_unicode_copy( e1 -> diag_subclass_origin, (SQLCHAR*) "ODBC 3.0",
+        ansi_to_unicode_copy( e1 -> diag_subclass_origin, (char*) "ODBC 3.0",
 							  SQL_NTS, __get_connection( error_header ) );
     else
-        ansi_to_unicode_copy( e1 ->diag_subclass_origin, (SQLCHAR*) "ISO 9075",
+        ansi_to_unicode_copy( e1 ->diag_subclass_origin, (char*) "ISO 9075",
 							  SQL_NTS, __get_connection( error_header ) );
     wide_strcpy( e2 -> diag_subclass_origin, e1 -> diag_subclass_origin );
 
@@ -5616,9 +5616,9 @@ void dm_log_write( char *function_name, 
 #if defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_SYS_TIME_H )
 		{
 			struct timeval tv;
-			struct timezone tz;
+			void* tz = NULL;
 
-			gettimeofday( &tv, &tz );
+			gettimeofday( &tv, tz );
 
 			sprintf( tstamp_str, "[%ld.%06ld]", tv.tv_sec, tv.tv_usec );
 		}
--- exe/iusql.c;-0	2013-04-07 16:37:57 -0500
+++ exe/iusql.c	2013-04-14 17:15:13 -0500
@@ -27,6 +27,7 @@
 #endif
 
 static int OpenDatabase( SQLHENV *phEnv, SQLHDBC *phDbc, char *szDSN, char *szUID, char *szPWD );
+static int CloseDatabase( SQLHENV hEnv, SQLHDBC hDbc );
 static int ExecuteSQL( SQLHDBC hDbc, char *szSQL, char cDelimiter, int bColumnNames, int bHTMLTable );
 static int ExecuteHelp( SQLHDBC hDbc, char *szSQL, char cDelimiter, int bColumnNames, int bHTMLTable );
vmsupdate.patch (application/octet-stream, 5.7 KB)
--- README.VMS;-0	2013-04-07 16:38:07 -0500
+++ README.VMS	2013-07-12 16:09:22 -0500
@@ -1,8 +1,8 @@
-Building unixODBC on OpenVMS (Alpha only)
+Building unixODBC on OpenVMS (non-VAX only)
 =========================================
 
 Here's an initial go at building unixODBC on OpenVMS, at present this will 
-only run on alpha but if anyone requires use of this on VAX drop me an email
+only run on alpha and itanium, but if anyone requires use of this on VAX drop me an email
 ([email protected]) and I'll do the necessary transfer vector macro's to export 
 the required symbols from the two shared objects (ODBC.EXE and ODBCINST.EXE).
 
@@ -135,4 +135,4 @@ ConnSettings        =
 
 Jason
 
-last updated 7-NOV-2002 by Craig A. Berry -- [email protected]
+last updated 12-Jul-2013 by Craig A. Berry -- [email protected]
--- vmsbuild.com;-0	2013-04-07 16:38:07 -0500
+++ vmsbuild.com	2013-04-20 12:31:04 -0500
@@ -10,7 +10,7 @@ $ define/translation=concealed ODBCSRC "
 $!
 $ if p1 .eqs. "" then $goto ERR_NOPARAMS
 $!
-$ includes = "ODBCSRC:[include],ODBCSRC:[extras],ODBCSRC:[libltdl]"
+$ includes = "ODBCSRC:[include],ODBCSRC:[extras],""/ODBCSRC/libltdl"""
 $! /first_include requires CC 6.4 or later but avoids impossibly long /define qualifier
 $ CFLAGS="/names=as_is/prefix=all/include=(" + includes + ")/first_include=(ODBCSRC:[include]vmsconfig.h)
 $ LFLAGS="/nodebug/notrace"
@@ -39,14 +39,20 @@ $   if f$search("ODBCSRC:[vms]libodbcins
 $   if f$search("ODBCSRC:[vms]libodbc.olb") .eqs. "" then library/create ODBCSRC:[vms]libodbc.olb
 $   if f$search("ODBCSRC:[vms]libodbcpsql.olb") .eqs. "" then library/create ODBCSRC:[vms]libodbcpsql.olb
 $   call create_vmsconfig_h
-$   call compile "ODBCSRC:[extras]" "*.C" "ODBCSRC:[vms]libodbcinst.olb" "ODBCSRC:[vms]libodbc.olb"
-$   call compile "ODBCSRC:[ini]" "*.C" "ODBCSRC:[vms]libodbcinst.olb" "ODBCSRC:[vms]libodbc.olb"
-$   call compile "ODBCSRC:[log]" "*.C" "ODBCSRC:[vms]libodbcinst.olb"
-$   call compile "ODBCSRC:[lst]" "*.C" "ODBCSRC:[vms]libodbcinst.olb" "ODBCSRC:[vms]libodbc.olb"
-$   call compile "ODBCSRC:[odbcinst]" "*.C" "ODBCSRC:[vms]libodbcinst.olb"
-$   call compile "ODBCSRC:[drivermanager]" "*.C" "ODBCSRC:[vms]libodbc.olb"
-$   call compile "ODBCSRC:[exe]" "*.C"
-$   call compile "ODBCSRC:[drivers.postgresql]" "*.C" "ODBCSRC:[vms]libodbcpsql.olb"
+$   call compile "ODBCSRC:[extras]" "*.c" "ODBCSRC:[vms]libodbcinst.olb" "ODBCSRC:[vms]libodbc.olb"
+$   call compile "ODBCSRC:[ini]" "*.c" "ODBCSRC:[vms]libodbcinst.olb" "ODBCSRC:[vms]libodbc.olb"
+$   call compile "ODBCSRC:[log]" "*.c" "ODBCSRC:[vms]libodbcinst.olb"
+$   call compile "ODBCSRC:[lst]" "*.c" "ODBCSRC:[vms]libodbcinst.olb" "ODBCSRC:[vms]libodbc.olb"
+$   call compile "ODBCSRC:[odbcinst]" "*.c" "ODBCSRC:[vms]libodbcinst.olb"
+$   call compile "ODBCSRC:[drivermanager]" "*.c" "ODBCSRC:[vms]libodbc.olb"
+$   call compile "ODBCSRC:[exe]" "*.c"
+$   if f$getdvi("ODBCSRC:", "ACPTYPE") .eqs. "F11V5"
+$   then
+$       set process/parse=extended
+$       call compile "ODBCSRC:[Drivers.Postgre7^.1]" "*.c" "ODBCSRC:[vms]libodbcpsql.olb"
+$   else
+$       call compile "ODBCSRC:[Drivers.Postgre7_1]" "*.c" "ODBCSRC:[vms]libodbcpsql.olb"
+$   endif
 $   set default 'cwd'
 $!
 $ endif
@@ -167,7 +173,7 @@ $   if f$edit(filename,"UPCASE") .eqs. "
 $   object = F$SEARCH ("''filename'.OBJ;*",2)
 $   if object .eqs. ""
 $   then
-$      say "cc" + CFLAGS + " ''filename'.C"
+$      say "cc" + CFLAGS + " ''filename'.c"
 $      on warning then continue
 $      cc 'CFLAGS' 'filename'
 $!     keep module names upper case to avoid insanity on ODS-5 volumes
@@ -199,8 +205,15 @@ $ write vmsconfig "#if __VMS_VER >= 7000
 $ write vmsconfig "#define HAVE_STRCASECMP"
 $ write vmsconfig "#define HAVE_STRNCASECMP"
 $ write vmsconfig "#define HAVE_STDARG_H"
+$ write vmsconfig "#define HAVE_STDLIB_H"
+$ write vmsconfig "#define HAVE_STRING_H"
+$ write vmsconfig "#define HAVE_STRINGS_H"
+$ write vmsconfig "#define HAVE_DTIME"
+$ write vmsconfig "#define HAVE_SYS_TIME_H"
+$ write vmsconfig "#define HAVE_GETTIMEOFDAY"
+$ write vmsconfig "#define HAVE_UNISTD_H"
 $ write vmsconfig "#endif"
-$ write vmsconfig "#define SIZEOF_LONG_INT 8"
+$ write vmsconfig "#define SIZEOF_LONG_INT 4"
 $ write vmsconfig "#define UNIXODBC_SOURCE"
 $ write vmsconfig "#define readonly __readonly"
 $ write vmsconfig "#define DEFLIB_PATH ""ODBC_LIBDIR:[LIB]"""
@@ -216,6 +229,7 @@ $ write vmsconfig "#define SYSTEM_FILE_P
 $ write vmsconfig "char* getvmsenv (char* symbol);"
 $ close vmsconfig
 $!
+$ if f$search("ODBCSRC:[include]unixodbc_conf.h") .nes. "" then delete/noconfirm/nolog ODBCSRC:[include]unixodbc_conf.h;*
 $ open/write unixodbcconfig ODBCSRC:[include]unixodbc_conf.h
 $ write unixodbcconfig "/* auto-generated definitions for VMS port */
 $ write unixodbcconfig "#ifndef HAVE_PWD_H"
@@ -225,6 +239,10 @@ $ write unixodbcconfig "#ifndef SIZEOF_L
 $ write unixodbcconfig " #define SIZEOF_LONG_INT 8"
 $ write unixodbcconfig "#endif"
 $ close unixodbcconfig
+$ if f$search("ODBCSRC:[include]config.h") .nes. "" then delete/noconfirm/nolog ODBCSRC:[include]config.h;*
+$ open/write config_h ODBCSRC:[include]config.h
+$ write config_h "/* The real stuff is in vmsconfig.h */
+$ close config_h
 $ exit
 $ endsubroutine ! create_vmsconfig_h
 $!
--- vms/odbcinst_axp.opt;-0	2013-04-07 16:38:07 -0500
+++ vms/odbcinst_axp.opt	2013-04-19 16:05:19 -0500
@@ -1,5 +1,7 @@
 CASE_SENSITIVE=YES
-SYMBOL_VECTOR = (SQLManageDataSources=PROCEDURE,-
+SYMBOL_VECTOR = (-
+_SQLDriverConnectPrompt=PROCEDURE,-
+SQLManageDataSources=PROCEDURE,-
 SQLCreateDataSource=PROCEDURE,-
 SQLGetTranslator=PROCEDURE,-
 SQLInstallDriverManager=PROCEDURE,-
@@ -23,4 +25,5 @@ SQLInstallDriverEx=PROCEDURE,-
 SQLInstallTranslatorEx=PROCEDURE,-
 SQLGetConfigMode=PROCEDURE,-
 SQLSetConfigMode=PROCEDURE,-
+odbcinst_system_file_name=PROCEDURE,-
 odbcinst_system_file_path=PROCEDURE)