1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**************************************************************************
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius*   Copyright (C) 2000-2012, International Business Machines
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru***************************************************************************
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   file name:  pkgdata.c
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   encoding:   ANSI X3.4 (1968)
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   tab size:   8 (not used)
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   indentation:4
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   created on: 2000may16
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   created by: Steven \u24C7 Loomis
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*  common types for pkgdata
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef _PKGTYPES
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define _PKGTYPES
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* headers */
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h"
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "filestrm.h"
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* linked list */
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustruct _CharList;
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef struct _CharList
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char       *str;
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  struct _CharList *next;
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} CharList;
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
3685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho/*
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * write CharList 'l' into stream 's' using deliminter 'delim' (delim can be NULL). quoted: -1 remove, 0 as is, 1 add quotes
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruconst char *pkg_writeCharList(FileStream *s, CharList *l, const char *delim, int32_t quoted);
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Same, but use line breaks. quoted: -1 remove, 0 as is, 1 add quotes
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruconst char *pkg_writeCharListWrap(FileStream *s, CharList *l, const char *delim, const char *brk, int32_t quoted);
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Count items . 0 if null
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruuint32_t pkg_countCharList(CharList *l);
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
5285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho/*
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Prepend string to CharList. Str is adopted!
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCharList *pkg_prependToList(CharList *l, const char *str);
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
5785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho/*
5885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * append string to CharList. *end or even end can be null if you don't
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * know it.[slow]
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Str is adopted!
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCharList *pkg_appendToList(CharList *l, CharList** end, const char *str);
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
6485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho/*
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * strAlias is an alias to a full or relative path to a FILE.  This function
6685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * will search strAlias for the directory name (with strrchr). Then, it will
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * determine if that directory is already in list l.  If not, it will add it
6885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * with strdup(strAlias).
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param l list to append to , or NULL
7085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * @param end end pointer-to-pointer.  Can point to null, or be null.
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param strAlias alias to full path string
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return new list
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCharList *pkg_appendUniqueDirToList(CharList *l, CharList** end, const char *strAlias);
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * does list contain string?  Returns: t/f
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUBool  pkg_listContains(CharList *l, const char *str);
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
8285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Delete list
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid pkg_deleteList(CharList *l);
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Mode package function
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querustruct UPKGOptions_;
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef   void (UPKGMODE)(struct UPKGOptions_ *, FileStream *s, UErrorCode *status);
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
9385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Static mode - write the readme file
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param opt UPKGOptions
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param libName Name of the .lib, etc file
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status ICU error code
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid pkg_sttc_writeReadme(struct UPKGOptions_ *opt, const char *libName, UErrorCode *status);
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
10085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho/*
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Options to be passed throughout the program
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef struct UPKGOptions_
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  CharList   *fileListFiles; /* list of files containing files for inclusion in the package */
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  CharList   *filePaths;     /* All the files, with long paths */
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  CharList   *files;         /* All the files */
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  CharList   *outFiles;      /* output files [full paths] */
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *shortName;   /* name of what we're building */
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *cShortName;   /* name of what we're building as a C identifier */
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *entryName;   /* special entrypoint name */
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *targetDir;  /* dir for packaged data to go */
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *dataDir;    /* parent of dir for package (default: tmpdir) */
11685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho  const char *tmpDir;
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *srcDir;
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *options;     /* Options arg */
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *mode;        /* Mode of building */
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *version;     /* Library version */
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *comment;     /* comment string */
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *install;     /* Where to install to (NULL = don't install) */
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *icuroot;     /* where does ICU lives */
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  const char *libName;     /* name for library (default: shortName) */
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  UBool      rebuild;
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  UBool      verbose;
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  UBool      quiet;
12883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius  UBool      withoutAssembly;
12983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius  UBool      pdsbuild;     /* for building PDS in z/OS */
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} UPKGOptions;
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruchar * convertToNativePathSeparators(char *path);
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* set up common defines for library naming */
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
13783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#if U_PLATFORM_HAS_WIN32_API
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# ifndef UDATA_SO_SUFFIX
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#  define UDATA_SO_SUFFIX ".dll"
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# endif
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define LIB_PREFIX ""
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define LIB_STATIC_PREFIX ""
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define OBJ_SUFFIX ".obj"
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define UDATA_LIB_SUFFIX ".lib"
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
14683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#elif U_PLATFORM == U_PF_CYGWIN
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define LIB_PREFIX "cyg"
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define LIB_STATIC_PREFIX "lib"
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define OBJ_SUFFIX ".o"
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define UDATA_LIB_SUFFIX ".a"
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else  /* POSIX? */
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define LIB_PREFIX "lib"
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define LIB_STATIC_PREFIX "lib"
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define OBJ_SUFFIX ".o"
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define UDATA_LIB_SUFFIX ".a"
15785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho#endif
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define ASM_SUFFIX ".s"
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* defines for common file names */
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define UDATA_CMN_PREFIX ""
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define UDATA_CMN_SUFFIX ".dat"
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define UDATA_CMN_INTERMEDIATE_SUFFIX "_dat"
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
16685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho#define ICUDATA_RES_FILE "icudata.res"
16785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define PKGDATA_DERIVED_PATH '\t'
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
171