1 /* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2 *
3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the License.html file in the root of the source tree.
5 */
6
7 #if defined(STREAM_MISSING)
8 #else
9 #include <iostream>
10 #endif
11 #include <fstream>
12 #include "ZenLib/Ztring.h"
13
14 #ifdef __WINDOWS__
15 #undef __TEXT
16 #include <windows.h>
17 #endif
18
19 //---------------------------------------------------------------------------
20 //Get command line args in main()
21 #ifdef UNICODE
22 #ifdef _WIN32
23 #define GETCOMMANDLINE() \
24 MediaInfoNameSpace::Char** argv=CommandLineToArgvW(GetCommandLineW(), &argc); \
25
26 #else //WIN32
27 #define GETCOMMANDLINE() \
28 std::vector<MediaInfoNameSpace::String> argv; \
29 for (int Pos=0; Pos<argc; Pos++) \
30 { \
31 ZenLib::Ztring A; \
32 A.From_Local(argv_ansi[Pos]); \
33 argv.push_back(A); \
34 } \
35
36 #endif //WIN32
37 #else //UNICODE
38 #define GETCOMMANDLINE() \
39 MediaInfoNameSpace::Char** argv=argv_ansi; \
40
41 #endif //UNICODE
42
43 //---------------------------------------------------------------------------
44 //Write to terminal
STRINGOUT(ZenLib::Ztring Text)45 inline void STRINGOUT(ZenLib::Ztring Text)
46 {
47 #ifdef UNICODE
48 #if defined(STREAM_MISSING)
49 wprintf(L"%ls\n", Text.c_str());
50 #elif defined(_MSC_VER)
51 std::wcout<<Text.c_str()<<std::endl;
52 #else //_MSC_VER
53 std::cout<<Text.To_Local().c_str()<<std::endl;
54 #endif //_MSC_VER
55 #else // UNICODE
56 #if defined(STREAM_MISSING)
57 fprintf(stdout, "%s\n", Text.c_str());
58 #else
59 std::cout<<Text.c_str()<<std::endl;
60 #endif //_MSC_VER
61 #endif // UNICODE
62 }
STRINGERR(ZenLib::Ztring Text)63 inline void STRINGERR(ZenLib::Ztring Text)
64 {
65 #ifdef UNICODE
66 #if defined(STREAM_MISSING)
67 fwprintf(stderr, L"%ls\n", Text.c_str());
68 #elif defined(_MSC_VER)
69 std::wcerr<<Text.c_str()<<std::endl;
70 #else //_MSC_VER
71 std::cerr<<Text.To_Local().c_str()<<std::endl;
72 #endif //_MSC_VER
73 #else // UNICODE
74 #if defined(STREAM_MISSING)
75 fprintf(stderr, "%s\n", Text.c_str());
76 #else
77 std::cerr<<Text.c_str()<<std::endl;
78 #endif //_MSC_VER
79 #endif // UNICODE
80 }
81
TEXTOUT(const char * Text)82 inline void TEXTOUT(const char* Text)
83 {
84 STRINGOUT(ZenLib::Ztring().From_ISO_8859_1(Text));
85 }
86
87 enum MI_Return
88 {
89 MI_OK = 0,
90 MI_ERROR,
91 MI_STOP,
92 MI_ADD,
93 };
94