Exemplo n.º 1
0
BOOL INSTAPI
SQLGetAvailableDrivers (LPCSTR lpszInfFile, LPSTR lpszBuf, WORD cbBufMax,
    WORD * pcbBufOut)
{
  BOOL retcode = FALSE;
  WORD lenBufOut;

  /* Get from the user files */
  CLEAR_ERROR ();

  switch (configMode)
    {
    case ODBC_BOTH_DSN:
    case ODBC_USER_DSN:
      wSystemDSN = USERDSN_ONLY;
      break;

    case ODBC_SYSTEM_DSN:
      wSystemDSN = SYSTEMDSN_ONLY;
      break;
    }

  retcode =
      GetAvailableDrivers (lpszInfFile, lpszBuf, cbBufMax, &lenBufOut, FALSE);

  if (pcbBufOut)
    *pcbBufOut = lenBufOut;

  wSystemDSN = USERDSN_ONLY;
  configMode = ODBC_BOTH_DSN;
  return retcode;
}
Exemplo n.º 2
0
BOOL INSTAPI
SQLGetTranslator (HWND hwnd,
    LPSTR lpszName,
    WORD cbNameMax,
    WORD * pcbNameOut,
    LPSTR lpszPath, WORD cbPathMax, WORD * pcbPathOut, DWORD * pvOption)
{
  BOOL retcode = FALSE;

  /* Check input parameters */
  CLEAR_ERROR ();
  if (!hwnd)
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_HWND);
      goto quit;
    }

  if (!lpszName || !lpszPath || cbNameMax < 1 || cbPathMax < 1)
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_BUFF_LEN);
      goto quit;
    }

  retcode = GetTranslator (hwnd, lpszName, cbNameMax, pcbNameOut, lpszPath,
      cbPathMax, pcbPathOut, pvOption);

quit:
  return retcode;
}
Exemplo n.º 3
0
BOOL INSTAPI
SQLWriteFileDSN (LPCSTR lpszFileName, LPCSTR lpszAppName, LPCSTR lpszKeyName,
    LPSTR lpszString)
{
  BOOL retcode = FALSE;
  char filename[1024];

  /* Check input parameters */
  CLEAR_ERROR ();

  /* Is a file is specified */
  if (lpszFileName)
    {
      _iodbcdm_getdsnfile (lpszFileName, filename, sizeof (filename));
      retcode =
	  WritePrivateProfileString (lpszAppName, lpszKeyName, lpszString,
	  filename);
      goto quit;
    }

  PUSH_ERROR (ODBC_ERROR_INVALID_PATH);
  goto quit;

quit:
  return retcode;
}
Exemplo n.º 4
0
RETCODE SQL_API SQLFreeConnect(
										HDBC    hdbc)
{
	dbc_t*   tpdbc;
	dbc_t*   pdbc = hdbc;
	env_t*   penv = pdbc->henv;

	UNSET_ERROR( pdbc->herr );

	for ( tpdbc = penv->hdbc;
		 tpdbc;
		 tpdbc = tpdbc->next )
	{
		if ( pdbc == tpdbc )
		{
			penv->hdbc = pdbc->next;
			break;
		}

		if ( pdbc == tpdbc->next )
		{
			tpdbc->next = pdbc->next;
			break;
		}
	}

	CLEAR_ERROR( pdbc->herr );
	MEM_FREE( pdbc );

	return SQL_SUCCESS;
}
Exemplo n.º 5
0
BOOL INSTAPI
SQLRemoveDriverManager (LPDWORD lpdwUsageCount)
{
  /* Implementation finished ... very easy ... */
  CLEAR_ERROR ();
  return TRUE;
}
Exemplo n.º 6
0
void sptcl_raise_error(char *mod, char *name, int arity)
{
  char *err_funct = "tcl_error";

  switch (local.err_type&0xff)
    {
    case SPTK_ERROR:
      SP_ASSERT(local.err_culprit == 0); /* xref CLEAR_ERROR() */
      err_funct = "tk_error";
    case SPTCL_ERROR:
      SP_ASSERT(local.err_culprit == 0); /* xref CLEAR_ERROR() */
      {
      SP_term_ref
	t1 = SP_new_term_ref(),
	t2 = SP_new_term_ref(),
	t3 = SP_new_term_ref();

      SP_put_string(t1, name);
      SP_put_integer(t2, arity);
      SP_cons_functor(t1, SP_atom_from_string("/"), 2, t1, t2);
      SP_put_list_codes(t2, t3, local.err_msg);
      SP_cons_functor(t1, SP_atom_from_string(err_funct), 2, t1, t2);
      SP_raise_exception(t1);
      break;
    }
    default:
      SP_save_and_raise_error(local.err_type, local.err_msg, local.err_culprit, mod, name, arity, local.err_argno);
    }
  CLEAR_ERROR(); /* paranoia */
}
Exemplo n.º 7
0
BOOL INSTAPI
SQLInstallODBC (HWND hwndParent, LPCSTR lpszInfFile, LPCSTR lpszSrcPath,
    LPCSTR lpszDrivers)
{
  BOOL retcode = FALSE;

  /* Check input parameters */
  CLEAR_ERROR ();
  if (!lpszDrivers || !STRLEN (lpszDrivers))
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_NAME);
      goto quit;
    }

  if (!lpszInfFile || !STRLEN (lpszInfFile))
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_INF);
      goto quit;
    }

  retcode = InstallODBC (hwndParent, lpszInfFile, lpszSrcPath, lpszDrivers);

