My Project
0.0.16
QUCS Mapping
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
DownLoad
QUCS-src
qucs-0.0.16
qucs-core
src
gperfappgen.cpp
Go to the documentation of this file.
1
/*
2
* gperfappgen.cpp - generates the gperf input file
3
*
4
* Copyright (C) 2005 Stefan Jahn <stefan@lkcc.org>
5
*
6
* This is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* This software is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this package; see the file COPYING. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19
* Boston, MA 02110-1301, USA.
20
*
21
* $Id: gperfappgen.cpp 1825 2011-03-11 20:42:14Z ela $
22
*
23
*/
24
25
#if HAVE_CONFIG_H
26
# include <config.h>
27
#endif
28
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <string.h>
32
33
#include "
evaluate.h
"
34
#include "
equation.h
"
35
36
using namespace
eqn
;
37
38
#include "gperfappgen.h"
39
40
/* The program is used to generate the input file for a gperf run. */
41
int
main
(
void
) {
42
43
struct
application_t * app;
44
char
* key;
45
int
len,
n
= 0;
46
47
// Print declarations.
48
fprintf
(stdout,
49
"%%language=C++\n"
50
"%%define class-name gperfapphash\n"
51
"%%define lookup-function-name get\n"
52
"%%define slot-name key\n"
53
"%%define word-array-name applist\n"
54
"%%struct-type\n"
55
"struct appindex { const char * key; int index; };\n"
56
"%%%%\n"
);
57
58
// Print hash key list.
59
for
(app =
applications
; app->
application
!= NULL; app++, n++) {
60
key = (
char
*) calloc (1, strlen (app->application) + app->nargs * 3 + 5);
61
strcat (key, app->application);
62
for
(
int
i
= 0;
i
< app->nargs;
i
++) {
63
strcat (key,
"_"
);
64
strcat (key,
checker::tag2key
(app->args[
i
]));
65
}
66
len = strlen (key);
67
fprintf
(stdout,
"\"%s\", %s%s%s%d\n"
, key,
68
len < 12 ?
"\t"
:
""
, len < 20 ?
"\t"
:
""
,
69
len < 28 ?
""
:
""
, n);
70
free (key);
71
}
72
73
return
0;
74
}
Generated on Tue Dec 25 2012 14:30:34 for My Project by
1.8.2