/[pdpsoft]/trunk/grid-mw-security/ees/src/app/main.c
ViewVC logotype

Contents of /trunk/grid-mw-security/ees/src/app/main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 525 - (show annotations) (download) (as text)
Wed Jul 15 08:55:01 2009 UTC (12 years, 6 months ago) by aramv
File MIME type: text/x-chdr
File size: 1729 byte(s)
Wored on parser, trying to fix memleaks
1 #include "nextgen.h"
2 #include "aos.h"
3 #include "ees_config.h"
4 #include "pdl.h"
5 #include <string.h>
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <stdarg.h>
9 #include <unistd.h>
10 #include <errno.h>
11 #include <sys/stat.h>
12 #include <sys/fcntl.h>
13
14
15
16 int main (void){
17 int _fd = 0;
18 char *_string = NULL;
19 char *file = "/home/aczid/.globus/usercert.pem";
20 char *config_file = "/home/aczid/example_1.pdl";
21 struct stat _stat;
22 if(pdl_init(config_file) == NG_SUCCESS){
23 yyparse();
24 if(pdl_term() == NG_FAILURE) {
25 printf("PDL failed\n");
26 } else {
27 printf("PDL failed\n");
28 }
29 }
30
31 printf("Modules dir: %s\n", MODULE_DIR);
32
33 if(NG_Init() == NG_FAILURE){
34 return NG_FAILURE;
35 }
36
37 if((_fd = open(file, O_RDONLY)) == -1){
38 ng_log(LOG_ERR, "Cannot open file %s: %s\n", file, strerror(errno));
39 exit(1);
40 }
41
42 if(fstat(_fd, &_stat) == -1){
43 ng_log(LOG_ERR, "Cannot stat file %s: %s\n", file, strerror(errno));
44 exit(1);
45 }
46
47 _string = calloc(1, (_stat.st_size+1)*sizeof(char));
48
49 if(((read(_fd, _string, _stat.st_size))) == -1){
50 ng_log(LOG_ERR, "Cannot read file %s\n", file);
51 exit(1);
52 } else {
53 printf("Read %lld bytes from file '%s'\n", (long long int) _stat.st_size, file);
54 }
55
56 close(_fd);
57
58 /*_string[_stat.st_size] = '\0';*/
59
60
61 /*ng_log(LOG_ERR,"My PEM string: %s\n", _string);*/
62
63 /*AOS_set_string("fooskldfjlskdjfkl;sjfl;sdjfl;dsjl;fjsdlfjsldfjsdkfj", "bar");*/
64
65 /*AOS_set_string("my_pemstring", "bladiebladiebla");*/
66 /*AOS_set_string("foo", "barbaz");*/
67
68 AOS_set_string("my_pemstring", _string);
69
70 /*NG_Run("plugin_a");*/
71 /*NG_Run("plugin_b");*/
72
73 /*ng_log(LOG_ERR, "My PEM string: %s\n", (char*) AOS_get_value_by_label("my_pemstring"));*/
74
75 free(_string);
76
77 NG_Term();
78
79 return 0;
80 }

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28