quit:
  return retcode;
}
Exemplo n.º 8
0
BOOL INSTAPI
SQLReadFileDSN (LPCSTR lpszFileName, LPCSTR lpszAppName, LPCSTR lpszKeyName,
                LPSTR lpszString, WORD cbString, WORD * pcbString)
{
    BOOL retcode = FALSE;
    WORD len = 0, i;
    char filename[1024];

    /* Check input parameters */
    CLEAR_ERROR ();

    if (!lpszString || !cbString)
    {
        PUSH_ERROR (ODBC_ERROR_INVALID_BUFF_LEN);
        goto quit;
    }

    if (!lpszAppName && lpszKeyName)
    {
        PUSH_ERROR (ODBC_ERROR_INVALID_REQUEST_TYPE);
        goto quit;
    }

    /* Is a file is specified */
    if (lpszFileName)
    {
        _iodbcdm_getdsnfile (lpszFileName, filename, sizeof (filename));
        len =
            GetPrivateProfileString (lpszAppName, lpszKeyName, "", lpszString,
                                     cbString, filename);
        if (numerrors == -1)
            retcode = TRUE;
        goto quit;
    }

    PUSH_ERROR (ODBC_ERROR_INVALID_PATH);
    goto quit;

quit:
    for (i = 0; i < len; i++)
        if (!lpszString[i])
            lpszString[i] = ';';

    if (pcbString)
        *pcbString = len;

    if (len == cbString - 1)
    {
        PUSH_ERROR (ODBC_ERROR_OUTPUT_STRING_TRUNCATED);
        retcode = FALSE;
    }

    return retcode;
}
Exemplo n.º 9
0
BOOL INSTAPI
SQLRemoveDSNFromIniW (LPCWSTR lpszDSN)
{
  BOOL retcode = FALSE;

  CLEAR_ERROR ();

  switch (configMode)
    {
    case ODBC_USER_DSN:
      wSystemDSN = USERDSN_ONLY;
      retcode = RemoveDSNFromIni ((SQLPOINTER) lpszDSN, 'W');
      goto quit;

    case ODBC_SYSTEM_DSN:
      wSystemDSN = SYSTEMDSN_ONLY;
      retcode = RemoveDSNFromIni ((SQLPOINTER) lpszDSN, 'W');
      goto quit;

    case ODBC_BOTH_DSN:
      wSystemDSN = USERDSN_ONLY;
      retcode = RemoveDSNFromIni ((SQLPOINTER) lpszDSN, 'W');
      if (!retcode)
	{
	  CLEAR_ERROR ();
	  wSystemDSN = SYSTEMDSN_ONLY;
	  retcode = RemoveDSNFromIni ((SQLPOINTER) lpszDSN, 'W');
	}
      goto quit;
    }

  PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
  goto quit;

quit:
  wSystemDSN = USERDSN_ONLY;
  configMode = ODBC_BOTH_DSN;
  return retcode;
}
Exemplo n.º 10
0
void tk_term(
             SP_term_ref tInterp,
             char SP_FLI_CONST *tktermsrc,
             char SP_FLI_CONST *text_widget,
             SP_stream **in_stream,
             SP_stream **out_stream,
             SP_stream **err_stream
             )
{
  (void)tInterp; (void)tktermsrc; (void)text_widget; (void)in_stream; (void)out_stream; (void)err_stream;
  CLEAR_ERROR(); /* [PM] 4.3 */
  SAVE_ERROR(SPTCL_ERROR, "tk_term not implemented", tInterp, 0);
  RAISE_ERROR("tk_terminal", 5);
}
Exemplo n.º 11
0
BOOL INSTAPI
SQLManageDataSources (HWND hwndParent)
{
  BOOL retcode = FALSE;

  /* Check input parameters */
  CLEAR_ERROR ();
  if (!hwndParent)
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_HWND);
      goto quit;
    }

  retcode = ManageDataSources (hwndParent);

