home *** CD-ROM | disk | FTP | other *** search
- /*
- * MakeDict © Dirk Holtwick, 1996
- *
- * Creates DICT files from VOC files that allow
- * a faster and less memory using access to a
- * vocabulary database
- */
-
- /// INCLUDES & DEFS
- #include <stdio.h>
- #include <stdlib.h>
-
- #include <proto/exec.h>
- #include <proto/dito.h>
-
- struct Library *DitoBase;
- ///
-
- /// HandleDITOError()
-
- // Easy routine for error handling
- int HandleDITOError(int error){
- switch(error){
- case DITO_Error_FileNotFound:
- puts("File not found!");
- break;
- case DITO_Error_NoDitoDatabase:
- puts("No DITO Database!");
- break;
- case DITO_Error_WrongLanguage:
- puts("Wrong Language!");
- break;
- case DITO_Error_Memory:
- puts("Not enough memory!");
- break;
- }
- return(error);
- }
- ///
- /// Main()
-
- // Main program
- main(int argc, char *argv[]){
- struct DITO_UserInfo ui;
- struct DITO_Database *data;
-
- if(argc==3)
- {
- if(DitoBase = OpenLibrary(DITO_NAME, DITO_VMIN))
- {
- // You have to create a database before adding or
- // loading entries to the structure. Do not try to
- // init the structure by yourself!
-
- DITO_GetUserInfo(&ui);
-
- if(ui.nr) printf("You are the registred user: %s, #%d\n\n",ui.name,ui.nr);
- else puts("You are not registred. Please do it!\n");
-
- if(data = DITO_CreateDatabase())
- {
-
- // You may now add entries to the database, e.g.
- // with DITO_LoadDatabase()
-
- printf("Loading '%s' ...\n",argv[1]);
-
- if(!HandleDITOError(DITO_LoadDatabase(data,argv[1])))
- {
-
- // Save as DITO Dictionary for faster data access and
- // less memory use
-
- printf("Saving as '%s' ...\n", argv[2]);
-
- DITO_SaveDatabase (data, argv[2], DITO_Save_Dict);
-
- puts("Finished.");
- }
-
- // Do not forget to dispose the DITO_Database!
-
- DITO_DisposeDatabase(data);
- }
-
- CloseLibrary(DitoBase);
- }
- else puts("Couldn't open actual version of dito.library.");
- }
- else puts("USAGE: MakeDict [input.voc] [output.dict]");
- }
- ///
-