*** empty log message ***
[h316.git] / pc-tools / ldc2 / src / tool.cpp
index acebb5efc57573635a0d91f1a96885f36cfc16e8..b33e0279c82cfc811dcebe710f2c8535b7277103 100644 (file)
@@ -7,36 +7,31 @@
 
 using namespace std;
 
+
 /*!
- *\brief Output a vector of strings to out_fd.
+ *\brief Output a vector of strings.
  *\arg strings A vector containing text.
+ *\arg fp A FILE pointer where to write to.
  *\retval 0 The vector was empty.
  *\retval 1 The vector contained text.
  */
-int dump_vector(vector<string> strings){
+int dump_vector_fp(vector<string> strings, FILE * fp){
   int res=0;
   for (vector<string>::iterator iter=strings.begin();iter<strings.end();iter++){
-    char buffer[50000];
-    snprintf(buffer,50000,"%s\n",(*iter).c_str());
-    write (out_fd,buffer,strlen(buffer));
+    fprintf(fp,"%s\n",
+           iter->substr(0,iter->find_last_not_of(" ")+1).c_str());
     res=1;
   }
   return res;
 }
 
 /*!
- *\brief Output a vector of strings to stderr.
+ *\brief Output a vector of strings to out_fd.
  *\arg strings A vector containing text.
  *\retval 0 The vector was empty.
  *\retval 1 The vector contained text.
  */
-int dump_vector_err(vector<string> strings){
-  int res=0;
-  for (vector<string>::iterator iter=strings.begin();iter<strings.end();iter++){
-    char buffer[50000];
-    snprintf(buffer,50000,"%s\n",(*iter).c_str());
-    write (2,buffer,strlen(buffer));
-    res=1;
-  }
-  return res;
+int dump_vector(vector<string> strings){
+  FILE * fp=fdopen(out_fd,"w");
+  return dump_vector_fp(strings,fp);
 }