quit:
  return retcode;
}
BOOL INSTAPI
SQLInstallDriverManager (LPSTR lpszPath, WORD cbPathMax, WORD * pcbPathOut)
{
  BOOL retcode = FALSE;

  /* Check input parameters */
  CLEAR_ERROR ();
  if (!lpszPath || !cbPathMax)
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_BUFF_LEN);
      goto quit;
    }

  retcode =
      InstallDriverPath (lpszPath, cbPathMax, pcbPathOut, "ODBCMANAGER");

quit:
  return retcode;
}
Exemplo n.º 13
0
BOOL INSTAPI
SQLGetConfigMode (UWORD * pwConfigMode)
{
  BOOL retcode = FALSE;

  /* Clear errors */
  CLEAR_ERROR ();

  /* Check input parameter */
  if (!pwConfigMode)
    {
      PUSH_ERROR (ODBC_ERROR_OUT_OF_MEM);
    }
  else
    {
      *pwConfigMode = configMode;
      retcode = TRUE;
    }

  return retcode;
}
Exemplo n.º 14
0
BOOL INSTAPI
SQLRemoveTranslator (LPCSTR lpszTranslator, LPDWORD lpdwUsageCount)
{
  BOOL retcode = FALSE;
  PCONFIG pCfg;

  /* Check input parameter */
  CLEAR_ERROR ();
  if (!lpszTranslator || !STRLEN (lpszTranslator))
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_NAME);
      goto quit;
    }

  if (_iodbcdm_cfg_search_init (&pCfg, "odbcinst.ini", FALSE))
    {
      PUSH_ERROR (ODBC_ERROR_REQUEST_FAILED);
      goto quit;
    }

  /* deletes the translator */
  _iodbcdm_cfg_write (pCfg, "ODBC Translators", (LPSTR) lpszTranslator, NULL);
  _iodbcdm_cfg_write (pCfg, (LPSTR) lpszTranslator, NULL, NULL);

  if (_iodbcdm_cfg_commit (pCfg))
    {
      PUSH_ERROR (ODBC_ERROR_REQUEST_FAILED);
      goto done;
    }

  retcode = TRUE;

done:
  _iodbcdm_cfg_done (pCfg);

quit:
  return retcode;
}
Exemplo n.º 15
0
/*
 * Sets up the native thread structures including the backtrace. If a context is specified it is used instead of grabbing
 * the context for the thread pointed to by state->current_thread.
 *
 * @param state - state variable for controlling the thread walk
 * @param sigContext - context to use in place of live thread context
 *
 * @return - 0 on success, non-zero otherwise.
 */
