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 #define CLASSPATH "SYS:Classes/USB"
23 #define CLASSNAMEMAX 128
25 static const char *template = "QUIET/S,REMOVE/S";
26 const char *version
= "$VER: AddUSBClasses 1.8 (24.05.2017) © The AROS Development Team";
27 static IPTR ArgsArray
[ARGS_SIZEOF
];
28 static struct RDArgs
*ArgsHook
= NULL
;
45 int main(int argc
, char *argv
[])
49 struct ExAllControl
*exall
;
50 struct ExAllData
*exdata
;
54 UBYTE sbuf
[CLASSNAMEMAX
];
58 BOOL exready
, isvalid
;
60 if(!(ArgsHook
= ReadArgs(template, ArgsArray
, NULL
)))
62 fail("Wrong arguments!\n");
65 if((ps
= OpenLibrary("poseidon.library", 4)))
67 if(ArgsArray
[ARGS_REMOVE
])
70 psdGetAttrs(PGA_STACK
, NULL
, PA_ClassList
, &puclist
, TAG_END
);
71 while(puclist
->lh_Head
->ln_Succ
)
73 if(!ArgsArray
[ARGS_QUIET
])
75 Printf("Removing class %s...\n", puclist
->lh_Head
->ln_Name
);
78 psdRemClass(puclist
->lh_Head
);
83 if((exall
= AllocDosObject(DOS_EXALLCONTROL
, NULL
)))
85 lock
= Lock(CLASSPATH
, ACCESS_READ
);
88 exall
->eac_LastKey
= 0;
89 exall
->eac_MatchString
= NULL
;
90 exall
->eac_MatchFunc
= NULL
;
93 exready
= ExAll(lock
, (struct ExAllData
*) buf
, 1024, ED_NAME
, exall
);
94 exdata
= (struct ExAllData
*) buf
;
95 ents
= exall
->eac_Entries
;
99 psdSafeRawDoFmt(sbuf
, CLASSNAMEMAX
, CLASSPATH
"/%s", exdata
->ed_Name
);
100 namelen
= strlen(sbuf
);
101 if (((namelen
> 4) && (!strcmp(&sbuf
[namelen
-4], ".dbg"))) || ((namelen
> 5) && (!strcmp(&sbuf
[namelen
-5], ".info"))))
107 if(!strcmp(&sbuf
[namelen
-4], ".elf"))
112 psdGetAttrs(PGA_STACK
, NULL
, PA_ClassList
, &puclist
, TAG_END
);
114 puc
= puclist
->lh_Head
;
117 if(!strncmp(puc
->ln_Name
, exdata
->ed_Name
, strlen(puc
->ln_Name
)))
126 if(!ArgsArray
[ARGS_QUIET
])
128 Printf("Skipping class %s...\n", exdata
->ed_Name
);
130 exdata
= exdata
->ed_Next
;
135 if(!ArgsArray
[ARGS_QUIET
])
137 Printf("Adding class %s...", exdata
->ed_Name
);
139 if(psdAddClass(sbuf
, 0))
141 if(!ArgsArray
[ARGS_QUIET
])
146 if(!ArgsArray
[ARGS_QUIET
])
152 exdata
= exdata
->ed_Next
;
158 errmsg
= "Failed to lock " CLASSPATH
".\n";
160 FreeDosObject(DOS_EXALLCONTROL
, exall
);
165 errmsg
= "Unable to open poseidon.library\n";
168 return(0); // never gets here, just to shut the compiler up