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