blob: 0d5f068280fc198666b5b69586d06bf301c219dc [file] [log] [blame]
paulborilecd9b9bd2019-04-18 12:31:25 +02001/*
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
19const char *wurfl_get_api_version(void)
20{
21 return "1.11.2.100"; // 100 indicates the dummy
22}
23
24wurfl_handle wurfl_create(void)
25{
26 return (void*) 0xbeffa;
27}
28
29void wurfl_destroy(wurfl_handle handle)
30{
31 return;
32}
33
34wurfl_error wurfl_set_root(wurfl_handle hwurfl, const char* root)
35{
36 return WURFL_OK;
37}
38wurfl_error wurfl_add_patch(wurfl_handle hwurfl, const char *patch)
39{
40 return WURFL_OK;
41}
42
43wurfl_error wurfl_add_requested_capability(wurfl_handle hwurfl, const char *requested_capability)
44{
45 return WURFL_OK;
46}
47
48const char *wurfl_get_error_message(wurfl_handle hwurfl)
49{
50 return "wurfl dummy library error message";
51}
52
53int wurfl_has_virtual_capability(wurfl_handle hwurfl, const char *virtual_capability)
54{
55 return 0;
56}
57
58wurfl_error wurfl_set_cache_provider(wurfl_handle hwurfl, wurfl_cache_provider cache_provider, const char *config)
59{
60 return WURFL_OK;
61}
62
63wurfl_error wurfl_load(wurfl_handle hwurfl)
64{
65 return WURFL_OK;
66}
67
68wurfl_device_handle wurfl_lookup(wurfl_handle hwurfl, wurfl_header_retrieve_callback header_retrieve_callback, const void *header_retrieve_callback_data)
69{
mbellomie30e3002019-05-21 15:44:53 +020070 // 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 Tarreauce1f7a12019-05-22 14:54:27 +020074 (void)hvalue;
paulborilecd9b9bd2019-04-18 12:31:25 +020075 return (void *) 0xdeffa;
76}
77
78const char *wurfl_device_get_capability(wurfl_device_handle hwurfldevice, const char *capability)
79{
80 return "dummy_cap_val";
81}
82
83const char *wurfl_device_get_virtual_capability(wurfl_device_handle hwurfldevice, const char *capability)
84{
85 return "dummy_vcap_val";
86}
87
88void wurfl_device_destroy(wurfl_device_handle handle)
89{
90 return;
91}
92
93const char *wurfl_device_get_id(wurfl_device_handle hwurfldevice)
94{
95 return "generic_dummy_device";
96}
97
98const char *wurfl_device_get_root_id(wurfl_device_handle hwurfldevice)
99{
100 return "generic_dummy_device";
101}
102
103const char *wurfl_device_get_original_useragent(wurfl_device_handle hwurfldevice)
104{
Willy Tarreauce1f7a12019-05-22 14:54:27 +0200105 return "original_useragent";
paulborilecd9b9bd2019-04-18 12:31:25 +0200106}
107const char *wurfl_device_get_normalized_useragent(wurfl_device_handle hwurfldevice)
108{
Willy Tarreauce1f7a12019-05-22 14:54:27 +0200109 return "normalized_useragent";
paulborilecd9b9bd2019-04-18 12:31:25 +0200110}
111int wurfl_device_is_actual_device_root(wurfl_device_handle hwurfldevice)
112{
113 return 1;
114}
115
116const char *wurfl_get_wurfl_info(wurfl_handle hwurfl)
117{
118 return "dummy wurfl info";
119}
120
121const 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