diff options
Diffstat (limited to 'Build/source/libs/icu/icu-xetex/samples/date')
7 files changed, 689 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-xetex/samples/date/Makefile.in b/Build/source/libs/icu/icu-xetex/samples/date/Makefile.in new file mode 100644 index 00000000000..c1873721df5 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/Makefile.in @@ -0,0 +1,75 @@ +## Makefile.in for ICU - samples/date +## Copyright (c) 1999-2004, International Business Machines Corporation and +## others. All Rights Reserved. + +## Source directory information + +srcdir=@srcdir@ +top_srcdir=@top_srcdir@ + +top_builddir = ../.. + +include $(top_builddir)/icudefs.mk + +## Build directory information +subdir = samples/date + +## Extra files to remove for 'make clean' +CLEANFILES = *~ $(DEPS) + +## Target information +TARGET = icudate$(EXEEXT) + +CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n +LIBS = $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M) + +OBJECTS = uprint.o date.o + +DEPS = $(OBJECTS:.o=.d) + +## List of phony targets +.PHONY : all all-local install install-local clean clean-local \ +distclean distclean-local dist dist-local check check-local + +## Clear suffix list +.SUFFIXES : + +## List of standard targets +all: all-local +install: install-local +clean: clean-local +distclean : distclean-local +dist: dist-local +check: all check-local + +all-local: $(TARGET) + +install-local: all-local + +dist-local: + +clean-local: + test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) + $(RMV) $(OBJECTS) $(TARGET) + +distclean-local: clean-local + $(RMV) Makefile + +check-local: + -$(INVOKE) ./$(TARGET) + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(TARGET) : $(OBJECTS) + $(LINK.c) $(OUTOPT)$@ $^ $(LIBS) + $(POST_BUILD_STEP) + +ifeq (,$(MAKECMDGOALS)) +-include $(DEPS) +else +ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) +-include $(DEPS) +endif +endif diff --git a/Build/source/libs/icu/icu-xetex/samples/date/date.c b/Build/source/libs/icu/icu-xetex/samples/date/date.c new file mode 100644 index 00000000000..8a7ebe1f964 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/date.c @@ -0,0 +1,204 @@ +/* +********************************************************************** +* Copyright (C) 1998-2007, International Business Machines +* Corporation and others. All Rights Reserved. +********************************************************************** +* +* File date.c +* +* Modification History: +* +* Date Name Description +* 06/11/99 stephen Creation. +* 06/16/99 stephen Modified to use uprint. +******************************************************************************* +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "unicode/utypes.h" +#include "unicode/ustring.h" +#include "unicode/uclean.h" + +#include "unicode/ucnv.h" +#include "unicode/udat.h" +#include "unicode/ucal.h" + +#include "uprint.h" + +int main(int argc, char **argv); + +#if UCONFIG_NO_FORMATTING + +int main(int argc, char **argv) +{ + printf("%s: Sorry, UCONFIG_NO_FORMATTING was turned on (see uconfig.h). No formatting can be done. \n", argv[0]); + return 0; +} +#else + + +/* Protos */ +static void usage(void); +static void version(void); +static void date(const UChar *tz, UDateFormatStyle style, char *format, UErrorCode *status); + + +/* The version of date */ +#define DATE_VERSION "1.0" + +/* "GMT" */ +static const UChar GMT_ID [] = { 0x0047, 0x004d, 0x0054, 0x0000 }; + + +int +main(int argc, + char **argv) +{ + int printUsage = 0; + int printVersion = 0; + int optind = 1; + char *arg; + const UChar *tz = 0; + UDateFormatStyle style = UDAT_DEFAULT; + UErrorCode status = U_ZERO_ERROR; + char *format = NULL; + + + /* parse the options */ + for(optind = 1; optind < argc; ++optind) { + arg = argv[optind]; + + /* version info */ + if(strcmp(arg, "-v") == 0 || strcmp(arg, "--version") == 0) { + printVersion = 1; + } + /* usage info */ + else if(strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) { + printUsage = 1; + } + /* display date in gmt */ + else if(strcmp(arg, "-u") == 0 || strcmp(arg, "--gmt") == 0) { + tz = GMT_ID; + } + /* display date in gmt */ + else if(strcmp(arg, "-f") == 0 || strcmp(arg, "--full") == 0) { + style = UDAT_FULL; + } + /* display date in long format */ + else if(strcmp(arg, "-l") == 0 || strcmp(arg, "--long") == 0) { + style = UDAT_LONG; + } + /* display date in medium format */ + else if(strcmp(arg, "-m") == 0 || strcmp(arg, "--medium") == 0) { + style = UDAT_MEDIUM; + } + /* display date in short format */ + else if(strcmp(arg, "-s") == 0 || strcmp(arg, "--short") == 0) { + style = UDAT_SHORT; + } + else if(strcmp(arg, "-F") == 0 || strcmp(arg, "--format") == 0) { + if ( optind + 1 < argc ) { + optind++; + format = argv[optind]; + } + } + /* POSIX.1 says all arguments after -- are not options */ + else if(strcmp(arg, "--") == 0) { + /* skip the -- */ + ++optind; + break; + } + /* unrecognized option */ + else if(strncmp(arg, "-", strlen("-")) == 0) { + printf("icudate: invalid option -- %s\n", arg+1); + printUsage = 1; + } + /* done with options, display date */ + else { + break; + } + } + + /* print usage info */ + if(printUsage) { + usage(); + return 0; + } + + /* print version info */ + if(printVersion) { + version(); + return 0; + } + + /* print the date */ + date(tz, style, format, &status); + + u_cleanup(); + return (U_FAILURE(status) ? 1 : 0); +} + +/* Usage information */ +static void +usage() +{ + puts("Usage: icudate [OPTIONS]"); + puts("Options:"); + puts(" -h, --help Print this message and exit."); + puts(" -v, --version Print the version number of date and exit."); + puts(" -u, --gmt Display the date in Greenwich Mean Time."); + puts(" -f, --full Use full display format."); + puts(" -l, --long Use long display format."); + puts(" -m, --medium Use medium display format."); + puts(" -s, --short Use short display format."); +} + +/* Version information */ +static void +version() +{ + printf("icudate version %s (ICU version %s), created by Stephen F. Booth.\n", + DATE_VERSION, U_ICU_VERSION); + puts(U_COPYRIGHT_STRING); +} + +/* Format the date */ +static void +date(const UChar *tz, + UDateFormatStyle style, + char *format, + UErrorCode *status) +{ + UChar *s = 0; + int32_t len = 0; + UDateFormat *fmt; + UChar uFormat[100]; + + fmt = udat_open(style, style, 0, tz, -1,NULL,0, status); + if ( format != NULL ) { + u_charsToUChars(format,uFormat,strlen(format)), + udat_applyPattern(fmt,FALSE,uFormat,strlen(format)); + } + len = udat_format(fmt, ucal_getNow(), 0, len, 0, status); + if(*status == U_BUFFER_OVERFLOW_ERROR) { + *status = U_ZERO_ERROR; + s = (UChar*) malloc(sizeof(UChar) * (len+1)); + if(s == 0) goto finish; + udat_format(fmt, ucal_getNow(), s, len + 1, 0, status); + if(U_FAILURE(*status)) goto finish; + } + + /* print the date string */ + uprint(s, stdout, status); + + /* print a trailing newline */ + printf("\n"); + + finish: + udat_close(fmt); + free(s); +} +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/date/date.sln b/Build/source/libs/icu/icu-xetex/samples/date/date.sln new file mode 100644 index 00000000000..d392b392bfb --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/date.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "date", "date.vcproj", "{38B5751A-C6F9-4409-950C-F4F9DA17275F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|Win32.ActiveCfg = Debug|Win32 + {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|Win32.Build.0 = Debug|Win32 + {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|Win32.ActiveCfg = Release|Win32 + {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/date/date.vcproj b/Build/source/libs/icu/icu-xetex/samples/date/date.vcproj new file mode 100644 index 00000000000..eb4327dd166 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/date.vcproj @@ -0,0 +1,231 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="date" + ProjectGUID="{38B5751A-C6F9-4409-950C-F4F9DA17275F}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Release|Win32" + OutputDirectory=".\Release" + IntermediateDirectory=".\Release" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TypeLibraryName=".\Release/date.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/date.pch" + AssemblerListingLocation=".\Release/" + ObjectFile=".\Release/" + ProgramDataBaseFileName=".\Release/" + WarningLevel="3" + SuppressStartupBanner="true" + CompileAs="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG" + Culture="1033" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="icuuc.lib icuin.lib" + OutputFile=".\Release/date.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + ProgramDatabaseFile=".\Release/date.pdb" + SubSystem="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\Debug" + IntermediateDirectory=".\Debug" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TypeLibraryName=".\Debug/date.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/date.pch" + AssemblerListingLocation=".\Debug/" + ObjectFile=".\Debug/" + ProgramDataBaseFileName=".\Debug/" + WarningLevel="3" + SuppressStartupBanner="true" + DebugInformationFormat="4" + CompileAs="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG" + Culture="1033" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="icuucd.lib icuind.lib" + OutputFile=".\Debug/date.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/date.pdb" + SubSystem="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + > + <File + RelativePath=".\date.c" + > + </File> + <File + RelativePath=".\uprint.c" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + <File + RelativePath=".\uprint.h" + > + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/Build/source/libs/icu/icu-xetex/samples/date/readme.txt b/Build/source/libs/icu/icu-xetex/samples/date/readme.txt new file mode 100644 index 00000000000..3ba36d518e4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/readme.txt @@ -0,0 +1,58 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +icudate: a sample program which displays the current date + +This sample demonstrates + Formatting a date + Outputting text in the default codepage to the console + + +Files: + date.c Main source file + uprint.h codepage output convenience header + uprint.h codepage output convenience implementation + date.sln Windows MSVC workspace. Double-click this to get started. + date.vcproj Windows MSVC project file + +To Build icudate on Windows + 1. Install and build ICU + 2. In MSVC, open the workspace file icu\samples\date\date.sln + 3. Choose a Debug or Release build. + 4. Build. + +To Run on Windows + 1. Start a command shell window + 2. Add ICU's bin directory to the path, e.g. + set PATH=c:\icu\bin;%PATH% + (Use the path to where ever ICU is on your system.) + 3. cd into the icudate directory, e.g. + cd c:\icu\source\samples\date\debug + 4. Run it + date + +To Build on Unixes + 1. Build ICU. icudate is built automatically by default unless samples are turned off. + Specify an ICU install directory when running configure, + using the --prefix option. The steps to build ICU will look something + like this: + cd <icu directory>/source + runConfigureICU <platform-name> --prefix <icu install directory> [other options] + gmake all + + 2. Install ICU, + gmake install + + To Run on Unixes + cd <icu directory>/source/samples/date + + gmake check + -or- + + export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH + date + + + Note: The name of the LD_LIBRARY_PATH variable is different on some systems. + If in doubt, run the sample using "gmake check", and note the name of + the variable that is used there. LD_LIBRARY_PATH is the correct name + for Linux and Solaris. + diff --git a/Build/source/libs/icu/icu-xetex/samples/date/uprint.c b/Build/source/libs/icu/icu-xetex/samples/date/uprint.c new file mode 100644 index 00000000000..27e82af2f2b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/uprint.c @@ -0,0 +1,76 @@ +/* +********************************************************************** +* Copyright (C) 1998-2001, International Business Machines Corporation +* and others. All Rights Reserved. +********************************************************************** +* +* File date.c +* +* Modification History: +* +* Date Name Description +* 06/14/99 stephen Creation. +******************************************************************************* +*/ + +#include "uprint.h" + +#include "unicode/ucnv.h" +#include "unicode/ustring.h" + +#define BUF_SIZE 128 + +/* Print a ustring to the specified FILE* in the default codepage */ +void +uprint(const UChar *s, + FILE *f, + UErrorCode *status) +{ + /* converter */ + UConverter *converter; + char buf [BUF_SIZE]; + int32_t sourceLen; + const UChar *mySource; + const UChar *mySourceEnd; + char *myTarget; + int32_t arraySize; + + if(s == 0) return; + + /* set up the conversion parameters */ + sourceLen = u_strlen(s); + mySource = s; + mySourceEnd = mySource + sourceLen; + myTarget = buf; + arraySize = BUF_SIZE; + + /* open a default converter */ + converter = ucnv_open(0, status); + + /* if we failed, clean up and exit */ + if(U_FAILURE(*status)) goto finish; + + /* perform the conversion */ + do { + /* reset the error code */ + *status = U_ZERO_ERROR; + + /* perform the conversion */ + ucnv_fromUnicode(converter, &myTarget, myTarget + arraySize, + &mySource, mySourceEnd, NULL, + TRUE, status); + + /* Write the converted data to the FILE* */ + fwrite(buf, sizeof(char), myTarget - buf, f); + + /* update the conversion parameters*/ + myTarget = buf; + arraySize = BUF_SIZE; + } + while(*status == U_BUFFER_OVERFLOW_ERROR); + + finish: + + /* close the converter */ + ucnv_close(converter); +} diff --git a/Build/source/libs/icu/icu-xetex/samples/date/uprint.h b/Build/source/libs/icu/icu-xetex/samples/date/uprint.h new file mode 100644 index 00000000000..16ffb47c115 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/uprint.h @@ -0,0 +1,26 @@ +/* +********************************************************************** +* Copyright (C) 1998-2004, International Business Machines Corporation +* and others. All Rights Reserved. +********************************************************************** +* +* File uprint.h +* +* Modification History: +* +* Date Name Description +* 06/14/99 stephen Creation. +******************************************************************************* +*/ + +#ifndef UPRINT_H +#define UPRINT_H 1 + +#include <stdio.h> + +#include "unicode/utypes.h" + +/* Print a ustring to the specified FILE* in the default codepage */ +U_CFUNC void uprint(const UChar *s, FILE *f, UErrorCode *status); + +#endif /* ! UPRINT_H */ |