1 /* Copyright © 2012 Brandon L Black <blblack@gmail.com> 2 * 3 * This file is part of gdnsd. 4 * 5 * gdnsd-plugin-geoip is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * gdnsd-plugin-geoip is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with gdnsd. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef DCINFO_H 21 #define DCINFO_H 22 23 #include <gdnsd/compiler.h> 24 #include <gdnsd/vscf.h> 25 26 // DEG2RAD converts degrees to radians. Our auto_dc_coords input 27 // and GeoIPCity coordinate data is in degrees, and must be 28 // converted to radians before storage (auto_dc_coords) or use 29 // (GeoIPCity data), because our haversine() func takes its inputs 30 // in radian format 31 static const double DEG2RAD = 0.017453292519943295769236907684886; 32 33 typedef struct _dcinfo dcinfo_t; 34 35 F_NONNULLX(1, 4) F_WUNUSED 36 dcinfo_t* dcinfo_new(vscf_data_t* dc_cfg, vscf_data_t* dc_auto_cfg, vscf_data_t* dc_auto_limit_cfg, const char* map_name); 37 F_NONNULL F_PURE 38 unsigned dcinfo_get_count(const dcinfo_t* info); 39 F_NONNULL F_PURE 40 unsigned dcinfo_get_limit(const dcinfo_t* info); 41 F_NONNULL F_PURE 42 const double* dcinfo_get_coords(const dcinfo_t* info, const unsigned dcnum); 43 F_NONNULLX(1) F_PURE 44 unsigned dcinfo_name2num(const dcinfo_t* info, const char* dcname); 45 F_NONNULL F_PURE 46 const char* dcinfo_num2name(const dcinfo_t* info, const unsigned dcnum); 47 F_NONNULL F_PURE 48 unsigned dcinfo_map_mon_idx(const dcinfo_t* info, const unsigned dcnum); 49 50 #endif // DCINFO_H 51