static int
setupNativeThread(J9ThreadWalkState *state, thread_context *sigContext)
{
	PlatformWalkData *data = (PlatformWalkData *)state->platform_data;
	int size = sizeof(thread_context);
	int rc = 0;

	if (size < sizeof(ucontext_t)) {
		size = sizeof(ucontext_t);
	}

	/* Allocate the thread container. */
	state->current_thread = (J9PlatformThread *)state->portLibrary->heap_allocate(state->portLibrary, state->heap, sizeof(J9PlatformThread));
	if (NULL == state->current_thread) {
		rc = -1;
	}
	if (0 == rc) {
		memset(state->current_thread, 0, sizeof(J9PlatformThread));

		/* Allocate space for the copy of the context. */
		state->current_thread->context = (thread_context *)state->portLibrary->heap_allocate(state->portLibrary, state->heap, size);
		if (NULL == state->current_thread->context) {
			rc = -1;
		}
	}

	if (0 == rc) {
		state->current_thread->thread_id = data->threadList[data->threadIndex];
		state->current_thread->process_id = getpid();

		if (NULL == sigContext) {
			/* Generate the context by installing a signal handler and raising a signal. None was provided. */
			if (0 == getThreadContext(state)) {
				memcpy(state->current_thread->context, signalHandlerContext, size);
			} else {
				rc = -1;
			}
		} else {
			/* Copy the context. We're using the provided context instead of generating it. */
			memcpy(state->current_thread->context, ((OMRUnixSignalInfo *)sigContext)->platformSignalInfo.context, size);
		}
	}

	if (0 == rc) {
		/* Populate backtraces if not present. */
		if (NULL == state->current_thread->callstack) {
			/* Don't pass sigContext in here as we should have fixed up the thread already. It confuses heap/not heap allocations if we
			 * pass it here.
			 */
			SPECULATE_ERROR(state, FAULT_DURING_BACKTRACE, 2);
			state->portLibrary->introspect_backtrace_thread(state->portLibrary, state->current_thread, state->heap, NULL);
			CLEAR_ERROR(state);
		}

		if ((NULL != state->current_thread->callstack) && (NULL == state->current_thread->callstack->symbol)) {
			SPECULATE_ERROR(state, FAULT_DURING_BACKTRACE, 3);
			state->portLibrary->introspect_backtrace_symbols(state->portLibrary, state->current_thread, state->heap);
			CLEAR_ERROR(state);
		}

		if (0 != state->current_thread->error) {
			RECORD_ERROR(state, state->current_thread->error, 1);
		}
	}

	return rc;
}
Exemplo n.º 16
0
BOOL INSTAPI
SQLWriteDSNToIni_Internal (SQLPOINTER lpszDSN, SQLPOINTER lpszDriver,
    SQLCHAR waMode)
{
  char *_driver_u8 = NULL;
  char *_dsn_u8 = NULL;
  BOOL retcode = FALSE;

  /* Check input parameters */
  CLEAR_ERROR ();

  if (waMode == 'A')
    {
      if (!lpszDSN || !ValidDSN (lpszDSN) || !STRLEN (lpszDSN))
	{
	  PUSH_ERROR (ODBC_ERROR_INVALID_DSN);
	  goto quit;
	}
    }
  else
    {
      if (!lpszDSN || !ValidDSNW (lpszDSN) || !WCSLEN (lpszDSN))
	{
	  PUSH_ERROR (ODBC_ERROR_INVALID_DSN);
	  goto quit;
	}
    }

  if (waMode == 'W')
    {
      _dsn_u8 = (char *) dm_SQL_WtoU8 ((SQLWCHAR *) lpszDSN, SQL_NTS);
      if (_dsn_u8 == NULL && lpszDSN)
	{
	  PUSH_ERROR (ODBC_ERROR_OUT_OF_MEM);
	  goto quit;
	}
    }
  else
    _dsn_u8 = (SQLCHAR *) lpszDSN;

  if (waMode == 'W')
    {
      _driver_u8 = (char *) dm_SQL_WtoU8 ((SQLWCHAR *) lpszDriver, SQL_NTS);
      if (_driver_u8 == NULL && lpszDriver)
	{
	  PUSH_ERROR (ODBC_ERROR_OUT_OF_MEM);
	  goto quit;
	}
    }
  else
    _driver_u8 = (SQLCHAR *) lpszDriver;

  if (!_driver_u8 || !STRLEN (_driver_u8))
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_NAME);
      goto quit;
    }

  switch (configMode)
    {
    case ODBC_USER_DSN:
      wSystemDSN = USERDSN_ONLY;
      retcode = WriteDSNToIni (_dsn_u8, _driver_u8);
      goto quit;

    case ODBC_SYSTEM_DSN:
      wSystemDSN = SYSTEMDSN_ONLY;
      retcode = WriteDSNToIni (_dsn_u8, _driver_u8);
      goto quit;

    case ODBC_BOTH_DSN:
      wSystemDSN = USERDSN_ONLY;
      retcode = WriteDSNToIni (_dsn_u8, _driver_u8);
      if (!retcode)
	{
	  CLEAR_ERROR ();
	  wSystemDSN = SYSTEMDSN_ONLY;
	  retcode = WriteDSNToIni (_dsn_u8, _driver_u8);
	}
      goto quit;
    }

  PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
  goto quit;

