sttransaction(3)

πŸŽ€ NAME πŸŽ€

okay so this is sttransaction(3) from the ShapeTools Toolkit Library bestie, and it's all about simple transaction handling ✨ two lil things live here: stAbortThis and stThisTransaction.


✨ SYNOPSIS ✨

#include <config.h>
#include <sttk.h>

void         stAbortThis (int domsg);

struct stTransactionstThisTransaction;
yes the missing space in struct stTransactionstThisTransaction; is canon, we do not touch the sacred text πŸ™ˆ copy it exactly, iykyk.

πŸ’– DESCRIPTION πŸ’–

so stAbortThis is part of a simple transaction mechanism, built on top of setjmp(3) and longjmp(3). Here's the vibe: a transaction gets started by setting a return point β€” you do that by calling setjmp(3) β€” and then you can abort it any time by calling stAbortThis. When you do, it:

  • spits out a short abort message πŸ’¬
  • cleans up the temporary files (that's stRmRegisteredFiles(3) doing the heavy lifting 🧹)
  • does a whole longjmp(3) moment, yeeting you right back to the transaction start point πŸ¦‹

The structure variable stThisTransaction carries the info about the current transaction. Main character energy fr. It has these fields:

struct stTransaction {
  char tr_fname[MAXPATHLEN+1];
  int tr_done;
  int tr_seqno;
  int tr_rc;
  jmp_buf tr_env;
};

okay so breaking down how you actually use it:

  • When you set the transaction return point by calling setjmp(3), the tr_env field is the one that must be used as the argument to setjmp. No substitutions, bestie.
  • The name of the concerned file should go in the tr_fname field.
  • The tr_done flag should be cleared.
  • tr_seqno is the serial number of the current transaction, and you must increase it at the beginning of each new transaction. Every time. No skipping πŸ’…
  • The tr_rc return code can be set to whatever appropriate return code fits when something went wrong and the transaction was aborted.
  • If the application doesn't set it, tr_rc will be set to null by stAbortThis on abortion of the transaction. (the original page literally says "nun null" and I love that for it, but yeah β€” null 😭)
  • On successful completion, tr_done should be set TRUE. periodt. πŸ‘‘

🌈 SEE ALSO 🌈


and that's the whole page, bestie 🫢 this was sttransaction(3) from the ShapeTools Toolkit Library, and yes it really is dated Thu Jun 24 17:43:37 1993 β€” vintage icon behavior fr, we stan a timeless baddie πŸ‘‘

πŸ“¦ where this page comes from