Skip to content
Snippets Groups Projects
Commit efdbc232 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add some helper functions for modifying node records in node.dab, atomically

These should probably be moved (along with other node functions in this file)
to nodedat.* some day.
parent 7215e911
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -1145,6 +1145,109 @@ int putnodedat(scfg_t* cfg, uint number, node_t* node, BOOL closeit, int file)
return(0);
}
/****************************************************************************/
/****************************************************************************/
BOOL set_node_status(scfg_t* cfg, int nodenum, enum node_status status)
{
node_t node;
int file;
if(getnodedat(cfg, nodenum, &node, /* lockit: */TRUE, &file) != 0)
return FALSE;
node.status = status;
return putnodedat(cfg, nodenum, &node, /* closeit: */TRUE, file) == 0;
}
/****************************************************************************/
/****************************************************************************/
BOOL set_node_misc(scfg_t* cfg, int nodenum, uint misc)
{
node_t node;
int file;
if(getnodedat(cfg, nodenum, &node, /* lockit: */TRUE, &file) != 0)
return FALSE;
node.misc = misc;
return putnodedat(cfg, nodenum, &node, /* closeit: */TRUE, file) == 0;
}
/****************************************************************************/
/****************************************************************************/
BOOL set_node_lock(scfg_t* cfg, int nodenum, BOOL set)
{
node_t node;
int file;
if(getnodedat(cfg, nodenum, &node, /* lockit: */TRUE, &file) != 0)
return FALSE;
if(set)
node.misc |= NODE_LOCK;
else
node.misc &= ~NODE_LOCK;
return putnodedat(cfg, nodenum, &node, /* closeit: */TRUE, file) == 0;
}
/****************************************************************************/
/****************************************************************************/
BOOL set_node_interrupt(scfg_t* cfg, int nodenum, BOOL set)
{
node_t node;
int file;
if(getnodedat(cfg, nodenum, &node, /* lockit: */TRUE, &file) != 0)
return FALSE;
if(set)
node.misc |= NODE_INTR;
else
node.misc &= ~NODE_INTR;
return putnodedat(cfg, nodenum, &node, /* closeit: */TRUE, file) == 0;
}
/****************************************************************************/
/****************************************************************************/
BOOL set_node_down(scfg_t* cfg, int nodenum, BOOL set)
{
node_t node;
int file;
if(getnodedat(cfg, nodenum, &node, /* lockit: */TRUE, &file) != 0)
return FALSE;
if(set)
node.misc |= NODE_DOWN;
else
node.misc &= ~NODE_DOWN;
return putnodedat(cfg, nodenum, &node, /* closeit: */TRUE, file) == 0;
}
/****************************************************************************/
/****************************************************************************/
BOOL set_node_rerun(scfg_t* cfg, int nodenum, BOOL set)
{
node_t node;
int file;
if(getnodedat(cfg, nodenum, &node, /* lockit: */TRUE, &file) != 0)
return FALSE;
if(set)
node.misc |= NODE_RRUN;
else
node.misc &= ~NODE_RRUN;
return putnodedat(cfg, nodenum, &node, /* closeit: */TRUE, file) == 0;
}
/****************************************************************************/
/****************************************************************************/
BOOL set_node_errors(scfg_t* cfg, int nodenum, uint errors)
{
node_t node;
int file;
if(getnodedat(cfg, nodenum, &node, /* lockit: */TRUE, &file) != 0)
return FALSE;
node.errors = errors;
return putnodedat(cfg, nodenum, &node, /* closeit: */TRUE, file) == 0;
}
/****************************************************************************/
/* Packs the password 'pass' into 5bit ASCII inside node_t. 32bits in */
/* node.extaux, and the other 8bits in the upper byte of node.aux */
......
......@@ -86,6 +86,13 @@ DLLEXPORT int putsmsg(scfg_t*, int usernumber, char *strin);
DLLEXPORT char* getnmsg(scfg_t*, int node_num);
DLLEXPORT int putnmsg(scfg_t*, int num, char *strin);
DLLEXPORT int getnodeclient(scfg_t*, uint number, client_t*, time_t*);
DLLEXPORT BOOL set_node_lock(scfg_t*, int node_num, BOOL);
DLLEXPORT BOOL set_node_interrupt(scfg_t*, int node_num, BOOL);
DLLEXPORT BOOL set_node_down(scfg_t*, int node_num, BOOL);
DLLEXPORT BOOL set_node_rerun(scfg_t*, int node_num, BOOL);
DLLEXPORT BOOL set_node_status(scfg_t*, int node_num, enum node_status);
DLLEXPORT BOOL set_node_misc(scfg_t*, int node_num, uint);
DLLEXPORT BOOL set_node_errors(scfg_t*, int node_num, uint);
DLLEXPORT uint finduserstr(scfg_t*, uint usernumber, enum user_field, const char *str
,BOOL del, BOOL next, void (*progress)(void*, int, int), void* cbdata);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment