This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-mbse/mbcico/statetbl.h

54 lines
1.0 KiB
C
Raw Normal View History

2001-08-17 05:46:24 +00:00
#ifndef STATETBL_H
#define STATETBL_H
#define SM_DECL(proc,name) \
int proc(void)\
{\
2003-09-07 20:25:33 +00:00
int sm_success=0;\
char *sm_name=name;
2001-08-17 05:46:24 +00:00
#define SM_STATES \
2003-09-07 20:25:33 +00:00
enum {
2001-08-17 05:46:24 +00:00
#define SM_NAMES \
2003-09-07 20:25:33 +00:00
} sm_state; \
char * sm_sname[] = {
2001-08-17 05:46:24 +00:00
#define SM_EDECL \
2003-09-07 20:25:33 +00:00
};
2001-08-17 05:46:24 +00:00
#define SM_START(x) \
2003-09-07 20:25:33 +00:00
sm_state=x;\
Syslog('S', "SM (%s): Start => %s", sm_name, sm_sname[sm_state]); \
while (!sm_success) switch (sm_state)\
{\
default: WriteError("Statemachine %s error: state=%d",sm_name,sm_state);\
sm_success=-1;
2001-08-17 05:46:24 +00:00
#define SM_STATE(x) \
2003-09-07 20:25:33 +00:00
break;\
case x:
2001-08-17 05:46:24 +00:00
#define SM_END \
2003-09-07 20:25:33 +00:00
}\
2001-08-17 05:46:24 +00:00
#define SM_RETURN \
2003-09-07 20:25:33 +00:00
return (sm_success != 1);\
2001-08-17 05:46:24 +00:00
}
#define SM_PROCEED(x) \
2003-09-07 20:25:33 +00:00
if (x != sm_state) {\
Syslog('S', "SM (%s): %s => %s", sm_name, sm_sname[sm_state], sm_sname[x]);\
}\
sm_state=x; break;
2001-08-17 05:46:24 +00:00
#define SM_SUCCESS \
2003-09-07 20:25:33 +00:00
Syslog('S', "SM (%s): %s => Success", sm_name, sm_sname[sm_state]);\
sm_success=1; break;
2001-08-17 05:46:24 +00:00
#define SM_ERROR \
2003-09-07 20:25:33 +00:00
Syslog('S', "SM (%s): %s => Error", sm_name, sm_sname[sm_state]);\
sm_success=-1; break;
2001-08-17 05:46:24 +00:00
#endif