/[zanavi_public1]/navit/navit/param.c
ZANavi

Contents of /navit/navit/param.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (12 years, 5 months ago) by zoff99
File MIME type: text/plain
File size: 1786 byte(s)
import files
1 /**
2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include <stdio.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include "param.h"
24
25 void
26 param_add_string(char *name, char *value, struct param_list **param, int *count)
27 {
28 if (*count > 0) {
29 (*param)->name=malloc(strlen(value)+strlen(name)+2);
30 (*param)->value=(*param)->name+strlen(name)+1;
31 strcpy((*param)->name, name);
32 strcpy((*param)->value, value);
33 (*count)--;
34 (*param)++;
35 }
36
37 }
38
39 void
40 param_add_dec(char *name, unsigned long value, struct param_list **param, int *count)
41 {
42 char buffer[1024];
43 sprintf(buffer, "%ld", value);
44 param_add_string(name, buffer, param, count);
45 }
46
47
48 void
49 param_add_hex(char *name, unsigned long value, struct param_list **param, int *count)
50 {
51 char buffer[1024];
52 sprintf(buffer, "0x%lx", value);
53 param_add_string(name, buffer, param, count);
54 }
55
56 void
57 param_add_hex_sig(char *name, long value, struct param_list **param, int *count)
58 {
59 char buffer[1024];
60 if (value < 0)
61 sprintf(buffer, "-0x%lx", -value);
62 else
63 sprintf(buffer, "0x%lx", value);
64 param_add_string(name, buffer, param, count);
65 }

   
Visit the ZANavi Wiki