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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 472 by aramv, Tue Jun 23 13:05:50 2009 UTC revision 473 by aramv, Wed Jun 24 14:25:36 2009 UTC
# Line 1  Line 1 
1  #include "plugin_manager.h"  #include "plugin_manager.h"
2    #include "aos.h"
3  #include "nextgen.h"  #include "nextgen.h"
4  #include "ng_log.h"  #include "ng_log.h"
5  #include <string.h>  #include <string.h>
6  #include <stdlib.h>  #include <stdlib.h>
7  #include <stdarg.h>  #include <stdarg.h>
8  #include <unistd.h>  #include <unistd.h>
9    #include <errno.h>
10    #include <sys/stat.h>
11    #include <sys/fcntl.h>
12    
13    
14    
15  int main (void){  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();          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();          NG_Term();
58    
59          return 0;          return 0;

Legend:
Removed from v.472  
changed lines
  Added in v.473

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