Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / tools / adflib / Generic / adf_nativ.c
blob45ea3a3e10b91c6ae63c926b475a5223b98912f6
1 /*
2 * adf_nativ.c
4 * file
5 */
7 #include<stdio.h>
8 #include<stdlib.h>
9 #include<string.h>
10 #include"adf_str.h"
11 #include"adf_nativ.h"
12 #include"adf_err.h"
14 extern struct Env adfEnv;
17 * myInitDevice
19 * must fill 'dev->size'
21 RETCODE myInitDevice(struct Device* dev, char* name,BOOL ro)
23 struct nativeDevice* nDev;
25 nDev = (struct nativeDevice*)dev->nativeDev;
27 nDev = (struct nativeDevice*)malloc(sizeof(struct nativeDevice));
28 if (!nDev) {
29 (*adfEnv.eFct)("myInitDevice : malloc");
30 return RC_ERROR;
32 dev->nativeDev = nDev;
33 if (!ro)
34 /* check if device is writable, if not, force readOnly to TRUE */
35 dev->readOnly = FALSE;
36 else
37 /* mount device as read only */
38 dev->readOnly = TRUE;
40 dev->size = 0;
42 return RC_OK;
47 * myReadSector
50 RETCODE myReadSector(struct Device *dev, long n, int size, unsigned char* buf)
52 return RC_OK;
57 * myWriteSector
60 RETCODE myWriteSector(struct Device *dev, long n, int size, unsigned char* buf)
62 return RC_OK;
67 * myReleaseDevice
69 * free native device
71 RETCODE myReleaseDevice(struct Device *dev)
73 struct nativeDevice* nDev;
75 nDev = (struct nativeDevice*)dev->nativeDev;
77 free(nDev);
79 return RC_OK;
84 * adfInitNativeFct
87 void adfInitNativeFct()
89 struct nativeFunctions *nFct;
91 nFct = (struct nativeFunctions*)adfEnv.nativeFct;
93 nFct->adfInitDevice = myInitDevice ;
94 nFct->adfNativeReadSector = myReadSector ;
95 nFct->adfNativeWriteSector = myWriteSector ;
96 nFct->adfReleaseDevice = myReleaseDevice ;
97 nFct->adfIsDevNative = myIsDevNative;
102 * myIsDevNative
105 BOOL myIsDevNative(char *devName)
107 return (strncmp(devName,"/xxx/",5)==0);
109 /*##########################################################################*/