iso9660fs: initialize buffer cache
[minix.git] / drivers / printer / liveupdate.c
blob1f36555694cc6fb76741c2cfbfc8192180650647
1 #include <minix/drivers.h>
3 /* State management variables. */
4 EXTERN int writing;
5 EXTERN int is_status_msg_expected;
7 /* Custom states definition. */
8 #define PR_STATE_WRITE_PROTOCOL_FREE (SEF_LU_STATE_CUSTOM_BASE + 0)
9 #define PR_STATE_IS_CUSTOM(s) ((s) == PR_STATE_WRITE_PROTOCOL_FREE)
11 /*===========================================================================*
12 * sef_cb_lu_prepare *
13 *===========================================================================*/
14 int sef_cb_lu_prepare(int state)
16 int is_ready;
18 /* Check if we are ready for the target state. */
19 is_ready = FALSE;
20 switch(state) {
21 /* Standard states. */
22 case SEF_LU_STATE_REQUEST_FREE:
23 is_ready = TRUE;
24 break;
26 case SEF_LU_STATE_PROTOCOL_FREE:
27 is_ready = (!writing && !is_status_msg_expected);
28 break;
30 /* Custom states. */
31 case PR_STATE_WRITE_PROTOCOL_FREE:
32 is_ready = (!writing);
33 break;
36 /* Tell SEF if we are ready. */
37 return is_ready ? OK : ENOTREADY;
40 /*===========================================================================*
41 * sef_cb_lu_state_isvalid *
42 *===========================================================================*/
43 int sef_cb_lu_state_isvalid(int state)
45 return SEF_LU_STATE_IS_STANDARD(state) || PR_STATE_IS_CUSTOM(state);
48 /*===========================================================================*
49 * sef_cb_lu_state_dump *
50 *===========================================================================*/
51 void sef_cb_lu_state_dump(int state)
53 sef_lu_dprint("printer: live update state = %d\n", state);
54 sef_lu_dprint("printer: writing = %d\n", writing);
55 sef_lu_dprint("printer: is_status_msg_expected = %d\n",
56 is_status_msg_expected);
58 sef_lu_dprint("printer: SEF_LU_STATE_WORK_FREE(%d) reached = %d\n",
59 SEF_LU_STATE_WORK_FREE, TRUE);
60 sef_lu_dprint("printer: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n",
61 SEF_LU_STATE_REQUEST_FREE, TRUE);
62 sef_lu_dprint("printer: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n",
63 SEF_LU_STATE_PROTOCOL_FREE, (!writing && !is_status_msg_expected));
64 sef_lu_dprint("printer: PR_STATE_WRITE_PROTOCOL_FREE(%d) reached = %d\n",
65 PR_STATE_WRITE_PROTOCOL_FREE, (!writing));