b33e0279c82cfc811dcebe710f2c8535b7277103
[h316.git] / pc-tools / ldc2 / src / tool.cpp
1 #include <vector>
2 #include <string>
3
4 #include <stdio.h>
5
6 #include "config.hh"
7
8 using namespace std;
9
10
11 /*!
12 *\brief Output a vector of strings.
13 *\arg strings A vector containing text.
14 *\arg fp A FILE pointer where to write to.
15 *\retval 0 The vector was empty.
16 *\retval 1 The vector contained text.
17 */
18 int dump_vector_fp(vector<string> strings, FILE * fp){
19 int res=0;
20 for (vector<string>::iterator iter=strings.begin();iter<strings.end();iter++){
21 fprintf(fp,"%s\n",
22 iter->substr(0,iter->find_last_not_of(" ")+1).c_str());
23 res=1;
24 }
25 return res;
26 }
27
28 /*!
29 *\brief Output a vector of strings to out_fd.
30 *\arg strings A vector containing text.
31 *\retval 0 The vector was empty.
32 *\retval 1 The vector contained text.
33 */
34 int dump_vector(vector<string> strings){
35 FILE * fp=fdopen(out_fd,"w");
36 return dump_vector_fp(strings,fp);
37 }