Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

lib/WINBUILD/i_opencbm.c File Reference

Helper functions for the DLL for accessing the driver, and the install functions. More...

#include <windows.h>
#include <windowsx.h>
#include "debug.h"
#include <winioctl.h>
#include "cbmioctl.h"
#include <stdlib.h>
#include <stddef.h>
#include "i_opencbm.h"
#include "version.h"
#include "archlib.h"

Go to the source code of this file.

Defines

#define DBG_USERMODE
#define DBG_PROGNAME   "OPENCBM.DLL"

Functions

LONG RegGetDWORD (IN HKEY RegKey, IN char *SubKey, OUT LPDWORD Value)
 Get a DWORD value from the registry.
const char * cbmarch_get_driver_name (int PortNumber)
 Get the name of the driver for a specific parallel port.
int cbmarch_driver_open (CBM_FILE *HandleDevice, int PortNumber)
 Opens the driver.
void cbmarch_driver_close (CBM_FILE HandleDevice)
 Closes the driver.
BOOL cbm_ioctl (IN CBM_FILE HandleDevice, IN DWORD ControlCode, IN PVOID InBuffer, IN ULONG InBufferSize, OUT PVOID OutBuffer, IN ULONG OutBufferSize)
 Perform an ioctl on the driver.
BOOL cbm_i_driver_start (VOID)
 Start a device driver.
BOOL cbm_i_driver_stop (VOID)
 Stop a device driver.
BOOL cbm_i_i_driver_install (OUT PULONG Buffer, IN ULONG BufferLen)
 Complete driver installation, "direct version".
BOOL IsDriverStartedAutomatically (VOID)
 Is the driver started automatically?


Detailed Description

Helper functions for the DLL for accessing the driver, and the install functions.

**************************************************************

Author:
Spiro Trikaliotis
Version:
Id
i_opencbm.c,v 1.13 2006/04/19 16:48:17 trikalio Exp

Authors:
Based on code from Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>

Definition in file lib/WINBUILD/i_opencbm.c.


Define Documentation

#define DBG_PROGNAME   "OPENCBM.DLL"
 

The name of the executable

Definition at line 35 of file lib/WINBUILD/i_opencbm.c.

#define DBG_USERMODE
 

Mark: We are in user-space (for debug.h)

Definition at line 31 of file lib/WINBUILD/i_opencbm.c.


Function Documentation

BOOL cbm_i_driver_start VOID   ) 
 

Start a device driver.

This function start a device driver. It is the programmatically equivalent for "net start <driver>"

Returns:
Returns TRUE on success, else FALSE.
This function is for use of the installation routines only!

Definition at line 435 of file lib/WINBUILD/i_opencbm.c.

References DBG_ERROR, DBG_PREFIX, DBG_SUCCESS, DBG_WARN, FUNC_ENTER, FUNC_LEAVE_BOOL, and OPENCBM_DRIVERNAME.

Referenced by CbmCheckCorrectInstallation(), CbmInstall(), and opencbm_init().

BOOL cbm_i_driver_stop VOID   ) 
 

Stop a device driver.

This function stops a device driver. It is the programmatically equivalent for "net stop <driver>"

Returns:
Returns TRUE on success, else FALSE.
This function is for use of the installation routines only!

Definition at line 510 of file lib/WINBUILD/i_opencbm.c.

References DBG_ERROR, DBG_PREFIX, DBG_SUCCESS, FUNC_ENTER, FUNC_LEAVE_BOOL, and OPENCBM_DRIVERNAME.

Referenced by CbmCheckCorrectInstallation(), CbmRemove(), and opencbm_init().

BOOL cbm_i_i_driver_install OUT PULONG  Buffer,
IN ULONG  BufferLen
 

Complete driver installation, "direct version".

This function performs anything that is needed to successfully complete the driver installation.

Parameters:
Buffer Pointer to a buffer which will return the install information
BufferLen The length of the buffer Buffer points to (in bytes).
Returns:
FALSE on success, TRUE on error
This function is for use of the installation routines only!

This version is for usage in the DLL or the install package.

Definition at line 575 of file lib/WINBUILD/i_opencbm.c.

References CBM_FILE, CBM_I_DRIVER_INSTALL_0_FAILED, CBM_I_DRIVER_INSTALL_0_IOCTL_FAILED, cbm_ioctl(), cbmarch_driver_close(), cbmarch_driver_open(), CBMCTRL, CBMT_I_INSTALL_OUT_MAKE_VERSION, CBMT_I_INSTALL_OUT_MAKE_VERSION_EX, DBG_ASSERT, DBG_ERROR, DBG_PREFIX, CBMT_I_INSTALL_OUT::DllVersion, CBMT_I_INSTALL_OUT::DllVersionEx, CBMT_I_INSTALL_OUT::ErrorFlags, FUNC_ENTER, and FUNC_LEAVE_INT.

Referenced by cbm_i_driver_install(), and CbmCheckCorrectInstallation().

BOOL cbm_ioctl IN CBM_FILE  HandleDevice,
IN DWORD  ControlCode,
IN PVOID  InBuffer,
IN ULONG  InBufferSize,
OUT PVOID  OutBuffer,
IN ULONG  OutBufferSize
 

Perform an ioctl on the driver.

This function performs an ioctl on the driver. It is used internally only.

