OSDN Git Service

client 0.5.3 release
[unagi/old-svn-converted.git] / client / tag / 0.5.3 / reader_master.c
diff --git a/client/tag/0.5.3/reader_master.c b/client/tag/0.5.3/reader_master.c
new file mode 100644 (file)
index 0000000..1a8e4c8
--- /dev/null
@@ -0,0 +1,50 @@
+#include <assert.h>
+#include <string.h>
+#include "giveio.h"
+#include "reader_master.h"
+#include "reader_onajimi.h"
+#include "reader_hongkongfc.h"
+
+//¤³¤ì¤ò rodata ¤Ë¤·¤¿¤¤¤±¤É const ¤ÎÉÕ¤±Êý¤¬Ê¬¤«¤é¤ó
+static const struct reader_driver *DRIVER_LIST[] = {
+       &DRIVER_ONAJIMI, &DRIVER_HONGKONGFC,
+       NULL
+};
+
+int paralellport_open_or_close(int oc)
+{
+       static int giveio_status;
+       if(oc == READER_OPEN){
+               giveio_status = giveio_start();
+               switch(giveio_status){
+               case GIVEIO_OPEN:
+               case GIVEIO_START:
+               case GIVEIO_WIN95:
+                       break;
+               default:
+               case GIVEIO_ERROR:
+                       //printf("%s Can't Access Direct IO %d\n", __FILE__, giveio_status);
+                       return NG;
+               }
+       }else if(oc == READER_CLOSE){
+               if(giveio_status != GIVEIO_WIN95){
+                       giveio_stop(GIVEIO_STOP);
+               }
+       }else{
+               assert(0);
+       }
+       return OK;
+}
+
+const struct reader_driver *reader_driver_get(const char *name)
+{
+       const struct reader_driver **d;
+       d = DRIVER_LIST;
+       while(*d != NULL){
+               if(strcmp(name, (*d)->name) == 0){
+                       return *d;
+               }
+               d++;
+       }
+       return NULL;
+}