1 /* 2 * uclient - ustream based protocol client library 3 * 4 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org> 5 * 6 * Permission to use, copy, modify, and/or distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 #ifndef __UCLIENT_UTILS_H 19 #define __UCLIENT_UTILS_H 20 21 #include <stdbool.h> 22 23 struct http_digest_data { 24 const char *uri; 25 const char *method; 26 27 const char *auth_hash; /* H(A1) */ 28 const char *qop; 29 const char *nc; 30 const char *nonce; 31 const char *cnonce; 32 }; 33 34 static inline int base64_len(int len) 35 { 36 return ((len + 2) / 3) * 4; 37 } 38 39 void base64_encode(const void *inbuf, unsigned int len, void *out); 40 void bin_to_hex(char *dest, const void *buf, int len); 41 42 int uclient_urldecode(const char *in, char *out, bool decode_plus); 43 44 void http_digest_calculate_auth_hash(char *dest, const char *user, const char *realm, const char *password); 45 void http_digest_calculate_response(char *dest, const struct http_digest_data *data); 46 47 char *uclient_get_url_filename(const char *url, const char *default_name); 48 49 #endif 50
This page was automatically generated by LXR 0.3.1. • OpenWrt