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