1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: versioner.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_testshl2.hxx"
38 #include "testshl/versionhelper.hxx"
40 #include <rtl/ustring.hxx>
43 // ----------------------------------- Main -----------------------------------
44 #if (defined UNX) || (defined OS2)
45 int main( int, char* argv
[] )
47 int _cdecl
main( int, char* argv
[] )
50 static char const * optionSet
[] = {
51 "-time, display time only",
52 "-date, display date only",
53 "-upd, display UPD only",
54 "-minor, display minor only",
55 "-build, display build only",
56 "-inpath, display inpath only",
57 "-verbose, be verbose",
58 "-h:s, display help or help on option",
63 GetOpt
opt( argv
, optionSet
);
65 // someone indicates that he needs help
66 if ( opt
.hasOpt( "-h" ) || opt
.hasOpt( "-help" ) )
72 if (opt
.getParams().empty())
74 // std::cerr << "error: At least a library should given." << std::endl;
75 fprintf(stderr
, "error: At least a library should given.\n");
80 rtl::OUString suLibraryName
= rtl::OStringToOUString(opt
.getFirstParam(), RTL_TEXTENCODING_ASCII_US
);
81 VersionHelper
aHelper(suLibraryName
, opt
);
83 if (! aHelper
.isOk() )
85 fprintf(stderr
, "error: No version info found.\n");
89 if (opt
.hasOpt("-time"))
91 fprintf(stdout
, "%s\n", aHelper
.getTime().getStr());
93 else if (opt
.hasOpt("-date"))
95 fprintf(stdout
, "%s\n", aHelper
.getDate().getStr());
97 else if (opt
.hasOpt("-upd"))
99 fprintf(stdout
, "%s\n", aHelper
.getUpd().getStr());
101 else if (opt
.hasOpt("-minor"))
103 fprintf(stdout
, "%s\n", aHelper
.getMinor().getStr());
105 else if (opt
.hasOpt("-build"))
107 fprintf(stdout
, "%s\n", aHelper
.getBuild().getStr());
109 else if (opt
.hasOpt("-inpath"))
111 fprintf(stdout
, "%s\n", aHelper
.getInpath().getStr());
115 // std::cout << aHelper << std::endl;
116 aHelper
.printall(stdout
);