paulborile | cd9b9bd | 2019-04-18 12:31:25 +0200 | [diff] [blame] | 1 | /* |
| 2 | * InFuze C API - HAPROXY Dummy library version of include |
| 3 | * |
| 4 | * Author : Paul Stephen Borile, Mon Apr 8, 2019 |
| 5 | * Copyright (c) ScientiaMobile, Inc. |
| 6 | * http://www.scientiamobile.com |
| 7 | * |
| 8 | * This is a dummy implementation of the wurfl C API that builds and runs |
| 9 | * like the normal API simply without returning device detection data |
| 10 | * |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include "wurfl/wurfl.h" |
| 15 | |
| 16 | #pragma GCC diagnostic push |
| 17 | #pragma GCC diagnostic ignored "-Wunused-parameter" |
| 18 | |
| 19 | const char *wurfl_get_api_version(void) |
| 20 | { |
| 21 | return "1.11.2.100"; // 100 indicates the dummy |
| 22 | } |
| 23 | |
| 24 | wurfl_handle wurfl_create(void) |
| 25 | { |
| 26 | return (void*) 0xbeffa; |
| 27 | } |
| 28 | |
| 29 | void wurfl_destroy(wurfl_handle handle) |
| 30 | { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | wurfl_error wurfl_set_root(wurfl_handle hwurfl, const char* root) |
| 35 | { |
| 36 | return WURFL_OK; |
| 37 | } |
| 38 | wurfl_error wurfl_add_patch(wurfl_handle hwurfl, const char *patch) |
| 39 | { |
| 40 | return WURFL_OK; |
| 41 | } |
| 42 | |
| 43 | wurfl_error wurfl_add_requested_capability(wurfl_handle hwurfl, const char *requested_capability) |
| 44 | { |
| 45 | return WURFL_OK; |
| 46 | } |
| 47 | |
| 48 | const char *wurfl_get_error_message(wurfl_handle hwurfl) |
| 49 | { |
| 50 | return "wurfl dummy library error message"; |
| 51 | } |
| 52 | |
| 53 | int wurfl_has_virtual_capability(wurfl_handle hwurfl, const char *virtual_capability) |
| 54 | { |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | wurfl_error wurfl_set_cache_provider(wurfl_handle hwurfl, wurfl_cache_provider cache_provider, const char *config) |
| 59 | { |
| 60 | return WURFL_OK; |
| 61 | } |
| 62 | |
| 63 | wurfl_error wurfl_load(wurfl_handle hwurfl) |
| 64 | { |
| 65 | return WURFL_OK; |
| 66 | } |
| 67 | |
| 68 | wurfl_device_handle wurfl_lookup(wurfl_handle hwurfl, wurfl_header_retrieve_callback header_retrieve_callback, const void *header_retrieve_callback_data) |
| 69 | { |
mbellomi | e30e300 | 2019-05-21 15:44:53 +0200 | [diff] [blame] | 70 | // call callback, on a probably existing header |
| 71 | const char *hvalue = header_retrieve_callback("User-Agent", header_retrieve_callback_data); |
| 72 | // and on a non existing one |
| 73 | hvalue = header_retrieve_callback("Non-Existing-Header", header_retrieve_callback_data); |
Willy Tarreau | ce1f7a1 | 2019-05-22 14:54:27 +0200 | [diff] [blame] | 74 | (void)hvalue; |
paulborile | cd9b9bd | 2019-04-18 12:31:25 +0200 | [diff] [blame] | 75 | return (void *) 0xdeffa; |
| 76 | } |
| 77 | |
| 78 | const char *wurfl_device_get_capability(wurfl_device_handle hwurfldevice, const char *capability) |
| 79 | { |
| 80 | return "dummy_cap_val"; |
| 81 | } |
| 82 | |
| 83 | const char *wurfl_device_get_virtual_capability(wurfl_device_handle hwurfldevice, const char *capability) |
| 84 | { |
| 85 | return "dummy_vcap_val"; |
| 86 | } |
| 87 | |
| 88 | void wurfl_device_destroy(wurfl_device_handle handle) |
| 89 | { |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | const char *wurfl_device_get_id(wurfl_device_handle hwurfldevice) |
| 94 | { |
| 95 | return "generic_dummy_device"; |
| 96 | } |
| 97 | |
| 98 | const char *wurfl_device_get_root_id(wurfl_device_handle hwurfldevice) |
| 99 | { |
| 100 | return "generic_dummy_device"; |
| 101 | } |
| 102 | |
| 103 | const char *wurfl_device_get_original_useragent(wurfl_device_handle hwurfldevice) |
| 104 | { |
Willy Tarreau | ce1f7a1 | 2019-05-22 14:54:27 +0200 | [diff] [blame] | 105 | return "original_useragent"; |
paulborile | cd9b9bd | 2019-04-18 12:31:25 +0200 | [diff] [blame] | 106 | } |
| 107 | const char *wurfl_device_get_normalized_useragent(wurfl_device_handle hwurfldevice) |
| 108 | { |
Willy Tarreau | ce1f7a1 | 2019-05-22 14:54:27 +0200 | [diff] [blame] | 109 | return "normalized_useragent"; |
paulborile | cd9b9bd | 2019-04-18 12:31:25 +0200 | [diff] [blame] | 110 | } |
| 111 | int wurfl_device_is_actual_device_root(wurfl_device_handle hwurfldevice) |
| 112 | { |
| 113 | return 1; |
| 114 | } |
| 115 | |
| 116 | const char *wurfl_get_wurfl_info(wurfl_handle hwurfl) |
| 117 | { |
| 118 | return "dummy wurfl info"; |
| 119 | } |
| 120 | |
| 121 | const char *wurfl_get_last_load_time_as_string(wurfl_handle hwurfl) |
| 122 | { |
| 123 | return "dummy wurfl last load time"; |
| 124 | } |
| 125 | |
| 126 | #pragma GCC diagnostic pop |