aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--configure.ac2
-rw-r--r--include/samsung-ipc.h1
-rw-r--r--samsung-ipc/ipc_strings.c20
3 files changed, 22 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index d59ef0f..4246af8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([libsamsung-ipc], [0.6.0], [replicant@osuosl.org], [libsamsung-ipc])
+AC_INIT([libsamsung-ipc], [0.7.0], [replicant@osuosl.org], [libsamsung-ipc])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([dist-bzip2 dist-xz subdir-objects])
diff --git a/include/samsung-ipc.h b/include/samsung-ipc.h
index 53f1f72..d9aa7c7 100644
--- a/include/samsung-ipc.h
+++ b/include/samsung-ipc.h
@@ -138,6 +138,7 @@ const char *ipc_request_type_string(unsigned char type);
const char *ipc_response_type_string(unsigned char type);
const char *ipc_command_string(unsigned short command);
const char *ipc_group_string(unsigned char group);
+const char *ipc_client_type_string(unsigned char client_type);
int ipc_data_dump(struct ipc_client *client, const void *data, size_t size);
void ipc_client_log_send(struct ipc_client *client, struct ipc_message *message,
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;
+ }
+}