shiftry123

Laboratorium 3 states.c

Apr 16th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include "states.h"
  3.  
  4. int random(int from, int to) {
  5.     return rand() % (to - from) + from;
  6. }
  7.  
  8. int open_connection_state(void) {
  9.     int action = random(0, 10);
  10.     if (action % 2 == 0) return done;
  11.     else return error;
  12. }
  13.  
  14. int wait_for_request_state(void) {
  15.     int action = random(0, 100);
  16.     if (action % 10 == 0) return request_available;
  17.     else return no_request;
  18. }
  19.  
  20. int get_request_state(void) {
  21.     int action = random(0, 100);
  22.     if (action % 3 == 0) return done;
  23.     else return error;
  24. }
  25.  
  26. int find_handler_state(void) {
  27.     int action = random(0, 100);
  28.     if (action % 5 == 0) return handler_available;
  29.     else return error;
  30. }
  31.  
  32. int send_response_state(void) {
  33.     return done;
  34. }
  35.  
  36. int send_error_state(void) {
  37.     return done;
  38. }
  39.  
  40. int close_connection_state(void) {
  41.     return done;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment