Julian Hall | 8cff2b8 | 2020-11-23 18:12:17 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef SERVICE_NAME_H |
| 8 | #define SERVICE_NAME_H |
| 9 | |
| 10 | #include <stdbool.h> |
| 11 | #include <stddef.h> |
| 12 | |
| 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | /* |
| 18 | * Check if it is valid service name with all the mandatory sections. |
| 19 | */ |
| 20 | bool sn_is_valid(const char *sn); |
| 21 | |
| 22 | /* |
| 23 | * Check naming authority. Returns true for match. |
| 24 | */ |
| 25 | bool sn_check_authority(const char *sn, const char *auth); |
| 26 | |
| 27 | /* |
| 28 | * Check the service portion of the service name. Returns true for match. |
| 29 | */ |
| 30 | bool sn_check_service(const char *sn, const char *service); |
| 31 | |
| 32 | /* |
| 33 | * Get the service instance number |
| 34 | */ |
| 35 | unsigned int sn_get_service_instance(const char *sn); |
| 36 | |
| 37 | /* |
| 38 | * Read the service field and copy the null terminated string |
| 39 | * to the provided buffer. Returns the copied string length, |
| 40 | * minus the zero terminator. |
| 41 | */ |
| 42 | size_t sn_read_service(const char *sn, char *buf, size_t buf_len); |
| 43 | |
| 44 | |
| 45 | #ifdef __cplusplus |
| 46 | } |
| 47 | #endif |
| 48 | |
| 49 | #endif /* SERVICE_NAME_H */ |