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 data->facility_type = facility_type;
97 if (password_old != NULL) {
98 password_old_length = strlen(password_old);
99 if (password_old_length > sizeof(data->password_old_length))
100 password_old_length = sizeof(data->password_old_length);
102 data->password_old_length = (unsigned char) password_old_length;
103 strncpy((char *) data->password_old, password_old, password_old_length);
105 data->password_old_length = 0;
108 if (password_new != NULL) {
109 password_new_length = strlen(password_new);
110 if (password_new_length > sizeof(data->password_new_length))
111 password_new_length = sizeof(data->password_new_length);
113 data->password_new_length = (unsigned char) password_new_length;
114 strncpy((char *) data->password_new, password_new, password_new_length);
116 data->password_new_length = 0;
122 void *ipc_sec_rsim_access_file_data_extract(const void *data, size_t size)
124 struct ipc_sec_rsim_access_response_header *header;
127 if (data == NULL || size < sizeof(struct ipc_sec_rsim_access_response_header))
130 header = (struct ipc_sec_rsim_access_response_header *) data;
132 file_data = calloc(1, header->length);
134 memcpy(file_data, (void *) ((unsigned char *) data + sizeof(struct ipc_sec_rsim_access_response_header)), header->length);
139 int ipc_sec_lock_infomation_setup(struct ipc_sec_lock_infomation_request_data *data,
145 memset(data, 0, sizeof(struct ipc_sec_lock_infomation_request_data));
152 // vim:ts=4:sw=4:expandtab