Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
analysis.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, 2013 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
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 Free Software
16  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #include <argp.h>
20 
21 #include "log.h"
22 #include "analysis.h"
23 #include "generic_rpc.h"
24 #include "analysis_rpc.h"
25 
26 /* Pull in gsoap-generated namespace array. */
27 #include "analysis.nsmap"
28 
30  struct analysis_rpc_config *cfg;
31  struct soap *soap;
32 };
33 
34 #define ARGP_KEY_ANALYSIS_PATH 4096
35 #define ARGP_KEY_SCHEMA_PATH 4097
36 #define ARGP_KEY_ANNOTATION_PATH 4098
37 
38 struct argp_option analysis_rpc_argp_opts[] = {
39  { "analysis-path",ARGP_KEY_ANALYSIS_PATH,"PATH",0,
40  "Set the analysis description PATH.",0 },
41  { "schema-path",ARGP_KEY_SCHEMA_PATH,"PATH",0,
42  "Set the schema PATH.",0 },
43  { "annotation-path",ARGP_KEY_ANNOTATION_PATH,"PATH",0,
44  "Set the annotation PATH.",0 },
45  { 0,0,0,0,0,0 }
46 };
47 
48 error_t analysis_rpc_argp_parse_opt(int key,char *arg,struct argp_state *state) {
49  struct analysis_rpc_config *cfg = (struct analysis_rpc_config *)state->input;
50 
51  switch (key) {
52  case ARGP_KEY_ARG:
53  case ARGP_KEY_ARGS:
54  return ARGP_ERR_UNKNOWN;
55  case ARGP_KEY_END:
56  case ARGP_KEY_NO_ARGS:
57  case ARGP_KEY_SUCCESS:
58  case ARGP_KEY_ERROR:
59  case ARGP_KEY_FINI:
60  return 0;
61  case ARGP_KEY_INIT:
62  /* Pass the config obj directly to our first child. */
63  state->child_inputs[0] = cfg;
64  return 0;
65 
68  break;
71  break;
74  break;
75 
76  default:
77  return ARGP_ERR_UNKNOWN;
78  }
79 
80  return 0;
81 }
82 
83 const struct argp_child analysis_rpc_argp_children[2] = {
85  { NULL,0,NULL,0 },
86 };
87 
88 struct argp analysis_rpc_argp = {
90  NULL,"Analysis RPC Server Options",analysis_rpc_argp_children,NULL,NULL
91 };
92 
93 int main(int argc, char **argv) {
94  struct generic_rpc_config cfg;
95 
96  if (argp_parse(&analysis_rpc_argp,argc,argv,0,NULL,&cfg))
97  exit(errno);
98 
100 
101  atexit(analysis_rpc_fini);
102 
103  /*
104  * Setup some config options.
105  *
106  * First, do the signals we want our dedicated sighandling thread to catch.
107  * Then set the name and our primary handler. That's it!
108  */
109  sigemptyset(&cfg.sigset);
110  //sigaddset(&cfg.sigset,SIGINT);
111  sigaddset(&cfg.sigset,SIGCHLD);
112  sigaddset(&cfg.sigset,SIGPIPE);
113 
114  cfg.name = "target";
115 
117 
118  return generic_rpc_serve(&cfg);
119 }
int analysis_rpc_handle_request(struct soap *soap)
Definition: analysis_rpc.c:159
int generic_rpc_serve(struct generic_rpc_config *cfg)
Definition: generic_rpc.c:349
struct argp generic_rpc_argp
Definition: generic_rpc.c:261
#define ARGP_KEY_ANALYSIS_PATH
Definition: analysis.c:34
void analysis_rpc_fini(void)
Definition: analysis_rpc.c:110
#define ARGP_KEY_SCHEMA_PATH
Definition: analysis.c:35
struct argp analysis_rpc_argp
Definition: analysis.c:88
#define generic_rpc_argp_header
Definition: generic_rpc.h:33
void analysis_set_path_string(const char *path)
Definition: analysis.c:732
struct analysis_rpc_config * cfg
Definition: analysis.c:30
int main(int argc, char **argv)
Definition: analysis.c:93
struct soap * soap
Definition: analysis.c:31
const struct argp_child analysis_rpc_argp_children[2]
Definition: analysis.c:83
void analysis_rpc_init(void)
Definition: analysis_rpc.c:86
error_t analysis_rpc_argp_parse_opt(int key, char *arg, struct argp_state *state)
Definition: analysis.c:48
#define ARGP_KEY_ANNOTATION_PATH
Definition: analysis.c:36
int(* handle_request)(struct soap *soap)
Definition: generic_rpc.h:51
void analysis_set_schema_path_string(const char *path)
Definition: analysis.c:788
void analysis_set_annotation_path_string(const char *path)
Definition: analysis.c:760
struct argp_option analysis_rpc_argp_opts[]
Definition: analysis.c:38