FreeRDP
state.c
1 
22 #include "state.h"
23 
24 #include <winpr/string.h>
25 
26 BOOL state_run_failed(state_run_t status)
27 {
28  switch (status)
29  {
30  case STATE_RUN_FAILED:
31  case STATE_RUN_QUIT_SESSION:
32  return TRUE;
33  default:
34  return FALSE;
35  }
36 }
37 
38 BOOL state_run_success(state_run_t status)
39 {
40  if (status == STATE_RUN_CONTINUE)
41  return TRUE;
42  return status >= STATE_RUN_SUCCESS;
43 }
44 
45 const char* state_run_result_string(state_run_t status, char* buffer, size_t buffersize)
46 {
47  const char* name = NULL;
48 
49  switch (status)
50  {
51  case STATE_RUN_ACTIVE:
52  name = "STATE_RUN_ACTIVE";
53  break;
54  case STATE_RUN_REDIRECT:
55  name = "STATE_RUN_REDIRECT";
56  break;
57  case STATE_RUN_SUCCESS:
58  name = "STATE_RUN_SUCCESS";
59  break;
60  case STATE_RUN_FAILED:
61  name = "STATE_RUN_FAILED";
62  break;
63  case STATE_RUN_QUIT_SESSION:
64  name = "STATE_RUN_QUIT_SESSION";
65  break;
66  case STATE_RUN_TRY_AGAIN:
67  name = "STATE_RUN_TRY_AGAIN";
68  break;
69  case STATE_RUN_CONTINUE:
70  name = "STATE_RUN_CONTINUE";
71  break;
72  default:
73  name = "STATE_RUN_UNKNOWN";
74  break;
75  }
76 
77  (void)_snprintf(buffer, buffersize, "%s [%d]", name, status);
78  return buffer;
79 }
80 
81 BOOL state_run_continue(state_run_t status)
82 {
83  return (status == STATE_RUN_TRY_AGAIN) || (status == STATE_RUN_CONTINUE) ||
84  (status == STATE_RUN_ACTIVE);
85 }