]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | ******************************************************************************* | |
3 | * | |
374ca955 | 4 | * Copyright (C) 1999-2003, International Business Machines |
b75a7d8f A |
5 | * Corporation and others. All Rights Reserved. |
6 | * | |
7 | ******************************************************************************* | |
8 | * file name: toolutil.h | |
9 | * encoding: US-ASCII | |
10 | * tab size: 8 (not used) | |
11 | * indentation:4 | |
12 | * | |
13 | * created on: 1999nov19 | |
14 | * created by: Markus W. Scherer | |
15 | * | |
16 | * This file defines utility functions for ICU tools like genccode. | |
17 | */ | |
18 | ||
19 | #ifndef __TOOLUTIL_H__ | |
20 | #define __TOOLUTIL_H__ | |
21 | ||
22 | #include "unicode/utypes.h" | |
23 | ||
b75a7d8f A |
24 | /* |
25 | * For Windows, a path/filename may be the short (8.3) version | |
26 | * of the "real", long one. In this case, the short one | |
27 | * is abbreviated and contains a tilde etc. | |
28 | * This function returns a pointer to the original pathname | |
29 | * if it is the "real" one itself, and a pointer to a static | |
30 | * buffer (not thread-safe) containing the long version | |
31 | * if the pathname is indeed abbreviated. | |
32 | * | |
33 | * On platforms other than Windows, this function always returns | |
34 | * the input pathname pointer. | |
35 | * | |
36 | * This function is especially useful in tools that are called | |
37 | * by a batch file for loop, which yields short pathnames on Win9x. | |
38 | */ | |
39 | U_CAPI const char * U_EXPORT2 | |
40 | getLongPathname(const char *pathname); | |
41 | ||
42 | /* | |
43 | * Find the basename at the end of a pathname, i.e., the part | |
44 | * after the last file separator, and return a pointer | |
45 | * to this part of the pathname. | |
46 | * If the pathname only contains a basename and no file separator, | |
47 | * then the pathname pointer itself is returned. | |
48 | */ | |
49 | U_CAPI const char * U_EXPORT2 | |
50 | findBasename(const char *filename); | |
51 | ||
374ca955 A |
52 | /* |
53 | * UToolMemory is used for generic, custom memory management. | |
54 | * It is allocated with enough space for count*size bytes starting | |
55 | * at array. | |
56 | * The array is declared with a union of large data types so | |
57 | * that its base address is aligned for any types. | |
58 | * If size is a multiple of a data type size, then such items | |
59 | * can be safely allocated inside the array, at offsets that | |
60 | * are themselves multiples of size. | |
61 | */ | |
62 | struct UToolMemory; | |
63 | typedef struct UToolMemory UToolMemory; | |
64 | ||
65 | /** | |
66 | * Open a UToolMemory object for allocation of initialCapacity to maxCapacity | |
67 | * items with size bytes each. | |
68 | */ | |
69 | U_CAPI UToolMemory * U_EXPORT2 | |
70 | utm_open(const char *name, int32_t initialCapacity, int32_t maxCapacity, int32_t size); | |
71 | ||
72 | /** | |
73 | * Close a UToolMemory object. | |
74 | */ | |
75 | U_CAPI void U_EXPORT2 | |
76 | utm_close(UToolMemory *mem); | |
77 | ||
78 | /** | |
79 | * Get the pointer to the beginning of the array of items. | |
80 | * The pointer becomes invalid after allocation of new items. | |
81 | */ | |
82 | U_CAPI void * U_EXPORT2 | |
83 | utm_getStart(UToolMemory *mem); | |
84 | ||
85 | /** | |
86 | * Get the current number of items. | |
87 | */ | |
88 | U_CAPI int32_t U_EXPORT2 | |
89 | utm_countItems(UToolMemory *mem); | |
90 | ||
91 | /** | |
92 | * Allocate one more item and return the pointer to its start in the array. | |
93 | */ | |
94 | U_CAPI void * U_EXPORT2 | |
95 | utm_alloc(UToolMemory *mem); | |
96 | ||
97 | /** | |
98 | * Allocate n items and return the pointer to the start of the first one in the array. | |
99 | */ | |
100 | U_CAPI void * U_EXPORT2 | |
101 | utm_allocN(UToolMemory *mem, int32_t n); | |
102 | ||
b75a7d8f | 103 | #endif |