some last minute changes

- ifdef network initialization linking for 64-bit
- corrected too largument in windows build script shortcuts
- added LineEndingConverter sample
This commit is contained in:
aleks-f
2012-12-26 18:30:31 -06:00
parent 8147b94f12
commit 9f76b49ac0
24 changed files with 3300 additions and 180 deletions

View File

@@ -0,0 +1,92 @@
//
// LineEndingConverter.cpp
//
// $Id: //poco/1.4/Foundation/samples/LineEndingConverter/src/LineEndingConverter.cpp#1 $
//
// This sample demonstrates the line ending conversion from unix (LF) to windows (CRLF)
// and vice-versa.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/LineEndingConverter.h"
#include "Poco/FileStream.h"
#include "Poco/StreamCopier.h"
#include "Poco/String.h"
#include <sstream>
#include <iostream>
using Poco::InputLineEndingConverter;
using Poco::LineEnding;
using Poco::StreamCopier;
using Poco::FileInputStream;
using Poco::FileOutputStream;
using Poco::icompare;
inline void dosToUnix(std::istream& input, std::ostream& output)
{
InputLineEndingConverter conv(input, LineEnding::NEWLINE_LF);
StreamCopier::copyStream(conv, output);
}
inline void unixToDos(std::istream& input, std::ostream& output)
{
InputLineEndingConverter conv(input, LineEnding::NEWLINE_CRLF);
StreamCopier::copyStream(conv, output);
}
inline int usage()
{
std::cout << "Usage: LineEndingConverter {u2d | d2u} filename" << std::endl;
return -1;
}
int main(int argc, char** argv)
{
if (argc < 3) return usage();
if (strlen(argv[1]) != 3) return usage();
std::string conv(argv[1]);
FileInputStream fis(argv[2]);
std::stringstream ss;
StreamCopier::copyStream(fis, ss);
fis.close();
FileOutputStream fos(argv[2]);
if (0 == icompare(conv, "u2d")) unixToDos(ss, fos);
else if (0 == icompare(conv, "d2u")) dosToUnix(ss, fos);
else return usage();
fos.flush();
return 0;
}