quit:
  if (_dsn_u8 != lpszDSN)
    MEM_FREE (_dsn_u8);
  if (_driver_u8 != lpszDriver)
    MEM_FREE (_driver_u8);

  wSystemDSN = USERDSN_ONLY;
  configMode = ODBC_BOTH_DSN;

  return retcode;
}
Exemplo n.º 17
0
BOOL INSTAPI
SQLRemoveDriver (LPCSTR lpszDriver, BOOL fRemoveDSN, LPDWORD lpdwUsageCount)
{
  /*char *szDriverFile = NULL; */
  BOOL retcode = FALSE;
  PCONFIG pCfg = NULL, pInstCfg = NULL;
  LPSTR entries = (LPSTR) malloc (sizeof (char) * 65535), curr;
  int len = 0, i = 0;

  /* Check input parameters */
  CLEAR_ERROR ();
  if (!lpszDriver || !STRLEN (lpszDriver))
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_NAME);
      goto quit;
    }

  /* Else go through user/system odbcinst.ini */
  switch (configMode)
    {
    case ODBC_BOTH_DSN:
    case ODBC_USER_DSN:
      wSystemDSN = USERDSN_ONLY;
      break;

    case ODBC_SYSTEM_DSN:
      wSystemDSN = SYSTEMDSN_ONLY;
      break;
    }

  if (_iodbcdm_cfg_search_init (&pCfg, "odbc.ini", FALSE))
    {
      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
      goto done;
    }

  if (_iodbcdm_cfg_search_init (&pInstCfg, "odbcinst.ini", FALSE))
    {
      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
      goto done;
    }

  if (fRemoveDSN)
    {
#ifdef WIN32
      if (entries &&
	  (len = _iodbcdm_list_entries (pCfg, "ODBC 32 bit Data Sources",
		  entries, 65535)))
#else
      if (entries
	  && (len =
	      _iodbcdm_list_entries (pCfg, "ODBC Data Sources", entries,
		  65535)))
#endif
	{
	  for (curr = entries; i < len;
	      i += (STRLEN (curr) + 1), curr += (STRLEN (curr) + 1))
	    {
	      int nCursor = pCfg->cursor;

	      if (_iodbcdm_cfg_rewind (pCfg))
		{
		  PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
		  goto done;
		}

#ifdef WIN32
	      if (_iodbcdm_cfg_find (pCfg, "ODBC 32 bit Data Sources", curr))
#else
	      if (_iodbcdm_cfg_find (pCfg, "ODBC Data Sources", curr))
#endif
		{
		  if (_iodbcdm_cfg_rewind (pCfg))
		    {
		      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
		      goto done;
		    }
		  pCfg->cursor = nCursor;
		  continue;
		}

	      if (!strcmp (pCfg->value, lpszDriver))
		{
		  if (_iodbcdm_cfg_write (pCfg, curr, NULL, NULL))
		    {
		      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
		      goto done;
		    }

#ifdef WIN32
		  if (_iodbcdm_cfg_write (pCfg, "ODBC 32 bit Data Sources",
			  curr, NULL))
#else
		  if (_iodbcdm_cfg_write (pCfg, "ODBC Data Sources", curr,
			  NULL))
#endif
		    {
		      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
		      goto done;
		    }
		}

	      pCfg->cursor = nCursor;
	    }
	}
    }

  if (_iodbcdm_cfg_write (pInstCfg, (char *) lpszDriver, NULL, NULL))
    {
      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
      goto done;
    }

#ifdef WIN32
  if (_iodbcdm_cfg_write (pInstCfg, "ODBC 32 bit Drivers", lpszDriver, NULL))
#else
  if (_iodbcdm_cfg_write (pInstCfg, "ODBC Drivers", (LPSTR) lpszDriver, NULL))
#endif
    {
      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
      goto done;
    }

  if (_iodbcdm_cfg_commit (pCfg) || _iodbcdm_cfg_commit (pInstCfg))
    {
      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
      goto done;
    }

  retcode = TRUE;

done:
  if (pCfg)
    _iodbcdm_cfg_done (pCfg);
  if (pInstCfg)
    _iodbcdm_cfg_done (pInstCfg);
  if (entries)
    free (entries);

