mirror of
https://github.com/samhocevar/rinetd.git
synced 2025-03-22 15:50:08 +08:00
Improve code readability by using enum typedefs.
This commit is contained in:
parent
da497404ab
commit
ebd31cc72e
@ -248,8 +248,8 @@ static void readConfiguration(char const *file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addServer(char *bindAddress, uint16_t bindPort, int bindProto,
|
void addServer(char *bindAddress, uint16_t bindPort, protocolType bindProto,
|
||||||
char *connectAddress, uint16_t connectPort, int connectProto,
|
char *connectAddress, uint16_t connectPort, protocolType connectProto,
|
||||||
int serverTimeout, char *sourceAddress)
|
int serverTimeout, char *sourceAddress)
|
||||||
{
|
{
|
||||||
/* Turn all of this stuff into reasonable addresses */
|
/* Turn all of this stuff into reasonable addresses */
|
||||||
|
@ -46,7 +46,7 @@ extern FILE *logFile;
|
|||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
|
||||||
void addServer(char *bindAddress, uint16_t bindPort, int bindProto,
|
void addServer(char *bindAddress, uint16_t bindPort, protocolType bindProto,
|
||||||
char *connectAddress, uint16_t connectPort, int connectProto,
|
char *connectAddress, uint16_t connectPort, protocolType connectProto,
|
||||||
int serverTimeout, char *sourceAddress);
|
int serverTimeout, char *sourceAddress);
|
||||||
|
|
||||||
|
12
src/types.h
12
src/types.h
@ -11,12 +11,14 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
enum ruleType {
|
typedef enum _rule_type ruleType;
|
||||||
|
enum _rule_type {
|
||||||
allowRule,
|
allowRule,
|
||||||
denyRule,
|
denyRule,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum protocolType {
|
typedef enum _protocol_type protocolType;
|
||||||
|
enum _protocol_type {
|
||||||
protoTcp = 1,
|
protoTcp = 1,
|
||||||
protoUdp = 2,
|
protoUdp = 2,
|
||||||
};
|
};
|
||||||
@ -25,7 +27,7 @@ typedef struct _rule Rule;
|
|||||||
struct _rule
|
struct _rule
|
||||||
{
|
{
|
||||||
char *pattern;
|
char *pattern;
|
||||||
int type;
|
ruleType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _server_info ServerInfo;
|
typedef struct _server_info ServerInfo;
|
||||||
@ -40,7 +42,7 @@ struct _server_info {
|
|||||||
/* In ASCII and local byte order, for logging purposes */
|
/* In ASCII and local byte order, for logging purposes */
|
||||||
char *fromHost, *toHost;
|
char *fromHost, *toHost;
|
||||||
int16_t fromPort, toPort;
|
int16_t fromPort, toPort;
|
||||||
int fromProto, toProto;
|
protocolType fromProto, toProto;
|
||||||
|
|
||||||
/* Offset and count into list of allow and deny rules. Any rules
|
/* Offset and count into list of allow and deny rules. Any rules
|
||||||
prior to globalAllowRules and globalDenyRules are global rules. */
|
prior to globalAllowRules and globalDenyRules are global rules. */
|
||||||
@ -54,7 +56,7 @@ typedef struct _socket Socket;
|
|||||||
struct _socket
|
struct _socket
|
||||||
{
|
{
|
||||||
SOCKET fd;
|
SOCKET fd;
|
||||||
int proto;
|
protocolType proto;
|
||||||
/* recv: received on this socket
|
/* recv: received on this socket
|
||||||
sent: sent through this socket from the other buffer */
|
sent: sent through this socket from the other buffer */
|
||||||
int recvPos, sentPos;
|
int recvPos, sentPos;
|
||||||
|
Loading…
Reference in New Issue
Block a user