aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc/net.c
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-02-09 13:51:38 +0100
committerPaul Kocialkowski <contact@paulk.fr>2014-02-09 13:51:38 +0100
commit828f125ee5957ee3f64d45329f5ac261a2a3c1a7 (patch)
tree7cb2c2433a4fae20f660dd60819350034ea1ebeb /samsung-ipc/net.c
parent6cb0b59e3f0a7b8f2c9690b7e8d171d88d000270 (diff)
downloadexternal_libsamsung-ipc-828f125ee5957ee3f64d45329f5ac261a2a3c1a7.zip
external_libsamsung-ipc-828f125ee5957ee3f64d45329f5ac261a2a3c1a7.tar.gz
external_libsamsung-ipc-828f125ee5957ee3f64d45329f5ac261a2a3c1a7.tar.bz2
Consistent coding style in helpers
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc/net.c')
-rw-r--r--samsung-ipc/net.c65
1 files changed, 32 insertions, 33 deletions
diff --git a/samsung-ipc/net.c b/samsung-ipc/net.c
index e67f909..2d04bc8 100644
--- a/samsung-ipc/net.c
+++ b/samsung-ipc/net.c
@@ -1,7 +1,8 @@
/*
* This file is part of libsamsung-ipc.
*
- * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com
+ * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com>
+ * Copyright (C) 2014 Paul Kocialkowsk <contact@paulk.fr>
*
* libsamsung-ipc is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,49 +23,47 @@
#include <samsung-ipc.h>
-void ipc_net_regist_setup(struct ipc_net_regist_request_data *message,
- unsigned char domain)
+int ipc_net_plmn_sel_setup(struct ipc_net_plmn_sel_request_data *data,
+ unsigned char mode_sel, const char *plmn, unsigned char act)
{
- message->act = IPC_NET_ACCESS_TECHNOLOGY_UNKNOWN;
- message->domain = domain;
-}
+ size_t plmn_length;
-void ipc_net_plmn_sel_set_setup(struct ipc_net_plmn_sel_request_data *message,
- unsigned char mode, char *plmn, unsigned char act)
-{
- int message_plmn_len;
- int plmn_len;
- int i;
+ if (data == NULL)
+ return -1;
- if (message == NULL)
- return;
+ memset(data, 0, sizeof(struct ipc_net_plmn_sel_request_data));
+ data->mode_sel = mode_sel;
- message_plmn_len = sizeof(message->plmn);
+ if (mode_sel == IPC_NET_PLMN_SEL_AUTO) {
+ data->act = IPC_NET_ACCESS_TECHNOLOGY_UNKNOWN;
+ } else {
+ plmn_length = strlen(plmn);
+ if (plmn_length > sizeof(data->plmn))
+ plmn_length = sizeof(data->plmn);
- memset(message, 0, sizeof(struct ipc_net_plmn_sel_request_data));
+ strncpy((char *) data->plmn, plmn, plmn_length);
+
+ // If there are less (5 is the usual case) PLMN bytes, fill the rest with '#'
+ if (plmn_length < sizeof(data->plmn))
+ memset(data->plmn + plmn_length, '#', sizeof(data->plmn) - plmn_length);
- if (mode == IPC_NET_PLMN_SEL_AUTO)
- {
- message->mode_sel = IPC_NET_PLMN_SEL_AUTO;
- message->act = IPC_NET_ACCESS_TECHNOLOGY_UNKNOWN;
+ data->act = act;
}
- else if (mode == IPC_NET_PLMN_SEL_MANUAL)
- {
- plmn_len = strlen(plmn);
- // Only copy the first (6) bytes if there are more
- if(plmn_len > message_plmn_len)
- plmn_len = message_plmn_len;
+ return 0;
+}
- strncpy(message->plmn, plmn, plmn_len);
+int ipc_net_regist_setup(struct ipc_net_regist_request_data *data,
+ unsigned char domain)
+{
+ if (data == NULL)
+ return -1;
- // If there are less (5 is the usual case) PLMN bytes, fill the rest with '#'
- if (plmn_len < message_plmn_len)
- memset((void *) (message->plmn + plmn_len), '#', message_plmn_len - plmn_len);
+ memset(data, 0, sizeof(struct ipc_net_regist_request_data));
+ data->act = IPC_NET_ACCESS_TECHNOLOGY_UNKNOWN;
+ data->domain = domain;
- message->mode_sel = IPC_NET_PLMN_SEL_MANUAL;
- message->act = act;
- }
+ return 0;
}
// vim:ts=4:sw=4:expandtab