/[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 473 - (show annotations) (download) (as text)
Wed Jun 24 14:25:36 2009 UTC (12 years, 6 months ago) by aramv
File MIME type: text/x-chdr
File size: 1236 byte(s)
Added test code for l[4~oading a PEM file into the AOS.
1 #include "plugin_manager.h"
2 #include "aos.h"
3 #include "nextgen.h"
4 #include "ng_log.h"
5 #include <string.h>
6 #include <stdlib.h>
7 #include <stdarg.h>
8 #include <unistd.h>
9 #include <errno.h>
10 #include <sys/stat.h>
11 #include <sys/fcntl.h>
12
13
14
15 int main (void){
16 int _fd = 0;
17 char *_string = NULL;
18 char *file = "/home/aczid/.globus/usercert.pem";
19 struct stat _stat;
20
21
22 if((_fd = open(file, O_RDONLY)) == -1){
23 ng_log(LOG_ERR, "Cannot open file %s: %s\n", file, strerror(errno));
24 exit(1);
25 }
26
27 if(fstat(_fd, &_stat) == -1){
28 ng_log(LOG_ERR, "Cannot stat file %s: %s\n", file, strerror(errno));
29 exit(1);
30 }
31
32 _string = calloc(1, (_stat.st_size+1)*sizeof(char));
33
34 if(((read(_fd, _string, _stat.st_size))) == -1){
35 ng_log(LOG_ERR, "Cannot read file %s\n", file);
36 exit(1);
37 } else {
38 printf("Read %lld bytes from file '%s'\n", (long long int) _stat.st_size, file);
39 }
40
41 close(_fd);
42
43 _string[_stat.st_size] = '\0';
44
45 NG_Init();
46
47 /*ng_log(LOG_ERR,"My PEM string: %s\n", _string);*/
48
49 /*AOS_set_string("fooskldfjlskdjfkl;sjfl;sdjfl;dsjl;fjsdlfjsldfjsdkfj", "bar");*/
50
51 AOS_set_string("my_pemstring", _string);
52
53 /*printf("My PEM string: %s\n", (char*) AOS_get_value_by_label("my_pemstring"));*/
54
55 free(_string);
56
57 NG_Term();
58
59 return 0;
60 }

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