Back to index

nordugrid-arc-nox  1.1.0~rc6
main.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <iostream>
00006 #include <fstream>
00007 
00008 #include "LDIFtoXML.h"
00009 
00010 int main(int argc,char* argv[]) {
00011   std::string base;
00012   std::istream* in = &std::cin;
00013   std::istream* fin = NULL;
00014   Arc::NS ns;
00015   Arc::XMLNode xml(ns,"LDIFTree");
00016   int r = -1;
00017   if(argc < 2) {
00018     std::cerr<<"Usage: ldif2xml LDIF_base [input_file [output_file]] "<<std::endl;
00019     return -1;
00020   };
00021   base=argv[1];
00022   if(argc >= 3) in = (fin = new std::ifstream(argv[2]));
00023   if(*in) {
00024     if(ARex::LDIFtoXML(*in,base,xml)) {
00025       std::string s;
00026       xml.GetDoc(s);
00027       if(argc < 4) {
00028         std::cout<<s; r=0;
00029       } else {
00030         std::ofstream f(argv[3]);
00031         if(f) {
00032           f<<s; r=0;
00033         };
00034       };
00035     };
00036   };
00037   if(fin) delete fin;
00038   return r;
00039 }
00040