mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-06 13:17:44 +03:00
core/socket: add socket_port_type_from_string()
This commit is contained in:
parent
836bb1cd42
commit
038ed5a4b6
@ -2780,6 +2780,23 @@ const char* socket_port_type_to_string(SocketPort *p) {
|
||||
}
|
||||
}
|
||||
|
||||
SocketType socket_port_type_from_string(const char *s) {
|
||||
assert(s);
|
||||
|
||||
if (STR_IN_SET(t, "Stream", "Datagram", "SequentialPacket", "Netlink"))
|
||||
return = SOCKET_SOCKET;
|
||||
else if (streq(t, "Special"))
|
||||
return = SOCKET_SPECIAL;
|
||||
else if (streq(t, "MessageQueue"))
|
||||
return = SOCKET_MQUEUE;
|
||||
else if (streq(t, "FIFO"))
|
||||
return = SOCKET_FIFO;
|
||||
else if (streq(t, "USBFunction"))
|
||||
return = SOCKET_USB_FUNCTION;
|
||||
else
|
||||
return _SOCKET_TYPE_INVALID;
|
||||
}
|
||||
|
||||
_pure_ static bool socket_check_gc(Unit *u) {
|
||||
Socket *s = SOCKET(u);
|
||||
|
||||
|
@ -43,8 +43,8 @@ typedef enum SocketType {
|
||||
SOCKET_SPECIAL,
|
||||
SOCKET_MQUEUE,
|
||||
SOCKET_USB_FUNCTION,
|
||||
_SOCKET_FIFO_MAX,
|
||||
_SOCKET_FIFO_INVALID = -1
|
||||
_SOCKET_TYPE_MAX,
|
||||
_SOCKET_TYPE_INVALID = -1
|
||||
} SocketType;
|
||||
|
||||
typedef enum SocketResult {
|
||||
@ -194,3 +194,4 @@ const char* socket_result_to_string(SocketResult i) _const_;
|
||||
SocketResult socket_result_from_string(const char *s) _pure_;
|
||||
|
||||
const char* socket_port_type_to_string(SocketPort *p) _pure_;
|
||||
SocketType socket_port_type_from_string(const char *p) _pure_;
|
||||
|
Loading…
Reference in New Issue
Block a user