home *** CD-ROM | disk | FTP | other *** search
- /* Diavolo API Test */
-
- /*
-
- This file is meant as an example for programming the Diavolo Application Programming
- Interface.
-
- It contains a frame of routines which you can use in your own application.
-
- You will also find a sequence of commands send to Diavolo (in main()) which I used
- to test the API. Use them as an example how they work. They will most likely NOT
- work on your system as I used names and paths only valid on my machine. But if
- you want to test a specific command, just comment out the not needed commands and
- correct the parameters as needed on your system. Then you can compile this source
- and start the resulting program.
-
- This source was written and tested using SAS/C 6.51.
- Nested comments and C++-style comments must be enabled to compile the file correctly.
-
- For a detailed documentation of the API see DiavoloAPI.h and DiavoloPrefs.h.
-
-
- If you want to print this file, set your printer to 136 characters per line (condensed font).
-
-
- © 1995 Martin Korndörfer.
-
- */
-
- /* *********************************************************************** */
- /* *********************************************************************** */
- /* */
- /* Includes */
- /* */
- /* *********************************************************************** */
- /* *********************************************************************** */
-
-
- #include <clib/locale_protos.h> /* Contains all prototypes for Amiga functions. May
- have a different name when using another compiler */
-
-
- #include <dos/dos.h>
- #include <exec/exec.h>
- #include <stdio.h>
- #include <string.h>
-
- #include "sas:Diavolo/DiavoloPrefs.h" /* Contains documented preference structure and constants */
- #include "sas:Diavolo/DiavoloAPI.h" /* Structures, constants and documentation of Diavolo API */
-
-
-
- /* *********************************************************************** */
- /* *********************************************************************** */
- /* */
- /* Global variables */
- /* */
- /* *********************************************************************** */
- /* *********************************************************************** */
-
- struct MsgPort *MyReplyPort; /* Global Reply Port. Will be used by Diavolo to send its
- messages to the client */
-
- struct MsgPort *APIPort; /* API Port of Diavolo Backup. Global message port which
- must be used to send messages to Diavolo */
-
- BOOL Quit; /* TRUE: Quit requested by Diavolo */
-
-
- /* *********************************************************************** */
- /* *********************************************************************** */
- /* */
- /* Forward function declarations */
- /* */
- /* *********************************************************************** */
- /* *********************************************************************** */
-
-
- void CheckDAPIMsg(struct DiavoloAPIMsg *APIMsg);
-
-
- /* *********************************************************************** */
- /* *********************************************************************** */
- /* */
- /* Frame functions, use them in your code */
- /* */
- /* *********************************************************************** */
- /* *********************************************************************** */
-
- void CheckRequest(struct DiavoloAPIMsg *APIMsg)
-
- /* Will be used to process incoming request messages. After a client has made contact with
- Diavolo, before a requester is displayed to the user, a message will be sent to the client.
- The client can answer this request itself, so the user never sees the request, or make Diavolo
- display the request as normal. Anyway, the client MUST reply the request as fast as possible,
- so the message port must be always watched for incoming messages. If the client does not reply
- a message, there could be a deadlock (Diavolo waiting for client and client waiting for
- Diavolo).
-
- Modify this routine to customize the clients reaction to requesters. Look at the DAPI_RC_...
- defines at the end of DiavoloAPI.h for all possible request codes and their meaning.
-
- */
-
- {
- ULONG RetVal;
-
-
- /* At first the client displays the requester text. This is just for testing and
- should not be used in a final client application - at least not THIS way. */
-
- printf("Title: %s\n",APIMsg->DAPI_Ptr1);
- printf("Body:\n%s\n",APIMsg->DAPI_Ptr2);
- printf("Gadgets: %s\n",APIMsg->DAPI_Ptr3);
- printf("Code: %ld\n",APIMsg->DAPI_Arg1);
-
-
- /* This switch/case statement decides what to do with the requester. */
-
- switch(APIMsg->DAPI_Arg1)
- {
- /* The following requests shall not be displayed to the user. Instead Diavolo should
- react as if the user presses RETRY. */
-
- case DAPI_RC_INSERTDISK: /* Insert disk in any drive... */
- case DAPI_RC_INSERTDIRDISK: /* Insert first disk in any drive. */
- case DAPI_RC_BACKDISK: /* This disk contains another backup... */
- case DAPI_RC_DOSDISK: /* This disk is DOS formatted ... */
- case DAPI_RC_ALIENTAPE: /* This tape contains unreadable data or is empty ... */
-
- RetVal = 1; /* RetVal will be used as a replycode to Diavolo.
- 1 means the leftmost option, RETRY in these cases. */
- break;
-
- default: /* In all other cases... */
-
- RetVal = ~0; /* A RetVal of ~0 (bitwise NOT 0, in other words all bits set)
- means that Diavolo should display the requester as normal */
- }
-
- APIMsg->DAPI_Arg1 = RetVal; /* Return the message with RetVal set in Arg1 */
- ReplyMsg(APIMsg);
- }
-
-
-
-
- void CheckDAPIMsg(struct DiavoloAPIMsg *APIMsg)
-
- /* Check incoming messages. */
-
- {
- if(APIMsg->DAPI_Message.mn_Node.ln_Type == NT_REPLYMSG)
- /* The received message was a reply. Normally replies will only be received after you've sended
- a message to Diavolo in the first place. This example is written in a way that every
- routine knows its sent messages and handles its replies itself, so this generic routine
- should never has to handle replies. */
- {
- printf("Reply received. Don't know original message. ERROR!\n");
- }
-
- else
- {
- /* What kind of message is this? */
-
- switch(APIMsg->DAPI_Command)
- {
- case DAPI_REQUEST:
- /* Diavolo has a request. CheckRequest (see above) handles them */
- CheckRequest(APIMsg);
- break;
-
- case DAPI_CLOSEDOWN:
- /* Diavolo is closing down. The client is informed that it has to cut down
- the link to Diavolo, so it can complete the closedown. */
-
- Quit = TRUE; /* Set global Quit flag to TRUE */
- ReplyMsg(APIMsg); /* Return message */
- break;
-
- default:
- /* Another - unknown - message has arrived. Diavolo only sends the two
- messages handled above or replies. */
-
- printf("Unknown message. Command: %lx\n",APIMsg->DAPI_Command);
- ReplyMsg(APIMsg);
- break;
- }
- }
- }
-
-
-
- BOOL DoCommand(struct DiavoloAPIMsg *APIMsg)
-
- /* Send a command to Diavolo and wait for its completion (its reply).
-
- This routine handles all incoming message (also requests) and waits until the command
- was replied.
-
- Use this for all commands you want to send synchronously (which should be most). You
- cannot use them for asynchronous command, which are used to initiate an operation.
- These are DAPI_STARTBACKUP, DAPI_STARTSCAN and DAPI_STARTRESTORE. Use seperate
- routines for these commands (see below).
-
- The parameter APIMsg must be filled with the correct parameters you want to send to
- Diavolo (also the command code itself). After the routine replies you can find the
- result codes set by Diavolo in the same structure.
- */
-
- {
- struct DiavoloAPIMsg *Reply;
- BOOL Ok;
-
- /* Set Replyport of the message to send to the global client message port */
- APIMsg->DAPI_Message.mn_ReplyPort = MyReplyPort;
-
- /* Send the message to Diavolo's API Port */
- PutMsg(APIPort, APIMsg);
-
- do
- {
- /* This is a generic method of waiting for a message. If you want to check more
- than one message port, you'll have to add more bits to the Wait() mask. */
-
- while(! (Reply = (struct DiavoloAPIMsg *)GetMsg(MyReplyPort)))
- Wait(1l << MyReplyPort->mp_SigBit);
-
-
- if(Reply->DAPI_Message.mn_Node.ln_Type != NT_REPLYMSG || Reply != APIMsg)
- {
- /* The received message wasn't the reply for our own message, so process it */
-
- CheckDAPIMsg(Reply);
- Reply = NULL; /* No, we're not finished yet */
- }
- else
- {
- /* Our message has been replied. Fine, now look if there was an error
- set in the reply: */
-
- switch(Reply->DAPI_Errorcode)
- {
- case DAPI_EC_NOERROR:
- /* Everything was fine! */
-
- printf("Reply: No error!\n");
- Ok = TRUE;
- break;
-
- case DAPI_EC_INUSE:
- /* Diavolo's messageport is in use by another application */
-
- printf("Reply: In Use error\n");
- Ok = FALSE;
- break;
-
- case DAPI_EC_NOTAVAILABLE:
- /* The sent command is not available at this moment or entirely unknown */
-
- printf("Reply: Command not available!\n");
- Ok = FALSE;
- break;
-
- case DAPI_EC_NOTMETYET:
- /* You have not intiated the dialogue using DAPI_RENDEZVOUS yet */
-
- printf("Reply: Programs not met yet!\n");
- Ok = FALSE;
- break;
-
- case DAPI_EC_INVALIDCONFIG:
- /* The new configuration was invalid */
-
- printf("Reply: Invalid config!\n");
- Ok = FALSE;
- break;
-
- case DAPI_EC_SELECTFAILED:
- /* The selection (in DAPI_BACKSELECT and DAPI_RESTSELECT) failed */
-
- printf("Reply: Selection failed. Code: %ld!\n", Reply->DAPI_Arg1);
- Ok = FALSE;
- break;
-
- case DAPI_EC_OPPENDING:
- /* You cannot cut the connection (using DAPI_GOODBYE) while a client
- intiated operation is in progress. Cancel the operation first! */
-
- printf("Reply: Operation pending, Goodbye not possible!\n");
- Ok = FALSE;
- break;
-
- case DAPI_EC_OPFAILED:
- /* The oepration failed */
-
- printf("Reply: Operation failed, Code: %ld!\n",Reply->DAPI_Arg1);
- Ok = FALSE;
- break;
-
- default:
- printf("Unknown errorcode: %ld\n",Reply->DAPI_Errorcode);
- Ok = FALSE;
- }
- }
- }
- while(Reply == NULL);
- return(Ok);
- }
-
-
-
- void WaitForCompletion(struct DiavoloAPIMsg *OpMsg)
-
- /* This routine can be used by any asynchronous request to wait for its completion.
-
- In this program, it's used by DoBackup(), DoScan() and DoRestore(). It's not
- very smart, but it shows an example how to use DAPI_INQUIRY while the operation
- is in progress, to get a status report of the operation.
-
- In a real application you shouldn't use Delay() of course!
-
- The parameter is the message sent to intitiate the operation (and this routine is
- supposed to wait for).
- */
-
- {
- struct DiavoloAPIMsg APIMsg, *RepMsg;
- int z1;
- BOOL Ende;
- struct DiavoloInquiry DI;
-
- z1 = 0;
- do
- {
- /* Wait for a short moment, to avoid 100% cpu usage
-
- THIS IS BAD STYLE!
-
- It's only a simple example, to show how DAPI_INQUIRY can be used while the
- client is waiting for the reply.
-
- A real application would use timer.device events instead */
- Delay(10);
-
-
- Ende = FALSE;
-
- while(RepMsg = (struct DiavoloAPIMsg *)GetMsg(OpMsg->DAPI_Message.mn_ReplyPort))
- {
- if(RepMsg == OpMsg)
- {
- /* The operation command was replied. The operation has been finished, either
- because it was completed or aborted */
-
- printf("Backup complete! Errorcode: %ld, Arg1: %ld, Arg2: %ld, Arg3: %ld\n",RepMsg->DAPI_Errorcode,
- RepMsg->DAPI_Arg1, RepMsg->DAPI_Arg2, RepMsg->DAPI_Arg3);
- Ende = TRUE;
- }
- }
-
- if(z1 == 25)
- {
- /* Every 25th loop iteration, send DAPI_INQUIRY */
-
- z1 = 0; /* Reset loop counter */
-
- /* Send DAPI_INQUIRY. Arg1 has to be set to the size of your buffer and Ptr1 must point
- to the beginning of your buffer */
-
- APIMsg.DAPI_Command = DAPI_INQUIRY;
- APIMsg.DAPI_Arg1 = sizeof(struct DiavoloInquiry);
- APIMsg.DAPI_Ptr1 = &DI;
- DoCommand(&APIMsg);
-
-
- /* Show some of the values returned by DAPI_INQUIRY in the CLI */
-
- printf("Status: %ld, Medium: %ld\n",DI.DAPI_ActualStatus, DI.DAPI_BackupMedium);
- printf("Name: %s, ID: %lx, Size: %ld, Files: %ld, Dirs: %ld, Volumes: %ld\n",DI.DAPI_BackName,DI.DAPI_ID,
- DI.DAPI_BackSize,DI.DAPI_BackFiles,DI.DAPI_BackDirs,DI.DAPI_BackVolumes);
- printf("Current Dir: %s, Current File: %s\n",DI.DAPI_File, DI.DAPI_Dir);
- printf("ActFile: %ld, ActDir: %ld, ActByte: %ld Written: %ld\n",DI.DAPI_FileCount,DI.DAPI_DirCount,DI.DAPI_ByteCount,DI.DAPI_Written);
- printf("Unpacked: %ld, Packed: %ld\n",DI.DAPI_Unpacked, DI.DAPI_Packed);
- printf("DiskStatus: 1: %d, 2: %d, 3: %d, 4: %d\n",DI.DAPI_DiskStatus[0],DI.DAPI_DiskStatus[1],DI.DAPI_DiskStatus[2],DI.DAPI_DiskStatus[3]);
- printf("DiskTrack: 1: %d, 2: %d, 3: %d, 4: %d\n",DI.DAPI_DiskTrack[0],DI.DAPI_DiskTrack[1],DI.DAPI_DiskTrack[2],DI.DAPI_DiskTrack[3]);
- printf("DiskSize: 1: %d, 2: %d, 3: %d, 4: %d\n",DI.DAPI_DiskSize[0],DI.DAPI_DiskSize[1],DI.DAPI_DiskSize[2],DI.DAPI_DiskSize[3]);
- printf("DisksDone: %ld\n",DI.DAPI_DisksDone);
- }
- else
- {
- z1++; /* Increment loop counter */
-
-
- /* Check the global client message port for messages sent by Diavolo. */
-
- if(RepMsg = (struct DiavoloAPIMsg *)GetMsg(MyReplyPort))
- CheckDAPIMsg(RepMsg);
- }
- }
- while(! Ende);
- }
-
-
- void DoBackup(void)
-
- /* This routine starts a backup procedure asynchronously. */
-
- {
- struct DiavoloAPIMsg APIMsg, BackupMsg;
- struct MsgPort *BackReplyPort;
-
- /* To make things easier, I create my own message port to receive the reply of the
- backup command */
-
- if(! (BackReplyPort = CreateMsgPort()))
- {
- printf("Error creating own message port!\n");
- return;
- }
-
- BackupMsg.DAPI_Message.mn_ReplyPort = BackReplyPort;
- BackupMsg.DAPI_Command = DAPI_STARTBACKUP;
- BackupMsg.DAPI_Arg1 = TRUE; /* Use PW */
- BackupMsg.DAPI_Arg2 = FALSE; /* Encode data */
- BackupMsg.DAPI_Arg3 = 0; /* Ask user */
-
- BackupMsg.DAPI_Ptr1 = "Automatische Sicherung von API Test";
- BackupMsg.DAPI_Ptr2 = "Passwort";
-
- printf("Starting backup\n");
- PutMsg(APIPort,&BackupMsg);
-
-
- /* After the backup has been started, unlock the UserInterface. Since the
- backup procedure is asynchronous, we can do that AFTER the backup has
- been started, otherwise it would have to be done before starting it. */
-
- printf("Unlocking UI\n");
- APIMsg.DAPI_Command = DAPI_LOCKUI;
- APIMsg.DAPI_Arg1 = FALSE;
- DoCommand(&APIMsg);
-
- WaitForCompletion(&BackupMsg);
-
- DeleteMsgPort(BackReplyPort);
- }
-
- void DoRestore(ULONG Command)
-
- /* This routine starts a restore procedure asynchronously. See DoBackup() for
- details. The parameter Command contains the command code actually sent
- to Diavolo, so this routine can be used for restore AND compare operations. */
-
- {
- struct DiavoloAPIMsg APIMsg, RestoreMsg;
- struct MsgPort *RestReplyPort;
-
- if(! (RestReplyPort = CreateMsgPort()))
- {
- printf("Error creating own message port!\n");
- return;
- }
-
- RestoreMsg.DAPI_Message.mn_ReplyPort = RestReplyPort;
- RestoreMsg.DAPI_Command = Command;
-
- printf("Starting Restore\n");
- PutMsg(APIPort,&RestoreMsg);
-
- printf("Unlocking UI\n");
- APIMsg.DAPI_Command = DAPI_LOCKUI;
- APIMsg.DAPI_Arg1 = FALSE;
- DoCommand(&APIMsg);
-
- WaitForCompletion(&RestoreMsg);
-
- DeleteMsgPort(RestReplyPort);
- }
-
- void DoScan(void)
-
- /* This routine starts a scan backup procedure asynchronously. See DoBackup() for
- details. */
-
- {
- struct DiavoloAPIMsg APIMsg, ScanMsg;
- struct MsgPort *ScanReplyPort;
-
- if(! (ScanReplyPort = CreateMsgPort()))
- {
- printf("Error creating own message port!\n");
- return;
- }
-
- ScanMsg.DAPI_Message.mn_ReplyPort = ScanReplyPort;
- ScanMsg.DAPI_Command = DAPI_STARTSCAN;
- ScanMsg.DAPI_Arg1 = 2; /* 2nd backup on tape */
- ScanMsg.DAPI_Ptr1 = "Passwort";
-
- printf("Starting Scan\n");
- PutMsg(APIPort,&ScanMsg);
-
- printf("Unlocking UI\n");
- APIMsg.DAPI_Command = DAPI_LOCKUI;
- APIMsg.DAPI_Arg1 = FALSE;
- DoCommand(&APIMsg);
-
- WaitForCompletion(&ScanMsg);
-
- DeleteMsgPort(ScanReplyPort);
- }
-
-
- void main(void)
-
- {
- struct DiavoloAPIMsg APIMsg;
- struct PrefsFile PF;
-
- /* First create our own message port */
-
- if(! (MyReplyPort = CreateMsgPort()))
- {
- printf("Error creating own message port!\n");
- return;
- }
-
-
- /* Use forbid to secure the FindPort Operation (suggested in Exex autodocs) */
-
- Forbid();
-
-
- /* Look for Diavolo message port */
-
- if(! (APIPort = FindPort(RENDEZVOUS_NAME)))
- {
- Permit();
- printf("Couldn't find Diavolo API port!\n");
- DeleteMsgPort(MyReplyPort);
- return;
- }
-
- Permit();
-
- /* Rendezvous with Diavolo */
-
- APIMsg.DAPI_Command = DAPI_RENDEZVOUS;
- DoCommand(&APIMsg);
-
-
- /* The following is a sequence of commands which wont work this way on your
- system. Use them only as examples or to test the functions by activating only
- specific parts of the code. */
-
-
- /* First a typical backup procedure cycle */
-
-
- /* // Example1: Lock Userinterface
-
- printf("Locking UI\n");
- APIMsg.DAPI_Command = DAPI_LOCKUI;
- APIMsg.DAPI_Arg1 = TRUE;
- DoCommand(&APIMsg);
- */
-
-
- /* // Example2: Go to backup device selection window
-
- printf("Going to backup window\n");
- APIMsg.DAPI_Command = DAPI_INITBACKUP;
- DoCommand(&APIMsg);
- */
-
-
- /* // Example3: Change configuration. In this case: Alter backup destination to
- // SCSI Tape device
-
- printf("Altering Destination\n");
-
-
- /* First, get the current configuration */
-
- APIMsg.DAPI_Command = DAPI_ASKCONFIG;
- APIMsg.DAPI_Ptr1 = &PF;
- APIMsg.DAPI_Arg1 = sizeof(struct PrefsFile);
- DoCommand(&APIMsg);
-
-
- /* Make only neccessary changes */
-
- PF.prf_BackupMedium = MEDIUM_DEVICE;
-
-
- /* Write the configuration back to Diavolo */
-
- APIMsg.DAPI_Command = DAPI_CHANGECONFIG;
- APIMsg.DAPI_Ptr1 = &PF;
- DoCommand(&APIMsg);
- */
-
-
- /* // Example4: Clear all previous file selections
-
- printf("Clearing lists\n");
- APIMsg.DAPI_Command = DAPI_CLEARLISTS;
- DoCommand(&APIMsg);
- */
-
-
- // Example5: Select files for backup without using a filter file.
-
- printf("Making selection\n");
- APIMsg.DAPI_Command = DAPI_BACKSELECT;
- APIMsg.DAPI_Ptr1 = "Private:"; /* Partition to scan */
- APIMsg.DAPI_Ptr2 = "Treiber/#?"; /* Path and pattern of files to select */
- APIMsg.DAPI_Ptr3 = NULL; /* No date selection used */
- APIMsg.DAPI_Ptr4 = NULL; /* No scan exclusion pattern */
- APIMsg.DAPI_Arg1 = DAPI_SEL_INCLUDE; /* INCLUDE files matching to pattern */
- APIMsg.DAPI_Arg2 = 0; /* Ignore archive flag */
- APIMsg.DAPI_Arg3 = TRUE; /* Include subdirectories */
- APIMsg.DAPI_Arg4 = FALSE; /* Don't ignore empty directories */
- DoCommand(&APIMsg);
-
- APIMsg.DAPI_Command = DAPI_BACKSELECT;
- APIMsg.DAPI_Ptr1 = "Private:"; /* Another selection for the same partition.
- As it is already scanned, Diavolo won't scan it
- again. */
- APIMsg.DAPI_Ptr2 = "Tools/#?"; /* Another path to select files from */
- APIMsg.DAPI_Ptr3 = NULL; /* Again no date selection */
- APIMsg.DAPI_Ptr4 = NULL; /* No scan exclusion pattern */
- APIMsg.DAPI_Arg1 = DAPI_SEL_INCLUDE; /* INCLUDE files */
- APIMsg.DAPI_Arg2 = 0; /* Ignore archive flags */
- APIMsg.DAPI_Arg3 = TRUE; /* Include subdirectories */
- APIMsg.DAPI_Arg4 = FALSE; /* Don't ignore empty directories */
- DoCommand(&APIMsg);
-
- APIMsg.DAPI_Command = DAPI_BACKSELECT;
- APIMsg.DAPI_Ptr1 = "Private:Microdot"; /* Example of the use of a specific path as a partition.
- Same as "Select subdir" from the device selection. Only
- this path will be scanned, and it will listed seperately
- in the volume list. */
- APIMsg.DAPI_Ptr2 = "#?"; /* Select all files */
- APIMsg.DAPI_Ptr3 = NULL; /* No date selection */
- APIMsg.DAPI_Ptr4 = NULL; /* No scan exclusion pattern */
- APIMsg.DAPI_Arg1 = DAPI_SEL_INCLUDE; /* INCLUDE files */
- APIMsg.DAPI_Arg2 = 0; /* Ignore archive flags */
- APIMsg.DAPI_Arg3 = TRUE; /* Include subdirectories */
- APIMsg.DAPI_Arg4 = FALSE; /* Don't ignore empty directories */
- DoCommand(&APIMsg);
-
- APIMsg.DAPI_Command = DAPI_BACKSELECT;
- APIMsg.DAPI_Ptr1 = "WB_2.x"; /* Now we want to image backup this partition. */
- APIMsg.DAPI_Arg1 = DAPI_SEL_IMAGE; /* IMAGE-backup */
- APIMsg.DAPI_Arg2 = TRUE; /* Save only used blocks */
- DoCommand(&APIMsg);
-
- APIMsg.DAPI_Command = DAPI_BACKSELECT;
- APIMsg.DAPI_Ptr1 = "Work:MovieShop/MovieShop.prj";
- /* The last example shows how to select a MovieShop project */
- APIMsg.DAPI_Arg1 = DAPI_SEL_MOVIE; /* IMAGE-backup */
- DoCommand(&APIMsg);
-
-
-
- /* // Example6: Select files for backup using a filter file.
-
- printf("Using selection filter\n");
- APIMsg.DAPI_Command = DAPI_USEFILTER;
- APIMsg.DAPI_Ptr1 = (char *)"Testfilter.filter";
- DoCommand(&APIMsg);
- printf("Results: Partitions: %ld, Directories: %ld, Files: %ld, Size: %ld\n",APIMsg.DAPI_Arg1,
- APIMsg.DAPI_Arg2,APIMsg.DAPI_Arg3,APIMsg.DAPI_Arg4);
- */
-
-
- /* // Now, start backup
-
- DoBackup();
- */
-
- /* // Do Autocompare (DoRestore() manages this, just give the correct command name)
-
- DoRestore(DAPI_COMPAREBACKUP);
- */
-
-
- /* // Return to the main menu
-
- APIMsg.DAPI_Command = DAPI_MAINMENU;
- DoCommand(&APIMsg);
- */
-
-
- /* Now, a typical compare procedure cycle */
-
- /* // Lock the user interface
-
- printf("Locking UI\n");
- APIMsg.DAPI_Command = DAPI_LOCKUI;
- APIMsg.DAPI_Arg1 = TRUE;
- DoCommand(&APIMsg);
- */
-
-
- /* // Go to compare device selection
-
- printf("Going to compare window\n");
- APIMsg.DAPI_Command = DAPI_INITRESTORE;
- DoCommand(&APIMsg);
- */
-
-
- /* // Before any selection can take place, the backup has to be scanned.
-
- DoScan();
- */
-
-
- /* // The scan procedure has unlocked the user interface (see DoScan()), so
- // it must be locked again.
-
- printf("Locking UI\n");
- APIMsg.DAPI_Command = DAPI_LOCKUI;
- APIMsg.DAPI_Arg1 = TRUE;
- DoCommand(&APIMsg);
- */
-
-
- /* // Example7: File selection for compare/restore procedure. Note that filters
- // won't work here!
- // Note that normally all files are already selected after the scan has been
- // completed.
-
- APIMsg.DAPI_Command = DAPI_RESTSELECT;
- APIMsg.DAPI_Ptr1 = "Private:"; /* Partition to select files from. It
- must be a partition, path or assign present
- in the backup of course */
- APIMsg.DAPI_Ptr2 = "ram:"; /* New restore/compare destination or NULL if not to change */
- APIMsg.DAPI_Ptr3 = "#?"; /* Path and pattern for selection */
- APIMsg.DAPI_Ptr4 = NULL; /* No date selection */
- APIMsg.DAPI_Arg1 = FALSE; /* EXCLUDE all files matching the pattern */
- APIMsg.DAPI_Arg2 = 0; /* Ignore archive flag */
- APIMsg.DAPI_Arg3 = TRUE; /* Include subdirectories */
- APIMsg.DAPI_Arg4 = FALSE; /* Don't ignore empty directories */
- DoCommand(&APIMsg);
-
- APIMsg.DAPI_Command = DAPI_RESTSELECT;
- APIMsg.DAPI_Ptr1 = "Private:Microdot"; /* This is an example of a absolute path as a partition.
- It can only be used, if the backup contains a seperate
- entry for this path, i.e. this entry is listed in the
- volumes list. */
- APIMsg.DAPI_Ptr2 = NULL; /* Don't change restore/compare destination */
- APIMsg.DAPI_Ptr3 = "#?"; /* Match all files */
- APIMsg.DAPI_Ptr4 = NULL; /* No date selection */
- APIMsg.DAPI_Arg1 = FALSE; /* EXCLUDE all files */
- APIMsg.DAPI_Arg2 = 0; /* Ignore archive flags */
- APIMsg.DAPI_Arg3 = TRUE; /* Include subdirectories */
- APIMsg.DAPI_Arg4 = FALSE; /* Don't ignore empty directories */
- DoCommand(&APIMsg);
-
- APIMsg.DAPI_Command = DAPI_RESTSELECT;
- APIMsg.DAPI_Ptr1 = "Private:"; /* Select from Private: */
- APIMsg.DAPI_Ptr2 = NULL; /* Don't change destination */
- APIMsg.DAPI_Ptr3 = "#?.info"; /* Select all files matching to #?.info */
- APIMsg.DAPI_Ptr4 = NULL; /* No date selection */
- APIMsg.DAPI_Arg1 = TRUE; /* INCLUDE matching files */
- APIMsg.DAPI_Arg2 = 0; /* Ignore archive flags */
- APIMsg.DAPI_Arg3 = TRUE; /* Include subdirectories */
- APIMsg.DAPI_Arg4 = TRUE; /* Ignore empty directories (in this case: Don't select them) */
- DoCommand(&APIMsg);
- */
-
-
- /* // Start compare operation. Note that DAPI_STARTRESTORE starts BOTH compare and restore,
- // what operation is to be started is defined by DAPI_INITCOMPARE or DAPI_INITRESTORE
- // above!
-
- DoRestore(DAPI_STARTRESTORE);
- */
-
-
- /* // Example8: Create file and error reports
-
- APIMsg.DAPI_Command = DAPI_CREATEREPORT;
- APIMsg.DAPI_Arg1 = TRUE; /* Create filelist */
- APIMsg.DAPI_Arg2 = FALSE; /* Use condensed output */
- APIMsg.DAPI_Ptr1 = "ram:filelist"; /* Destination name of report */
- DoCommand(&APIMsg);
-
- APIMsg.DAPI_Command = DAPI_CREATEREPORT;
- APIMsg.DAPI_Arg1 = FALSE; /* Create errorreport */
- APIMsg.DAPI_Ptr1 = "ram:errorlist";
- DoCommand(&APIMsg);
- */
-
-
- /* // Back to main menu
-
- printf("MainMenu\n");
- APIMsg.DAPI_Command = DAPI_MAINMENU;
- DoCommand(&APIMsg);
- */
-
-
- /* // Example9: Issue an SCSI command
-
- APIMsg.DAPI_Command = DAPI_SCSICOMMAND;
- APIMsg.DAPI_Arg1 = 3; /* Eject tape */
- DoCommand(&APIMsg);
- */
-
-
- /* // Quit Diavolo
-
- printf("Quit\n");
- APIMsg.DAPI_Command = DAPI_QUIT;
- DoCommand(&APIMsg);
- */
-
-
- /* // Close connection with client
-
- printf("Good bye\n");
- APIMsg.DAPI_Command = DAPI_GOODBYE;
- DoCommand(&APIMsg);
- */
-
-
- DeleteMsgPort(MyReplyPort);
- }
-