2 ** AddUSBClasses 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>
22 static const char *template = "QUIET/S,REMOVE/S";
23 const char *version
= "$VER: AddUSBClasses 1.7 (03.06.09) by Chris Hodges <chrisly@platon42.de>";
24 static IPTR ArgsArray
[ARGS_SIZEOF
];
25 static struct RDArgs
*ArgsHook
= NULL
;
42 int main(int argc
, char *argv
[])
45 struct ExAllControl
*exall
;
48 struct ExAllData
*exdata
;
58 if(!(ArgsHook
= ReadArgs(template, ArgsArray
, NULL
)))
60 fail("Wrong arguments!\n");
63 if((ps
= OpenLibrary("poseidon.library", 4)))
65 if(ArgsArray
[ARGS_REMOVE
])
68 psdGetAttrs(PGA_STACK
, NULL
, PA_ClassList
, &puclist
, TAG_END
);
69 while(puclist
->lh_Head
->ln_Succ
)
71 if(!ArgsArray
[ARGS_QUIET
])
73 Printf("Removing class %s...\n", puclist
->lh_Head
->ln_Name
);
76 psdRemClass(puclist
->lh_Head
);
81 if((exall
= AllocDosObject(DOS_EXALLCONTROL
, NULL
)))
83 classpath
= "SYS:Classes/USB";
84 lock
= Lock(classpath
, ACCESS_READ
);
87 exall
->eac_LastKey
= 0;
88 exall
->eac_MatchString
= NULL
;
89 exall
->eac_MatchFunc
= NULL
;
92 exready
= ExAll(lock
, (struct ExAllData
*) buf
, 1024, ED_NAME
, exall
);
93 exdata
= (struct ExAllData
*) buf
;
94 ents
= exall
->eac_Entries
;
97 sbuf
= psdCopyStrFmt("%s/%s", classpath
, exdata
->ed_Name
);
102 namelen
= strlen(sbuf
);
105 if(!strcmp(&sbuf
[namelen
-4], ".elf"))
110 psdGetAttrs(PGA_STACK
, NULL
, PA_ClassList
, &puclist
, TAG_END
);
112 puc
= puclist
->lh_Head
;
115 if(!strncmp(puc
->ln_Name
, exdata
->ed_Name
, strlen(puc
->ln_Name
)))
124 if(!ArgsArray
[ARGS_QUIET
])
126 Printf("Skipping class %s...\n", exdata
->ed_Name
);
128 exdata
= exdata
->ed_Next
;
133 if(!ArgsArray
[ARGS_QUIET
])
135 Printf("Adding class %s...", exdata
->ed_Name
);
137 if(psdAddClass(sbuf
, 0))
139 if(!ArgsArray
[ARGS_QUIET
])
144 if(!ArgsArray
[ARGS_QUIET
])
150 exdata
= exdata
->ed_Next
;
156 errmsg
= "Could not lock on SYS:Classes/USB.\n";
158 FreeDosObject(DOS_EXALLCONTROL
, exall
);
163 errmsg
= "Unable to open poseidon.library\n";
166 return(0); // never gets here, just to shut the compiler up