aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-03-10 18:45:46 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-09-01 15:41:48 +0200
commit119a54a4c1fa321c8f82dc31aa66a24db244ba03 (patch)
treefb7b7f8e89543ac6d0dc59407a6e97cb2dbd473e /samsung-ipc
parente9d55ae583fb3cb8384fbbd21d873f8b9b5b5a46 (diff)
downloadhardware_replicant_libsamsung-ipc-119a54a4c1fa321c8f82dc31aa66a24db244ba03.tar.gz
hardware_replicant_libsamsung-ipc-119a54a4c1fa321c8f82dc31aa66a24db244ba03.tar.bz2
hardware_replicant_libsamsung-ipc-119a54a4c1fa321c8f82dc31aa66a24db244ba03.zip
Add ipc_client_type_string
When working on applications using libsamsung-ipc, we sometimes have functions that have an ipc client type argument and that work for all 3 ipc client types, or want to refactorize the code to do that in order to make the code more clean and generic. However in these cases, these functions often needed to output some error message or tell users what is going on through logging prints, and the code ends up being way cleaner if there is a generic function to get the name of the ipc client type. In many cases it makes sense not to use the full IPC_CLIENT_TYPE_<type> name but only the <name> type in these messages, so because it's easier to add IPC_CLIENT_TYPE_ to the <type> than removing it, it makes sense to only return the string associated to the type (like "FMT", "RFS" or "DUMMY". The least significant number of the library version was also bumped as we are adding a new function, but the applications that were built against older libsamsung-ipc revisions should still work. However applications that depends on this ipc_client_type_string will not work with previous versions of libsamsung-ipc. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/ipc_strings.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/samsung-ipc/ipc_strings.c b/samsung-ipc/ipc_strings.c
index 0922832..4d130b3 100644
--- a/samsung-ipc/ipc_strings.c
+++ b/samsung-ipc/ipc_strings.c
@@ -387,3 +387,23 @@ const char *ipc_group_string(unsigned char group)
return group_string;
}
}
+
+const char *ipc_client_type_string(unsigned char client_type)
+{
+ static char client_type_string[5] = { 0 };
+
+ switch (client_type) {
+ case IPC_CLIENT_TYPE_FMT:
+ return "FMT";
+ case IPC_CLIENT_TYPE_RFS:
+ return "RFS";
+ case IPC_CLIENT_TYPE_DUMMY:
+ return "DUMMY";
+ default:
+ snprintf((char *) &client_type_string,
+ sizeof(client_type_string),
+ "0x%02x",
+ client_type);
+ return client_type_string;
+ }
+}