Err vfsExportDatabaseToFile (UInt16 volRefNum, Char *pathNameP, UInt16 cardNo, LocalID dbID) { axxPacFD fd; Err ret; Err (*ExgDBWriteProcPtr) (const void* dataP, UInt32* sizeP, void* userDataP); if ((fd = axxPacOpen(LibRef, pathNameP, O_Creat)) < 0) return vfsErrBadName; ExgDBWriteProcPtr = &WriteDataToFile; ret = ExgDBWrite(WriteDataToFile, &fd, NULL, dbID, cardNo); ret = axxPacClose(LibRef, fd); if (0 < ret) return expErrNotEnoughPower; else return ret; }
/*********************************************************************** * * FUNCTION: SendDatabase * * DESCRIPTION: Sends data in the input field using the Exg API * * RETURNED: error code or zero for no error. * ***************************************************************************/ static Err SendDatabase (BeamParamsPtr cmdPBP) { Err err; ExgSocketType exgSocket; int bytesSent = 0; LocalID inputDbID = -1; inputDbID = DmFindDatabase(0, cmdPBP->inName); if(inputDbID == 0){ return(err); } // Create exgSocket structure MemSet(&exgSocket, sizeof(ExgSocketType), 0); exgSocket.description = cmdPBP -> description; // If the there isn't an appName and outName // then send the database directly. if(StrLen(cmdPBP->appName) == 0 && StrLen(cmdPBP->outName) == 0){ exgSocket.name = "dummy.pdb"; // Start and exchange put operation err = ExgPut(&exgSocket); if (!err){ // This function converts a palm database into its external (public) // format. The first parameter is a callback that will be passed parts of // the database to send or write. err = ExgDBWrite(WriteDBData, &exgSocket, NULL, inputDbID, cmdPBP -> cardNo); // Disconnect Exg and pass error err = ExgDisconnect(&exgSocket, err); } else { FrmAlert (2000); } return err; } // Otherwise use our wrapper file name // This ensures that CCBeam will be launched again // by the recieving palm exgSocket.name = CCBeamDBFilename; // Start and exchange put operation err = ExgPut(&exgSocket); if (!err){ // Send the out name we fix it at 32 bytes bytesSent = ExgSend(&exgSocket, cmdPBP->outName, 32, &err); if(bytesSent < 32){ return err; } // Send the application name we fix it at 32 bytes bytesSent = ExgSend(&exgSocket, cmdPBP->appName, 32, &err); if(bytesSent < 32){ return err; } // This function converts a palm database into its external (public) // format. The first parameter is a callback that will be passed parts of // the database to send or write. err = ExgDBWrite(WriteDBData, &exgSocket, NULL, inputDbID, cmdPBP -> cardNo); // Disconnect Exg and pass error err = ExgDisconnect(&exgSocket, err); } else { FrmAlert (2000); } return err; }