1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*
* SMS Utilities
*
* Copyright (C) 2010 by Multi-Tech Systems
*
* Author: James Maki <jmaki@multitech.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#define _GNU_SOURCE
#define __SMS_UTILS_C 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "global.h"
#include "utils.h"
#include "sms_utils.h"
static const struct {
const char *name;
int value;
} __msg_status_map[] = {
{"REC UNREAD", SMS_MSG_REC_UNREAD},
{"REC READ", SMS_MSG_REC_READ},
{"STO UNSENT", SMS_MSG_STO_UNSENT},
{"STO SENT", SMS_MSG_STO_SENT},
{"ALL", SMS_MSG_ALL},
};
int msg_status_name_to_value(const char *name)
{
int n = ARRAY_SIZE(__msg_status_map);
int i;
for (i = 0; i < n; ++i) {
if (!strcmp(__msg_status_map[i].name, name)) {
return __msg_status_map[i].value;
}
}
log_warning("message status is not valid: %s", name);
return -1;
}
const char *msg_status_value_to_name(int value)
{
int n = ARRAY_SIZE(__msg_status_map);
int i;
for (i = 0; i < n; ++i) {
if (value == __msg_status_map[i].value) {
return __msg_status_map[i].name;
}
}
log_warning("message status is not valid: %d", value);
return NULL;
}
void sms_msg_free(struct sms_msg *msg)
{
free(msg);
}
struct sms_msg *sms_msg_alloc(void)
{
return malloc(sizeof(struct sms_msg));
}
|