X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnetwork%2Facl.c;h=1a5d8f09ca9e836c29916e0032fbfa02e2fee789;hb=8134316d83a2a54065ecb48179f93ecdec8b32a1;hp=00f73dd170466ef6575678c7f8a5caef50bd8a12;hpb=6ee1e193fd896ab9a4729fde14f009d9ce629815;p=vlc diff --git a/src/network/acl.c b/src/network/acl.c index 00f73dd170..1a5d8f09ca 100644 --- a/src/network/acl.c +++ b/src/network/acl.c @@ -24,7 +24,11 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include #include #include @@ -40,7 +44,7 @@ typedef struct vlc_acl_entry_t uint8_t host[17]; uint8_t i_bytes_match; uint8_t i_bits_mask; - vlc_bool_t b_allow; + bool b_allow; } vlc_acl_entry_t; struct vlc_acl_t @@ -48,7 +52,7 @@ struct vlc_acl_t vlc_object_t *p_owner; unsigned i_size; vlc_acl_entry_t *p_entries; - vlc_bool_t b_allow_default; + bool b_allow_default; }; static int ACL_Resolve( vlc_object_t *p_this, uint8_t *p_bytes, @@ -150,7 +154,7 @@ int ACL_Check( vlc_acl_t *p_acl, const char *psz_ip ) * Items are always matched in the same order as they are added. */ int ACL_AddNet( vlc_acl_t *p_acl, const char *psz_ip, int i_len, - vlc_bool_t b_allow ) + bool b_allow ) { vlc_acl_entry_t *p_ent; unsigned i_size; @@ -185,9 +189,6 @@ int ACL_AddNet( vlc_acl_t *p_acl, const char *psz_ip, int i_len, if( i_len > 128 ) i_len = 128; - else - if( i_len < 0 ) - i_len = 0; } else i_len = 128; /* ACL_AddHost */ @@ -204,12 +205,12 @@ int ACL_AddNet( vlc_acl_t *p_acl, const char *psz_ip, int i_len, /** * Creates an empty ACL. * - * @param b_allow whether to grant (VLC_TRUE) or deny (VLC_FALSE) access + * @param b_allow whether to grant (true) or deny (false) access * by default (ie if none of the ACL entries matched). * * @return an ACL object. NULL in case of error. */ -vlc_acl_t *__ACL_Create( vlc_object_t *p_this, vlc_bool_t b_allow ) +vlc_acl_t *__ACL_Create( vlc_object_t *p_this, bool b_allow ) { vlc_acl_t *p_acl; @@ -317,8 +318,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) { if( ferror( file ) ) { - msg_Err( p_acl->p_owner, "error reading %s : %s\n", psz_path, - strerror( errno ) ); + msg_Err( p_acl->p_owner, "error reading %s : %m", psz_path ); goto error; } continue; @@ -337,7 +337,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) ptr = strchr( psz_ip, '\n' ); if( ptr == NULL ) { - msg_Warn( p_acl->p_owner, "skipping overly long line in %s\n", + msg_Warn( p_acl->p_owner, "skipping overly long line in %s", psz_path); do { @@ -345,8 +345,8 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) { if( ferror( file ) ) { - msg_Err( p_acl->p_owner, "error reading %s : %s\n", - psz_path, strerror( errno ) ); + msg_Err( p_acl->p_owner, "error reading %s : %m", + psz_path ); } goto error; } @@ -373,11 +373,11 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) *ptr++ = '\0'; /* separate address from mask length */ if( (ptr != NULL) - ? ACL_AddNet( p_acl, psz_ip, atoi( ptr ), VLC_TRUE ) - : ACL_AddHost( p_acl, psz_ip, VLC_TRUE ) ) + ? ACL_AddNet( p_acl, psz_ip, atoi( ptr ), true ) + : ACL_AddHost( p_acl, psz_ip, true ) ) { msg_Err( p_acl->p_owner, "cannot add ACL from %s", psz_path ); - goto error; + continue; } }