1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef NET_PROXY_PROXY_RESOLVER_V8_WRAPPER_H_ 18 #define NET_PROXY_PROXY_RESOLVER_V8_WRAPPER_H_ 19 20 // This header should be compatible with C or C++ compiler 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #define OK 0 26 #define ERR_PAC_SCRIPT_FAILED -1 27 #define ERR_FAILED -2 28 29 /** 30 * Declare an incomplete type ProxyResolverV8Handle. A pointer of this should always be 31 * either null or pointing to a C++ ProxyResolverV8 object. 32 */ 33 typedef void* ProxyResolverV8Handle; 34 35 /** 36 * Create a ProxyResolverV8Handle. The caller must call ProxyResolverV8Handle_delete to release 37 * the memory. 38 */ 39 ProxyResolverV8Handle* ProxyResolverV8Handle_new(); 40 41 /** 42 * @return the result in char16_t array if the run is successful. The result contains a list of 43 * proxies according to the PAC specification. Otherwise, return NULL if the run fails. 44 * The memory is allocated with malloc() and the caller should use free() to release it 45 * after use. 46 */ 47 char16_t* ProxyResolverV8Handle_GetProxyForURL(ProxyResolverV8Handle* handle, 48 const char16_t* spec, const char16_t* host); 49 /** 50 * @return OK if setting the pac script successfully. 51 */ 52 int ProxyResolverV8Handle_SetPacScript(ProxyResolverV8Handle* handle, 53 const char16_t* script_data); 54 55 void ProxyResolverV8Handle_delete(ProxyResolverV8Handle* handle); 56 57 #ifdef __cplusplus 58 } 59 #endif 60 61 #endif // NET_PROXY_PROXY_RESOLVER_V8_WRAPPER_H_