25 void rwHeadAccess(SECTNUM physical
, SECTNUM logical
, BOOL write
)
27 /* display the physical sector, the logical block, and if the access is read or write */
29 fprintf(stderr
, "phy %ld / log %ld : %c\n", (long)physical
, (long)logical
, write
? 'W' : 'R');
32 void progressBar(int perCentDone
)
34 fprintf(stderr
,"%d %% done\n",perCentDone
);
37 void Warning(char* msg
) {
38 fprintf(stderr
,"Warning <%s>\n",msg
);
41 void Error(char* msg
) {
42 fprintf(stderr
,"Error <%s>\n",msg
);
46 void Verbose(char* msg
) {
47 fprintf(stderr
,"Verbose <%s>\n",msg
);
50 void Changed(SECTNUM nSect
, int changedType
)
52 /* switch(changedType) {
54 fprintf(stderr,"Notification : sector %ld (FILE)\n",nSect);
57 fprintf(stderr,"Notification : sector %ld (DIR)\n",nSect);
60 fprintf(stderr,"Notification : sector %ld (ROOT)\n",nSect);
63 fprintf(stderr,"Notification : sector %ld (???)\n",nSect);
71 void adfEnvInitDefault()
76 /* internal checking */
79 { fprintf(stderr
,"Compilation error : sizeof(UBYTE)!=1\n"); exit(1); }
80 if (sizeof(USHORT
)!=2)
81 { fprintf(stderr
,"Compilation error : sizeof(USHORT)!=2\n"); exit(1); }
83 { fprintf(stderr
,"Compilation error : sizeof(ULONG)!=4\n"); exit(1); }
84 if (sizeof(struct bEntryBlock
)!=512)
85 { fprintf(stderr
,"Internal error : sizeof(struct bEntryBlock)!=512\n"); exit(1); }
86 if (sizeof(struct bRootBlock
)!=512)
87 { fprintf(stderr
,"Internal error : sizeof(struct bRootBlock)!=512\n"); exit(1); }
88 if (sizeof(struct bDirBlock
)!=512)
89 { fprintf(stderr
,"Internal error : sizeof(struct bDirBlock)!=512\n"); exit(1); }
90 if (sizeof(struct bBootBlock
)!=1024)
91 { fprintf(stderr
,"Internal error : sizeof(struct bBootBlock)!=1024\n"); exit(1); }
92 if (sizeof(struct bFileHeaderBlock
)!=512)
93 { fprintf(stderr
,"Internal error : sizeof(struct bFileHeaderBlock)!=512\n"); exit(1); }
94 if (sizeof(struct bFileExtBlock
)!=512)
95 { fprintf(stderr
,"Internal error : sizeof(struct bFileExtBlock)!=512\n"); exit(1); }
96 if (sizeof(struct bOFSDataBlock
)!=512)
97 { fprintf(stderr
,"Internal error : sizeof(struct bOFSDataBlock)!=512\n"); exit(1); }
98 if (sizeof(struct bBitmapBlock
)!=512)
99 { fprintf(stderr
,"Internal error : sizeof(struct bBitmapBlock)!=512\n"); exit(1); }
100 if (sizeof(struct bBitmapExtBlock
)!=512)
101 { fprintf(stderr
,"Internal error : sizeof(struct bBitmapExtBlock)!=512\n"); exit(1); }
102 if (sizeof(struct bLinkBlock
)!=512)
103 { fprintf(stderr
,"Internal error : sizeof(struct bLinkBlock)!=512\n"); exit(1); }
106 /* if LITT_ENDIAN not defined : must be BIG endian */
108 if (val
.c
[3]!=1) /* little endian : LITT_ENDIAN must be defined ! */
109 { fprintf(stderr
,"Compilation error : #define LITT_ENDIAN must exist\n"); exit(1); }
111 if (val
.c
[3]==1) /* big endian : LITT_ENDIAN must not be defined ! */
112 { fprintf(stderr
,"Compilation error : #define LITT_ENDIAN must not exist\n"); exit(1); }
115 adfEnv
.wFct
= Warning
;
117 adfEnv
.vFct
= Verbose
;
118 adfEnv
.notifyFct
= Changed
;
119 adfEnv
.rwhAccess
= rwHeadAccess
;
120 adfEnv
.progressBar
= progressBar
;
122 adfEnv
.useDirCache
= FALSE
;
123 adfEnv
.useRWAccess
= FALSE
;
124 adfEnv
.useNotify
= FALSE
;
125 adfEnv
.useProgressBar
= FALSE
;
127 /* sprintf(str,"ADFlib %s (%s)",adfGetVersionNumber(),adfGetVersionDate());
130 adfEnv
.nativeFct
=(struct nativeFunctions
*)malloc(sizeof(struct nativeFunctions
));
131 if (!adfEnv
.nativeFct
) (*adfEnv
.wFct
)("adfInitDefaultEnv : malloc");
143 free(adfEnv
.nativeFct
);
151 void adfChgEnvProp(int prop
, void *new)
158 adfEnv
.vFct
= (void(*)(char*))new;
161 adfEnv
.wFct
= (void(*)(char*))new;
164 adfEnv
.eFct
= (void(*)(char*))new;
167 adfEnv
.notifyFct
= (void(*)(SECTNUM
,int))new;
170 newBool
= (BOOL
*)new;
171 adfEnv
.useNotify
= *newBool
;
174 adfEnv
.progressBar
= (void(*)(int))new;
177 newBool
= (BOOL
*)new;
178 adfEnv
.useProgressBar
= *newBool
;
180 case PR_USE_RWACCESS
:
181 newBool
= (BOOL
*)new;
182 adfEnv
.useRWAccess
= *newBool
;
185 adfEnv
.rwhAccess
= (void(*)(SECTNUM
,SECTNUM
,BOOL
))new;
188 newBool
= (BOOL
*)new;
189 adfEnv
.useDirCache
= *newBool
;
198 void adfSetEnvFct( void(*eFct
)(char*), void(*wFct
)(char*), void(*vFct
)(char*),
199 void(*notFct
)(SECTNUM
,int) )
208 adfEnv
.notifyFct
= *notFct
;
213 * adfGetVersionNumber
216 char* adfGetVersionNumber()
218 return(ADFLIB_VERSION
);
226 char* adfGetVersionDate()
234 /*##################################################################################*/