sttransaction(3) | ShapeTools Toolkit Library | sttransaction(3) |
stAbortThis, stThisTransaction - simple transaction handling
#include <config.h>
#include <sttk.h>
void stAbortThis (int domsg);
struct stTransaction stThisTransaction;
stAbortThis is part of a simple transaction mechanism on the basis of setjmp(3) and longjmp(3). A transacion is started by setting a return point calling setjmp(3) and may be aborted by calling stAbortThis. This outputs a short abort message, cleans up the temporary files (stRmRegisteredFiles(3)) and performs a longjmp(3) operation, returning to the transaction start point.
The structure variable stThisTransaction carries information about the current transaction. It has the following fields:
struct stTransaction {
char tr_fname[MAXPATHLEN+1];
int tr_done;
int tr_seqno;
int tr_rc;
jmp_buf tr_env; };
When setting the transaction return point by calling setjmp(3) the tr_env field must be used as argument to setjmp. The name of the concerned file should be stored in tr_fname field and the tr_done flag should be cleared. tr_seqno is the serial number of the current transaction and must be increased at the beginning of each new transaction. The tr_rc return code can be set to an appropriate return code when something went wrong and the transaction was aborted. When not set by the application, tr_rc will be set nun null by stAbortThis on abortion of the transaction. On successful completion, tr_done should be set TRUE.
Thu Jun 24 17:43:37 1993 | sttk-1.7 |