27 #define DBG_PROGNAME "OPENCBM-XA1541.DLL"
28 #endif // #ifndef DBG_PROGNAME
42 #define OPENCBM_PLUGIN 1
45 #include "archlib-windows.h"
79 static const struct option longopts[] =
81 {
"help", no_argument, NULL,
'h' },
82 {
"version", no_argument, NULL,
'V' },
86 {
"forcent4", no_argument, NULL,
'F' },
87 #endif // #ifdef _X86_
88 {
"lpt", required_argument, NULL,
'l' },
89 {
"cabletype", required_argument, NULL,
't' },
90 {
"lock", required_argument, NULL,
'L' },
92 {
"debugflags", required_argument, NULL,
'D' },
93 {
"buffer", no_argument, NULL,
'B' },
95 {
"automatic", no_argument, NULL,
'A' },
96 {
"on-demand", no_argument, NULL,
'O' },
101 static const char shortopts[] =
"-hVFl:t:L:DBAO";
103 static const char usagetext[] =
104 "\n\nUsage: instcbm [options] xa1541 [plugin-options]\n"
105 "Install the XA1541 plugin and driver on the system, or remove it.\n"
107 "plugin-options is one of:\n"
108 " -h, --help display this help and exit\n"
109 " -V, --version display version information about cbm4win\n"
111 " -l, --lpt=no set default LPT port\n"
112 " -t, --cabletype=TYPE set cabletype to 'auto', 'xa1541' or 'xm1541'.\n"
113 " If not specified, --cabletype=auto is assumed.\n"
114 " -L, --lock=WHAT automatically lock the driver 'yes' or not 'no'.\n"
115 " If not specified, --lock=yes is assumed.\n"
117 " -F, --forcent4 force NT4 driver on a Win 2000, XP, or newer systems\n"
118 " (NOT RECOMMENDED!)\n"
119 #endif // #ifdef _X86_
120 " -A, --automatic (default) automatically start the driver on system boot.\n"
121 " The driver can be used from a normal user, no need for\n"
122 " administrator rights.\n"
123 " The opposite of --on-demand.\n"
124 " -O, --on-demand start the driver only on demand.\n"
125 " The opposite of --automatic.\n"
129 static opencbm_plugin_install_neededfiles_t NeededFilesXA1541[] =
131 { SYSTEM_DIR,
"opencbm-xa1541.dll", NULL },
132 { DRIVER_DIR,
"cbm4wdm.sys", NULL },
134 { DRIVER_DIR,
"cbm4nt.sys", NULL },
136 { LIST_END,
"", NULL }
153 fprintf(stderr,
"Try \"instcbm xa1541 --help\" for more information.\n");
162 printf(
"opencbm xa1541 plugin version " ", built on " __DATE__
" at " __TIME__
"\n");
172 printf(
"%s", usagetext);
208 processNumber(
const PCHAR Argument, PCHAR *NextChar, PBOOL ParameterGiven, PULONG ParameterValue)
254 *ParameterValue = strtoul(p, &p, base);
258 error = ((*p != 0) && (*p !=
',')) ? TRUE : FALSE;
262 error = *p != 0 ? TRUE : FALSE;
267 if (NextChar != NULL)
269 *NextChar = p + ((*p) ? 1 : 0);
272 if (ParameterGiven != NULL)
274 *ParameterGiven = TRUE;
296 char **localOptarg = Data->OptArg;
300 BOOL quitLocalProcessing = FALSE;
312 if (Data->Argc == 0) {
326 parameter->
OsVersion = Data->InstallParameter->OsVersion;
331 parameter->
Lpt = (ULONG) -1;
347 while ( ! quitLocalProcessing && (c = Data->GetoptLongCallback(Data->Argc, Data->Argv, shortopts, longopts)) != -1) {
351 Data->InstallParameter->NoExecute = TRUE;
356 Data->InstallParameter->NoExecute = TRUE;
360 if ((*localOptarg == NULL) || (strcmp(*localOptarg,
"auto") == 0))
362 else if (strcmp(*localOptarg,
"xa1541") == 0)
364 else if (strcmp(*localOptarg,
"xm1541") == 0)
368 fprintf(stderr,
"you must specify 'xa1541', 'xm1541' or 'auto' for --cabletype\n");
374 if (*localOptarg == NULL
375 || (strcmp(*localOptarg,
"+") == 0)
376 || (strcmp(*localOptarg,
"yes") == 0)
377 || (strcmp(*localOptarg,
"true") == 0)
382 else if (*localOptarg != NULL &&
383 ( (strcmp(*localOptarg,
"-") == 0)
384 || (strcmp(*localOptarg,
"no") == 0)
385 || (strcmp(*localOptarg,
"false") == 0)
393 fprintf(stderr,
"you must specify 'yes' or 'no' for --lock\n");
400 if (Data->InstallParameter->ExecuteParameterGiven)
403 printf(
"Colliding parameters were given, aborting!");
408 Data->InstallParameter->ExecuteParameterGiven = TRUE;
413 #endif // #ifdef _X86_
416 error = processNumber(*localOptarg, NULL, NULL, ¶meter->
Lpt);
422 fprintf(stderr,
"--automatic and --on-demand cannot be specified at the same time!\n");
435 fprintf(stderr,
"--automatic and --on-demand cannot be specified at the same time!\n");
446 quitLocalProcessing = 1;
451 fprintf(stderr,
"error...\n");
474 char * driverLocation = NULL;
486 if (pluginInstallParameter == NULL || pluginInstallParameter->OptionMemory == NULL) {
490 parameter = pluginInstallParameter->OptionMemory;
503 pluginInstallParameter->NeededFiles[driverToUse].FileLocationString,
504 pluginInstallParameter->NeededFiles[driverToUse].Filename);
506 if (driverLocation == NULL) {
508 fprintf(stderr,
"Could not get the location of the driver file, aborting.\n");
512 printf(
"Using driver '%s'\n", driverLocation);
552 if (pluginInstallParameter == NULL || pluginInstallParameter->OptionMemory == NULL) {
556 parameter = pluginInstallParameter->OptionMemory;
561 printf(
"No driver installed, cannot remove.\n");
566 printf(
"REMOVING driver...\n");
588 unsigned int size =
sizeof(NeededFilesXA1541);
594 if (NULL == Destination) {
598 memcpy(Destination, NeededFilesXA1541, size);
driver_to_use_e
use WDM driver or NT4 driver
struct cbm_install_parameter_plugin_s cbm_install_parameter_plugin_t
struct xa1541_parameter_s xa1541_parameter_t
The parameter which are given on the command-line.
BOOL CbmCheckPresence(IN LPCTSTR DriverName)
Check for the presence of the driver.
Define makros for debugging purposes.
enum driver_to_use_e driver_to_use_t
use WDM driver or NT4 driver
struct CbmPluginInstallProcessCommandlineData_s CbmPluginInstallProcessCommandlineData_t
void cbmlibmisc_strfree(const char *String)
Free a string.
enum iec_cabletype IEC_CABLETYPE
#define OPENCBM_DRIVERNAME
BOOL CBMAPIDECL opencbm_plugin_install_do_uninstall(void *Context)
@@@
Define the IOCTL codes for the opencbm driver.
BOOL CbmRemove(IN LPCTSTR DriverName)
Remove the driver.
#define FUNC_LEAVE_UINT(_xxx)
unsigned int CBMAPIDECL opencbm_plugin_install_get_needed_files(CbmPluginInstallProcessCommandlineData_t *Data, opencbm_plugin_install_neededfiles_t *Destination)
@@@
BOOL AutomaticOrOnDemandStart
#define FUNC_LEAVE_BOOL(_xxx)
char * cbmlibmisc_strcat(const char *First, const char *Second)
Concatenate two strings.
unsigned int CBMAPIDECL opencbm_plugin_install_process_commandline(CbmPluginInstallProcessCommandlineData_t *Data)
@@@
Defining OpenCBM version.
BOOL CbmInstall(IN LPCTSTR DriverName, IN LPCTSTR ServiceExe, IN BOOL AutomaticStart)
Install the driver.
int CbmCheckDriver(void)
Check for the correct installation.
BOOL CBMAPIDECL opencbm_plugin_install_do_install(void *Context)
@@@
Internal API for opencbm installation.
Some functions for string handling.
The parameter which are given on the command-line.
IEC_CABLETYPE IecCableType