Parameters:
HandleDevice A CBM_FILE which contains the file handle of the driver.
ControlCode The ControlCode of the IOCTL to be performed.
TextControlCode A string representation of the IOCTL to be performed. This is used for debugging purposes, only, and not available in free builds.
InBuffer Pointer to a buffer which holds the input parameters for the IOCTL. Can be NULL if no input buffer is needed.
InBufferSize Size of the buffer pointed to by InBuffer. If InBuffer is NULL, this has to be zero,
OutBuffer Pointer to a buffer which holds the output parameters of the IOCTL. Can be NULL if no output buffer is needed.
OutBufferSize Size of the buffer pointed to by OutBuffer. If OutBuffer is NULL, this has to be zero,
Returns:
TRUE: IOCTL succeeded, else FALSE an error occurred processing the IOCTL
If cbm_driver_open() did not succeed, it is illegal to call this function.

Definition at line 382 of file lib/WINBUILD/i_opencbm.c.

References DBG_ERROR, DBG_PREFIX, DBG_WARN, FUNC_ENTER, and FUNC_LEAVE_BOOL.

Referenced by cbm_i_i_driver_install(), cbmarch_clear_eoi(), cbmarch_close(), cbmarch_get_eoi(), cbmarch_iec_poll(), cbmarch_iec_release(), cbmarch_iec_set(), cbmarch_iec_setrelease(), cbmarch_listen(), cbmarch_lock(), cbmarch_open(), cbmarch_parallel_burst_read(), cbmarch_parallel_burst_read_track(), cbmarch_parallel_burst_write(), cbmarch_parallel_burst_write_track(), cbmarch_pp_read(), cbmarch_pp_write(), cbmarch_reset(), cbmarch_talk(), cbmarch_unlisten(), cbmarch_unlock(), cbmarch_untalk(), and CbmInstallUpdate().

void cbmarch_driver_close CBM_FILE  HandleDevice  ) 
 

Closes the driver.

Closes the driver, which has be opened with cbm_driver_open() before.

Parameters:
HandleDevice A CBM_FILE which contains the file handle of the driver.
cbm_driver_close() should be called to balance a previous call to cbm_driver_open().

If cbm_driver_open() did not succeed, it is illegal to call cbm_driver_close().

Definition at line 330 of file lib/WINBUILD/i_opencbm.c.

References DBG_ASSERT, FUNC_ENTER, and FUNC_LEAVE.

Referenced by cbm_driver_close(), cbm_i_i_driver_install(), and CbmInstallUpdate().

int cbmarch_driver_open CBM_FILE *  HandleDevice,
int  PortNumber
 

Opens the driver.

This function Opens the driver.

Parameters:
HandleDevice Pointer to a CBM_FILE which will contain the file handle of the driver.
PortNumber The port number of the driver to open. 0 means "default" driver, while values != 0 enumerate each driver.
Returns:
==0: This function completed successfully !=0: otherwise
PortNumber is not allowed to exceed 10.

cbm_driver_open() should be balanced with cbm_driver_close().

Definition at line 281 of file lib/WINBUILD/i_opencbm.c.

References cbmarch_get_driver_name(), DBG_ASSERT, FUNC_ENTER, and FUNC_LEAVE_INT.

Referenced by cbm_driver_open(), cbm_i_i_driver_install(), and CbmInstallUpdate().

const char* cbmarch_get_driver_name int  PortNumber  ) 
 

Get the name of the driver for a specific parallel port.

Get the name of the driver for a specific parallel port.

Parameters:
PortNumber The port number for the driver to open. 0 means "default" driver, while values != 0 enumerate each driver.
Returns:
Returns a pointer to a null-terminated string containing the driver name, or NULL if an error occurred.
Bug:
PortNumber is not allowed to exceed 10.
Todo:
do not hard-code the driver name
Bug:
the logic does not allow more than 10 entries, thus, fail this call if we want to use a port > 10!

Definition at line 230 of file lib/WINBUILD/i_opencbm.c.

References FUNC_ENTER, and FUNC_LEAVE_STRING.

Referenced by cbm_get_driver_name(), and cbmarch_driver_open().

BOOL IsDriverStartedAutomatically VOID   ) 
 

Is the driver started automatically?

This function finds out if the driver is started automatically or manually.

Returns:
Returns TRUE if driver is started automatically, FALSE if not.

Definition at line 634 of file lib/WINBUILD/i_opencbm.c.

References CBM_REGKEY_SERVICE, DBG_ERROR, DBG_PREFIX, DBG_WARN, FUNC_ENTER, FUNC_LEAVE_BOOL, and RegGetDWORD().

Referenced by CbmCheckCorrectInstallation(), and opencbm_init().

LONG RegGetDWORD IN HKEY  RegKey,
IN char *  SubKey,
OUT LPDWORD  Value
 

Get a DWORD value from the registry.

This function gets a DWORD value in the registry. It is a simple wrapper for convenience.

Parameters:
RegKey A handle to an already opened registry key.
SubKey Pointer to a null-terminiated string which holds the name of the value to be created or changed.
Value Pointer to a variable which will contain the value from the registry
Returns:
ERROR_SUCCESS on success, -1 otherwise
If this function returns -1, the given Value will not be changed at all!

Definition at line 77 of file lib/WINBUILD/i_opencbm.c.

Referenced by IsDriverStartedAutomatically().


Generated on Sun Apr 30 18:46:08 2006 for opencbm by  doxygen 1.4.2