2 * This file is part of libsamsung-ipc.
4 * Copyright (C) 2011 Simon Busch <morphis@gravedo.de>
5 * Copyright (C) 2011-2014 Paul Kocialkowski <contact@paulk.fr>
7 * libsamsung-ipc is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
12 * libsamsung-ipc is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
24 #include <samsung-ipc.h>
26 int ipc_sec_pin_status_setup(struct ipc_sec_pin_status_request_data *data,
27 unsigned char type, const char *pin1, const char *pin2)
35 memset(data, 0, sizeof(struct ipc_sec_pin_status_request_data));
39 pin1_length = strlen(pin1);
40 if (pin1_length > sizeof(data->pin1))
41 pin1_length = sizeof(data->pin1);
43 data->pin1_length = (unsigned char) pin1_length;
44 strncpy((char *) data->pin1, pin1, pin1_length);
48 pin2_length = strlen(pin2);
49 if (pin2_length > sizeof(data->pin2))
50 pin2_length = sizeof(data->pin2);
52 data->pin2_length = (unsigned char) pin2_length;
53 strncpy((char *) data->pin2, pin2, pin2_length);
59 int ipc_sec_phone_lock_request_set_setup(struct ipc_sec_phone_lock_request_set_data *data,
60 unsigned char facility_type, unsigned char active, const char *password)
62 size_t password_length;
67 memset(data, 0, sizeof(struct ipc_sec_phone_lock_request_set_data));
68 data->facility_type = facility_type;
69 data->active = active;
71 if (password != NULL) {
72 password_length = strlen(password);
73 if (password_length > sizeof(data->password))
74 password_length = sizeof(data->password);
76 data->password_length = (unsigned char) password_length;
77 strncpy((char *) data->password, password, password_length);
79 data->password_length = 0;
85 int ipc_sec_change_locking_pw_setup(struct ipc_sec_change_locking_pw_data *data,
86 unsigned char facility_type, const char *password_old,
87 const char *password_new)
89 size_t password_old_length;
90 size_t password_new_length;
95 memset(data, 0, sizeof(struct ipc_sec_change_locking_pw_data));
96 data->facility_type = facility_type;
98 if (password_old != NULL) {
99 password_old_length = strlen(password_old);
100 if (password_old_length > sizeof(data->password_old))
101 password_old_length = sizeof(data->password_old);
103 data->password_old_length = (unsigned char) password_old_length;
104 strncpy((char *) data->password_old, password_old, password_old_length);
106 data->password_old_length = 0;
109 if (password_new != NULL) {
110 password_new_length = strlen(password_new);
111 if (password_new_length > sizeof(data->password_new))
112 password_new_length = sizeof(data->password_new);
114 data->password_new_length = (unsigned char) password_new_length;
115 strncpy((char *) data->password_new, password_new, password_new_length);
117 data->password_new_length = 0;
123 void *ipc_sec_rsim_access_setup(struct ipc_sec_rsim_access_request_header *header,
124 const void *sim_io_data, size_t sim_io_size)
133 if (sim_io_data == NULL)
136 size = sizeof(struct ipc_sec_rsim_access_request_header) + sim_io_size;
138 data = calloc(1, size);
140 p = (unsigned char *) data;
142 memcpy(p, header, sizeof(struct ipc_sec_rsim_access_request_header));
143 p += sizeof(struct ipc_sec_rsim_access_request_header);
145 if (sim_io_data != NULL && sim_io_size > 0) {
146 memcpy(p, sim_io_data, sim_io_size);
153 int ipc_sec_lock_infomation_setup(struct ipc_sec_lock_infomation_request_data *data,
159 memset(data, 0, sizeof(struct ipc_sec_lock_infomation_request_data));
166 // vim:ts=4:sw=4:expandtab