2 ** AddUSBHardware by Chris Hodges <chrisly@platon42.de>
10 #include <dos/dosextens.h>
11 #include <dos/datetime.h>
12 #include <dos/exall.h>
13 #include <libraries/poseidon.h>
14 #include <proto/poseidon.h>
15 #include <proto/exec.h>
16 #include <proto/dos.h>
25 static const char *template = "DEVICE,UNIT/N,QUIET/S,REMOVE/S,ALL/S";
26 const char *version
= "$VER: AddUSBHardware 1.7 (03.06.09) by Chris Hodges <chrisly@platon42.de>";
27 static IPTR ArgsArray
[ARGS_SIZEOF
];
28 static struct RDArgs
*ArgsHook
= NULL
;
30 //extern struct DOSBase *DOSBase;
47 int main(int argc
, char *argv
[])
55 STRPTR devname
= NULL
;
59 if(!(ArgsHook
= ReadArgs(template, ArgsArray
, NULL
)))
61 fail("Wrong arguments!\n");
64 if((!ArgsArray
[ARGS_DEVICE
]) && (!(ArgsArray
[ARGS_REMOVE
] && ArgsArray
[ARGS_ALL
])))
66 fail("DEVICE argument is mandatory except for REMOVE ALL!\n");
69 if((ps
= OpenLibrary("poseidon.library", 4)))
72 if(ArgsArray
[ARGS_DEVICE
])
74 devname
= (STRPTR
) ArgsArray
[ARGS_DEVICE
];
76 if(ArgsArray
[ARGS_UNIT
])
78 unit
= *((ULONG
*) ArgsArray
[ARGS_UNIT
]);
80 if(ArgsArray
[ARGS_REMOVE
])
85 psdGetAttrs(PGA_STACK
, NULL
, PA_HardwareList
, &phwlist
, TAG_END
);
86 phw
= phwlist
->lh_Head
;
87 while((next
= phw
->ln_Succ
))
89 psdGetAttrs(PGA_HARDWARE
, phw
,
90 HA_DeviceName
, &cmpdevname
,
91 HA_DeviceUnit
, &cmpunit
,
93 if(ArgsArray
[ARGS_ALL
] || ((!stricmp(FilePart(cmpdevname
), FilePart(devname
))) && (cmpunit
== unit
)))
95 if(!ArgsArray
[ARGS_QUIET
])
97 Printf("Removing hardware %s, unit %ld...\n", cmpdevname
, cmpunit
);
106 } while(ArgsArray
[ARGS_ALL
] && next
);
111 if(!ArgsArray
[ARGS_QUIET
])
113 Printf("Adding hardware %s, unit %ld...", devname
, unit
);
115 if((phw
= psdAddHardware(devname
, unit
)))
117 if(!ArgsArray
[ARGS_QUIET
])
119 if(psdEnumerateHardware(phw
))
123 PutStr("enumeration failed!\n");
126 psdEnumerateHardware(phw
);
129 if(!ArgsArray
[ARGS_QUIET
])
137 } while(ArgsArray
[ARGS_ALL
]);
142 errmsg
= "Unable to open poseidon.library\n";
145 return(0); // never gets here, just to shut the compiler up