rules.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2019 Clementine Computing LLC.
  3. *
  4. * This file is part of PopuFare.
  5. *
  6. * PopuFare is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * PopuFare is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with PopuFare. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //This function clears the entire anti-passback cache
  21. int apb_clear();
  22. // This function examines the state of the gps_stat and stop_stat structures and clears the anti-passback cache if the bus has
  23. //either moved at least APB_DIST_EXPIRE meters since the last accept, or if the route, trip, or stop have changed.
  24. // If the cache is cleared as the result of this function call, the cache state is updated so that it reflects the location
  25. //data as they stood when the flush was completed. If there is nothing in the cache, the location is simply updated.
  26. int apb_flush_if_needed();
  27. //Add a rider to the anti-passback cache...
  28. int apb_add(logical_card_id_t id);
  29. // Look up a rider in the anti-passback cache. If the rider is not present, this function returns zero.
  30. //If the rider is present, this function returns the number of seconds since they last rode this bus.
  31. int apb_lookup(logical_card_id_t id);
  32. // This function does a "smart" magstripe lookup by looking up the token found
  33. //on track1, then track2, then track3 individually (ignoring tracks 1 and 2 if they
  34. //contain credit-card style field-delimiters), returning the index of the rider
  35. //in the riders database attached to ctx, or -1 if not found.
  36. // If the return is -1 (not found) final_token is filled with the whole list of
  37. //tracks that were attempted (with credit-card looking tracks blanked out).
  38. // If the return is >= 0 (record found) final_token is filled with the token that
  39. //was used to generate the match.
  40. int smart_find_mag(passdb_slim_context *ctx, char *token, char *final_token);
  41. // This function does a "smart" RFID lookup by translating the raw RFID format (NN|XXXX...)
  42. //where NN is the number of bits in hex, and XXXX... is the bitstring in hex (right justified
  43. //to the nearest nibble boundary) and processing it based on the number of bits and a list of
  44. //known formats until it either matches a known format or is determined not to match any of them.
  45. // If a match is found, the return value will be >= 0 and indicate the index of the rider in
  46. //the database that ctx is attached to. If no match is found, -1 is returned. In either case
  47. //final_token is filled with the string representing the decoded decimal RFID value "nbits:site:id"
  48. //or if the token was not in a known format, "nbits:rawval?".
  49. int smart_find_rf(passdb_slim_context *ctx, char *token, char *final_token);
  50. int rules_loaded();
  51. int load_rules(char *filename);
  52. int unload_rules();
  53. int process_rider(passdb_slim_context *ctx, int rider_index, char *credential);
  54. int process_driver_rulecall(struct driver_rulecall_struct *drc);