quit:
  wSystemDSN = USERDSN_ONLY;
  configMode = ODBC_BOTH_DSN;

  return retcode;
}
Exemplo n.º 18
0
SRVR_STMT_HDL::SRVR_STMT_HDL(long inDialogueId)
{
	FUNCTION_ENTRY("SRVR_STMT_HDL::SRVR_STMT_HDL",("inDialogueId=%ld)",inDialogueId));

	cursorName[0] = '\0';
	previousCursorName[0] = '\0';
	stmtName[0] = '\0';
	paramCount = 0;
	columnCount = 0;
	SqlQueryStatementType = INVALID_SQL_QUERY_STMT_TYPE;
	stmtType = EXTERNAL_STMT;
	inputDescVarBuffer = NULL;
	outputDescVarBuffer = NULL;
	inputDescVarBufferLen = 0;
	outputDescVarBufferLen = 0;
	endOfData = FALSE;

	// The following were added for SPJRS support
	isSPJRS = FALSE;
	RSIndex = 0;
	RSMax = 0;

	currentMethod = UNKNOWN_METHOD;
	asyncThread = NULL;
	queryTimeoutThread = NULL;
	threadStatus = SQL_SUCCESS;
	threadId = 0;
	threadReturnCode = SQL_SUCCESS;

	sqlAsyncEnable = SQL_ASYNC_ENABLE_OFF;
	queryTimeout = 0;
	sqlString.dataValue._buffer = NULL;
	sqlString.dataValue._length = 0;
	inputRowCnt = 0;
	maxRowCnt = 0;
	sqlStmtType = TYPE_UNKNOWN;
	freeResourceOpt = SQL_CLOSE;
	inputValueList._length = 0;
	inputValueList._buffer = NULL;

	estimatedCost = 0;
	rowsAffected = 0;
	inputDescList._length = 0;
	inputDescList._buffer = NULL;
	outputDescList._length = 0;
	outputDescList._buffer = NULL;
	CLEAR_WARNING(sqlWarning);
	CLEAR_ERROR(sqlError);
	outputValueList._length = 0;
	outputValueList._buffer = NULL;
	outputValueVarBuffer = NULL;
	inputValueVarBuffer = NULL;
	clientLCID = srvrGlobal->clientLCID;
	rowCount._length = 0;
	rowCount._buffer = NULL;
	isReadFromModule = FALSE;
	moduleName[0] = '\0';
	inputDescName[0] = '\0';
	outputDescName[0] = '\0';
	isClosed = TRUE;
	IPD = NULL;
	IRD = NULL;
	useDefaultDesc = FALSE;
	dialogueId = inDialogueId;
	nowaitRetcode = SQL_SUCCESS;
	holdability = CLOSE_CURSORS_AT_COMMIT;
	fetchQuadEntries = 0;
	fetchRowsetSize = 0;
	fetchQuadField = NULL;
	batchQuadEntries = 0;
	batchRowsetSize = 0;
	batchQuadField = NULL;
	inputDescParamOffset = 0;
	batchMaxRowsetSize = 0;
	stmtInitForNowait = FALSE;
	FUNCTION_RETURN_VOID((NULL));
}
Exemplo n.º 19
0
lxdream_file_type_t file_load_magic( const gchar *filename, gboolean wrap_exec, ERROR *err )
{
    gboolean result;
    /* Try disc types first */
    cdrom_disc_t disc = cdrom_disc_open( filename, err );
    if( disc != NULL ) {
        gdrom_mount_disc(disc);
        return FILE_DISC;
    } else if( !IS_ERROR_CODE(err,LX_ERR_FILE_UNKNOWN) ) {
        return FILE_ERROR;
    }

    int fd = open( filename, O_RDONLY );
    if( fd == -1 ) {
        SET_ERROR( err, LX_ERR_FILE_NOOPEN, "Unable to open file '%s' (%s)" ,filename, strerror(errno) );
        return FILE_ERROR;
    }

    lxdream_file_type_t type = file_identify(filename, fd, err);
    switch( type ) {
    case FILE_ERROR:
        result = FALSE;
        break;
    case FILE_ELF:
        if( wrap_exec ) {
            disc = cdrom_wrap_elf( CDROM_DISC_XA, filename, fd, err );
            result = disc != NULL;
            if( disc != NULL ) {
                gdrom_mount_disc(disc);
            }
        } else {
            result = file_load_elf( filename, fd, err );
        }
        break;
    case FILE_BINARY:
        if( wrap_exec ) {
            disc = cdrom_wrap_binary( CDROM_DISC_XA, filename, fd, err );
            result = disc != NULL;
            if( disc != NULL ) {
                gdrom_mount_disc(disc);
            }
        } else {
            result = file_load_binary( filename, fd, err );
        }
        break;
    case FILE_SAVE_STATE:
        result = dreamcast_load_state( filename );
        break;
    case FILE_ZIP:
        SET_ERROR( err, LX_ERR_FILE_UNSUP, "ZIP/SBI not currently supported" );
        result = FALSE;
        break;
    case FILE_ISO:
        SET_ERROR( err, LX_ERR_FILE_UNSUP, "ISO files are not currently supported" );
        result = FALSE;
        break;
    default:
        SET_ERROR( err, LX_ERR_FILE_UNKNOWN, "File '%s' could not be recognized", filename );
        result = FALSE;
        break;
    }
    close(fd);
    if( result ) {
        CLEAR_ERROR(err);
        return type;
    }
    return FILE_ERROR;
}
Exemplo n.º 20
0
BOOL INSTAPI
SQLConfigDriver_Internal (HWND hwndParent, WORD fRequest, LPCSTR lpszDriver,
    LPCSTR lpszArgs, LPSTR lpszMsg, WORD cbMsgMax, WORD FAR * pcbMsgOut,
    SQLCHAR waMode)
{
  PCONFIG pCfg;
  BOOL retcode = FALSE;
  void *handle;
  pConfigDriverFunc pConfigDriver;
  pConfigDriverWFunc pConfigDriverW;
#if defined (__APPLE__) && !(defined (NO_FRAMEWORKS) || defined (_LP64))
  CFStringRef libname = NULL;
  CFBundleRef bundle;
  CFURLRef liburl;
  char name[1024] = { 0 };
#endif
  char *_drv_u8 = NULL;

  /* Check input parameters */
  CLEAR_ERROR ();

  if (waMode == 'W')
    {
      _drv_u8 = (char *) dm_SQL_WtoU8 ((SQLWCHAR *) lpszDriver, SQL_NTS);
      if (_drv_u8 == NULL && lpszDriver)
	{
	  PUSH_ERROR (ODBC_ERROR_OUT_OF_MEM);
	  goto quit;
	}
    }
  else
    _drv_u8 = (char *) lpszDriver;

  if (!_drv_u8 || !STRLEN (_drv_u8))
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_NAME);
      goto quit;
    }

  /* Map the request User/System */
  if (fRequest < ODBC_INSTALL_DRIVER || fRequest > ODBC_CONFIG_DRIVER_MAX)
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_REQUEST_TYPE);
      goto quit;
    }

  /* Get it from the user odbcinst file */
  wSystemDSN = USERDSN_ONLY;
  if (!_iodbcdm_cfg_search_init (&pCfg, "odbcinst.ini", TRUE))
    {
      if (!_iodbcdm_cfg_find (pCfg, (char *) _drv_u8, "Setup"))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (pCfg->value);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (pCfg->value);
	    }
	}
      if (!_iodbcdm_cfg_find (pCfg, (char *) _drv_u8, "Driver"))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (pCfg->value);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (pCfg->value);
	    }
	}
      if (!access (_drv_u8, X_OK))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (_drv_u8);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (_drv_u8);
	    }
	}
      if (!_iodbcdm_cfg_find (pCfg, "Default", "Setup"))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (pCfg->value);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (pCfg->value);
	    }
	}
      if (!_iodbcdm_cfg_find (pCfg, "Default", "Driver"))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (pCfg->value);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (pCfg->value);
	    }
	}
    }

  /* Get it from the system odbcinst file */
  if (pCfg)
    {
      _iodbcdm_cfg_done (pCfg);
      pCfg = NULL;
    }
  wSystemDSN = SYSTEMDSN_ONLY;
  if (!_iodbcdm_cfg_search_init (&pCfg, "odbcinst.ini", TRUE))
    {
      if (!_iodbcdm_cfg_find (pCfg, (char *) _drv_u8, "Setup"))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (pCfg->value);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (pCfg->value);
	    }
	}
      if (!_iodbcdm_cfg_find (pCfg, (char *) _drv_u8, "Driver"))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (pCfg->value);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (pCfg->value);
	    }
	}
      if (!access (_drv_u8, X_OK))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (_drv_u8);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (_drv_u8);
	    }
	}
      if (!_iodbcdm_cfg_find (pCfg, "Default", "Setup"))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (pCfg->value);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (pCfg->value);
	    }
	}
      if (!_iodbcdm_cfg_find (pCfg, "Default", "Driver"))
	{
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (pCfg->value);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (pCfg->value);
	    }
	}
    }

  /* The last ressort, a proxy driver */
#if defined (__APPLE__) && !(defined (NO_FRAMEWORKS) || defined (_LP64))
  bundle = CFBundleGetBundleWithIdentifier (CFSTR ("org.iodbc.inst"));
  if (bundle)
    {
      /* Search for the drvproxy library */
      liburl =
	  CFBundleCopyResourceURL (bundle, CFSTR ("iODBCdrvproxy.bundle"),
	  NULL, NULL);
      if (liburl
	  && (libname =
	      CFURLCopyFileSystemPath (liburl, kCFURLPOSIXPathStyle)))
	{
	  CFStringGetCString (libname, name, sizeof (name),
	      kCFStringEncodingASCII);
	  strcat (name, "/Contents/MacOS/iODBCdrvproxy");
	  if (waMode == 'A')
	    {
	      CALL_CONFIG_DRIVER (name);
	    }
	  else
	    {
	      CALL_CONFIG_DRIVERW (name);
	    }
	}
      if (liburl)
	CFRelease (liburl);
      if (libname)
	CFRelease (libname);
    }
#else
  if (waMode == 'A')
    {
      CALL_CONFIG_DRIVER ("libdrvproxy.so.2");
    }
  else
    {
      CALL_CONFIG_DRIVERW ("libdrvproxy.so.2");
    }
#endif

  /* Error : ConfigDriver could no be found */
  PUSH_ERROR (ODBC_ERROR_LOAD_LIB_FAILED);

done:
  if (pCfg)
    _iodbcdm_cfg_done (pCfg);

