demo (UN)USE_FEATURE... usage
This commit is contained in:
parent
6732af2766
commit
9a51540b15
@ -240,16 +240,12 @@ typedef struct
|
|||||||
{
|
{
|
||||||
char buf[MAX_MEMORY_BUFF];
|
char buf[MAX_MEMORY_BUFF];
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
|
USE_FEATURE_HTTPD_BASIC_AUTH(const char *realm;)
|
||||||
const char *realm;
|
USE_FEATURE_HTTPD_BASIC_AUTH(char *remoteuser;)
|
||||||
char *remoteuser;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *query;
|
const char *query;
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_CGI
|
USE_FEATURE_HTTPD_CGI(char *referer;)
|
||||||
char *referer;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *configFile;
|
const char *configFile;
|
||||||
|
|
||||||
@ -1991,39 +1987,42 @@ static void sighup_handler(int sig)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum httpd_opts_nums {
|
||||||
|
c_opt_config_file = 0,
|
||||||
|
d_opt_decode_url,
|
||||||
|
h_opt_home_httpd,
|
||||||
|
USE_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,)
|
||||||
|
USE_FEATURE_HTTPD_BASIC_AUTH(r_opt_realm,)
|
||||||
|
USE_FEATURE_HTTPD_AUTH_MD5(m_opt_md5,)
|
||||||
|
USE_FEATURE_HTTPD_SETUID(u_opt_setuid,)
|
||||||
|
UNUSE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(p_opt_port,)
|
||||||
|
};
|
||||||
|
|
||||||
static const char httpd_opts[]="c:d:h:"
|
static const char httpd_opts[]="c:d:h:"
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
|
USE_FEATURE_HTTPD_ENCODE_URL_STR("e:")
|
||||||
"e:"
|
USE_FEATURE_HTTPD_BASIC_AUTH("r:")
|
||||||
#endif
|
USE_FEATURE_HTTPD_AUTH_MD5("m:")
|
||||||
#define OPT_INC_1 ENABLE_FEATURE_HTTPD_ENCODE_URL_STR
|
USE_FEATURE_HTTPD_SETUID("u:")
|
||||||
|
UNUSE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY("p:");
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
|
#define OPT_CONFIG_FILE (1<<c_opt_config_file)
|
||||||
"r:"
|
#define OPT_DECODE_URL (1<<d_opt_decode_url)
|
||||||
#endif
|
#define OPT_HOME_HTTPD (1<<h_opt_home_httpd)
|
||||||
#define OPT_INC_2 ENABLE_FEATURE_HTTPD_BASIC_AUTH
|
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5
|
#define OPT_ENCODE_URL USE_FEATURE_HTTPD_ENCODE_URL_STR((1<<e_opt_encode_url)) \
|
||||||
"m:"
|
UNUSE_FEATURE_HTTPD_ENCODE_URL_STR(0)
|
||||||
#endif
|
|
||||||
#define OPT_INC_3 ENABLE_FEATURE_HTTPD_AUTH_MD5
|
|
||||||
|
|
||||||
#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
|
#define OPT_REALM USE_FEATURE_HTTPD_BASIC_AUTH((1<<r_opt_realm)) \
|
||||||
"p:"
|
UNUSE_FEATURE_HTTPD_BASIC_AUTH(0)
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_SETUID
|
|
||||||
"u:"
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
#define OPT_CONFIG_FILE (1<<0) /* c */
|
#define OPT_MD5 USE_FEATURE_HTTPD_AUTH_MD5((1<<m_opt_md5)) \
|
||||||
#define OPT_DECODE_URL (1<<1) /* d */
|
UNUSE_FEATURE_HTTPD_AUTH_MD5(0)
|
||||||
#define OPT_HOME_HTTPD (1<<2) /* h */
|
|
||||||
#define OPT_ENCODE_URL (1<<(2+OPT_INC_1)) /* e */
|
#define OPT_SETUID USE_FEATURE_HTTPD_SETUID((1<<u_opt_setuid)) \
|
||||||
#define OPT_REALM (1<<(2+OPT_INC_1+OPT_INC_2)) /* r */
|
UNUSE_FEATURE_HTTPD_SETUID(0)
|
||||||
#define OPT_MD5 (1<<(2+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* m */
|
|
||||||
#define OPT_PORT (1<<(3+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* p */
|
#define OPT_PORT UNUSE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<p_opt_port)) \
|
||||||
#define OPT_SETUID (1<<(4+OPT_INC_1+OPT_INC_2+OPT_INC_3)) /* u */
|
USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
|
||||||
|
|
||||||
|
|
||||||
#ifdef HTTPD_STANDALONE
|
#ifdef HTTPD_STANDALONE
|
||||||
@ -2035,22 +2034,14 @@ int httpd_main(int argc, char *argv[])
|
|||||||
unsigned long opt;
|
unsigned long opt;
|
||||||
const char *home_httpd = home;
|
const char *home_httpd = home;
|
||||||
char *url_for_decode;
|
char *url_for_decode;
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
|
USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
|
||||||
const char *url_for_encode;
|
UNUSE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(const char *s_port;)
|
||||||
#endif
|
UNUSE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(int server;)
|
||||||
#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
|
|
||||||
const char *s_port;
|
|
||||||
int server;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_SETUID
|
USE_FEATURE_HTTPD_SETUID(const char *s_uid;)
|
||||||
const char *s_uid;
|
USE_FEATURE_HTTPD_SETUID(long uid = -1;)
|
||||||
long uid = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5
|
USE_FEATURE_HTTPD_AUTH_MD5(const char *pass;)
|
||||||
const char *pass;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
config = xcalloc(1, sizeof(*config));
|
config = xcalloc(1, sizeof(*config));
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
|
#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
|
||||||
@ -2065,22 +2056,12 @@ int httpd_main(int argc, char *argv[])
|
|||||||
|
|
||||||
opt = bb_getopt_ulflags(argc, argv, httpd_opts,
|
opt = bb_getopt_ulflags(argc, argv, httpd_opts,
|
||||||
&(config->configFile), &url_for_decode, &home_httpd
|
&(config->configFile), &url_for_decode, &home_httpd
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
|
USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode)
|
||||||
, &url_for_encode
|
USE_FEATURE_HTTPD_BASIC_AUTH(, &(config->realm))
|
||||||
#endif
|
USE_FEATURE_HTTPD_AUTH_MD5(, &pass)
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
|
USE_FEATURE_HTTPD_SETUID(, &s_uid)
|
||||||
, &(config->realm)
|
UNUSE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(, &s_port)
|
||||||
# ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5
|
);
|
||||||
, &pass
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
|
|
||||||
, &s_port
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_FEATURE_HTTPD_SETUID
|
|
||||||
, &s_uid
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
if(opt & OPT_DECODE_URL) {
|
if(opt & OPT_DECODE_URL) {
|
||||||
printf("%s", decodeString(url_for_decode, 1));
|
printf("%s", decodeString(url_for_decode, 1));
|
||||||
|
Loading…
Reference in New Issue
Block a user