[PATCH] State machine rewrite of dbus-auth.c

Kristian Høgsberg krh at bitplanet.net
Tue May 18 06:45:16 PDT 2004


Hi,

I have a patch here that rearranges the auth protocol code to work more 
like a state machine, as suggested by the TODO.  The basic idea is to 
implement each state as a function that does a

	switch (command)
	  {
	  ...
	  }

and handles the various commands in the protocol according to the 
current state.   A state is represented as a struct:

	typedef struct
	{
	  const char *name;               /**< Name of the state */
	  DBusAuthStateFunction handler;  /**< State function for this 	state */
	} DBusAuthStateData;

and the DBusAuth object has a DBusAuthStateData pointer to remember the 
current state.  The function goto_state() goes to a new state by 
updating the pointer and logs the transition.

The actual states and transitions implemented are as described in my 
previous mail

	http://freedesktop.org/pipermail/dbus/2004-May/001087.html

and the behaviour is mostly the same as the existing code.

I would like to hear what people think of the alternate specification 
and the rewrite.  The intention is that the specification should be 
clear and unambiguous, and that the structure and functionality of the 
implementation should be close to the specification.

Kristian

-------------- next part --------------
A non-text attachment was scrubbed...
Name: state-machine.patch
Type: text/x-patch
Size: 36623 bytes
Desc: not available
Url : http://freedesktop.org/pipermail/dbus/attachments/20040518/8d0c5874/state-machine-0001.bin


More information about the dbus mailing list