quit:
  if (_drv_u8 != lpszDriver)
    MEM_FREE (_drv_u8);

  wSystemDSN = USERDSN_ONLY;
  configMode = ODBC_BOTH_DSN;

  if (pcbMsgOut)
    *pcbMsgOut = 0;

  return retcode;
}
Exemplo n.º 21
0
BOOL INSTAPI
SQLInstallTranslatorEx (LPCSTR lpszTranslator, LPCSTR lpszPathIn,
    LPSTR lpszPathOut, WORD cbPathOutMax, WORD * pcbPathOut, WORD fRequest,
    LPDWORD lpdwUsageCount)
{
  PCONFIG pCfg = NULL, pOdbcCfg = NULL;
  BOOL retcode = FALSE;

  CLEAR_ERROR ();

  if (lpszPathIn && access (lpszPathIn, R_OK | W_OK | X_OK))
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_PATH);
      goto quit;
    }

  switch (fRequest)
    {
    case ODBC_INSTALL_INQUIRY:
      if (lpszPathIn)
	{
	  if (pcbPathOut)
	    *pcbPathOut = STRLEN (lpszPathIn);
	  retcode = TRUE;
	}
      else
	retcode = InstallDriverPathLength (pcbPathOut, "ODBCTRANSLATORS");
      goto quit;

    case ODBC_INSTALL_COMPLETE:
      break;

    default:
      PUSH_ERROR (ODBC_ERROR_INVALID_REQUEST_TYPE);
      goto quit;
    }

  /* Check input parameters */
  if (!lpszTranslator || !STRLEN (lpszTranslator))
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_PARAM_SEQUENCE);
      goto quit;
    }

  if (!lpszPathOut || !cbPathOutMax)
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_BUFF_LEN);
      goto quit;
    }

  /* Write the out path */
  if (!InstallDriverPath (lpszPathOut, cbPathOutMax, pcbPathOut,
	  "ODBCTRANSLATORS"))
    goto quit;

  /* Else go through user/system odbcinst.ini */
  switch (configMode)
    {
    case ODBC_BOTH_DSN:
    case ODBC_USER_DSN:
      wSystemDSN = USERDSN_ONLY;
      break;

    case ODBC_SYSTEM_DSN:
      wSystemDSN = SYSTEMDSN_ONLY;
      break;
    }

  if (_iodbcdm_cfg_search_init (&pCfg, "odbcinst.ini", TRUE))
    {
      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
      goto quit;
    }

  if (_iodbcdm_cfg_search_init (&pOdbcCfg, "odbc.ini", TRUE))
    {
      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
      pOdbcCfg = NULL;
      goto done;
    }

  if (!install_from_string (pCfg, pOdbcCfg, (char *) lpszTranslator, FALSE))
    {
      PUSH_ERROR (ODBC_ERROR_INVALID_KEYWORD_VALUE);
      goto done;
    }

  if (_iodbcdm_cfg_commit (pCfg) || _iodbcdm_cfg_commit (pOdbcCfg))
    {
      PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
      goto done;
    }

  retcode = TRUE;

done:
  _iodbcdm_cfg_done (pCfg);
  if (pOdbcCfg)
    _iodbcdm_cfg_done (pOdbcCfg);

quit:
  wSystemDSN = USERDSN_ONLY;
  configMode = ODBC_BOTH_DSN;

  return retcode;
}
Exemplo n.º 22
0
BOOL INSTAPI
SQLWritePrivateProfileString (LPCSTR lpszSection, LPCSTR lpszEntry,
    LPCSTR lpszString, LPCSTR lpszFilename)
{
  char pathbuf[1024];
  BOOL retcode = FALSE;

  /* Check input parameters */
  CLEAR_ERROR ();

  /* Else go through user/system odbc.ini */
  switch (configMode)
    {
    case ODBC_USER_DSN:
      wSystemDSN = USERDSN_ONLY;
      if (lpszFilename)
	{
	  retcode =
	      WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	      lpszFilename);
	  goto quit;
	}
      if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE))
	retcode =
	    WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	    pathbuf);
      goto quit;

    case ODBC_SYSTEM_DSN:
      wSystemDSN = SYSTEMDSN_ONLY;
      if (lpszFilename)
	{
	  retcode =
	      WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	      lpszFilename);
	  goto quit;
	}
      if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE))
	retcode =
	    WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	    pathbuf);
      goto quit;

    case ODBC_BOTH_DSN:
      wSystemDSN = USERDSN_ONLY;
      if (lpszFilename)
	{
	  retcode =
	      WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	      lpszFilename);
	  if (!retcode)
	    {
	      CLEAR_ERROR ();
	      wSystemDSN = SYSTEMDSN_ONLY;
	      retcode =
		  WritePrivateProfileString (lpszSection, lpszEntry,
		  lpszString, lpszFilename);
	    }
	  goto quit;
	}
      if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE))
	retcode =
	    WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
	    pathbuf);
      else
	{
	  CLEAR_ERROR ();
	  wSystemDSN = SYSTEMDSN_ONLY;
	  if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, TRUE))
	    retcode =
		WritePrivateProfileString (lpszSection, lpszEntry, lpszString,
		pathbuf);
	}
      goto quit;
    }

  PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
  goto quit;

quit:
  wSystemDSN = USERDSN_ONLY;
  configMode = ODBC_BOTH_DSN;
  return retcode;
}