summaryrefslogtreecommitdiff
path: root/ACE/netsvcs/clients/Naming/Dump_Restore/createfile.cpp
blob: 0b2925b32023e346ff2259bae787d1857a52fc49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// $Id$

#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_string.h"
#include "ace/ACE.h"

ACE_RCSID(Dump_Restore, createfile, "$Id$")

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  FILE *infile, *outfile;
  char buf[BUFSIZ];

  if ((infile = ACE_OS::fopen (argv[1], "r")) == 0)
    return -1;

  if ((outfile = ACE_OS::fopen (argv[2], "w")) == 0)
    return -1;

  int count = 0;
  while (ACE_OS::fgets (buf, BUFSIZ, infile))
    {
      buf[ACE_OS::strlen(buf) - 1] = '\0';
      ACE_OS::fputs (buf, outfile);
      if (count % 2 == 0)
        ACE_OS::fputs (" ", outfile);
      else
        ACE_OS::fputs ("\n", outfile);
      count++;
    }

  ACE_OS::fclose (outfile);
  ACE_OS::fclose (infile);
}