diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-04-18 08:08:23 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-04-18 08:08:23 +0000 |
commit | a7b65cdc9aae6ccbb5f652fcbcb7f32129bd8299 (patch) | |
tree | fe4d18c845102a586d924eb933092cc83c5b90de /locale/programs/locfile.c | |
parent | c77694049a23389267f9bb22135b393d824ba24c (diff) | |
download | glibc-a7b65cdc9aae6ccbb5f652fcbcb7f32129bd8299.tar.gz glibc-a7b65cdc9aae6ccbb5f652fcbcb7f32129bd8299.tar.xz glibc-a7b65cdc9aae6ccbb5f652fcbcb7f32129bd8299.zip |
Update.
2002-04-18 Ulrich Drepper <drepper@redhat.com> * locale/programs/locfile.c (to_archive): New variable. To collect data which has to be added to the locale archive. (write_all_categories): Take new third parameter with locale name. Unless no_archive flag set add new locale data to the archive (write_locale_data): Unless no-archive flag set store generated data in to_archive data structure instead of generation output file. Add new parameter with locale category index. * locale/programs/locfile.h: Add new parameters in declaractions of write_all_categories and write_locale_data. * locale/programs/localedef.c: Recognize --no-archive, --list-archive, --add-to-archive, and --delete-from-archive options. Pass extra parameter to write_all_categories. * locale/programs/localedef.h: Add prototypes for functions in locarchive.c. * locale/locarchive.h: New file. * locale/programs/locarchive.c: New file. * locale/Makefile (distribute): Add programs/locarchive.c and locarchive.h. (localedef-modules): Add md5 and locarchive. Add vpath to crypt subdir for md5.c. * locale/programs/ld-address.c: Pass locale category ID as new second parameter to write_locale_data. * locale/programs/ld-collate.c: Likewise. * locale/programs/ld-ctype.c: Likewise. * locale/programs/ld-identification.c: Likewise. * locale/programs/ld-measurement.c: Likewise. * locale/programs/ld-messages.c: Likewise. * locale/programs/ld-monetary.c: Likewise. * locale/programs/ld-name.c: Likewise. * locale/programs/ld-numeric.c: Likewise. * locale/programs/ld-paper.c: Likewise. * locale/programs/ld-telephone.c: Likewise. * locale/programs/ld-time.c: Likewise. * locale/simple-hash.c: Move compute_hashval function from here... * locale/hashval.h: ...to here. New file. * locale/simple-hash.h: Add prototype for compute_hashval. * include/libintl.h: Minor cleanups. * elf/reldep7.c: New file. * elf/reldep7mod1.c: New file. * elf/reldep7mod2.c: New file. * elf/Makefile: Add rules to build and run reldep7.
Diffstat (limited to 'locale/programs/locfile.c')
-rw-r--r-- | locale/programs/locfile.c | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c index 07a65bbb54..4d978d12a1 100644 --- a/locale/programs/locfile.c +++ b/locale/programs/locfile.c @@ -30,12 +30,18 @@ #include <sys/param.h> #include <sys/stat.h> +#include "../../crypt/md5.h" #include "localedef.h" #include "locfile.h" +#include "simple-hash.h" #include "locfile-kw.h" +/* Temporary storage of the locale data before writing it to the archive. */ +static locale_data_t to_archive; + + int locfile_read (struct localedef_t *result, const struct charmap_t *charmap) { @@ -312,9 +318,10 @@ static void (*const write_funcs[]) (struct localedef_t *, [LC_IDENTIFICATION] = identification_output }; + void write_all_categories (struct localedef_t *definitions, - const struct charmap_t *charmap, + const struct charmap_t *charmap, const char *locname, const char *output_path) { int cnt; @@ -322,8 +329,25 @@ write_all_categories (struct localedef_t *definitions, for (cnt = 0; cnt < sizeof (write_funcs) / sizeof (write_funcs[0]); ++cnt) if (write_funcs[cnt] != NULL) write_funcs[cnt] (definitions, charmap, output_path); + + if (! no_archive) + { + /* The data has to be added to the archive. Do this now. */ + struct locarhandle ah; + + /* Open the archive. This call never returns if we cannot + successfully open the archive. */ + open_archive (&ah); + + if (add_locale_to_archive (&ah, locname, to_archive, true) != 0) + error (EXIT_FAILURE, errno, _("cannot add to locale archive")); + + /* We are done. */ + close_archive (&ah); + } } + /* Return a NULL terminated list of the directories next to output_path that have the same owner, group, permissions and device as output_path. */ static const char ** @@ -408,6 +432,7 @@ siblings_uncached (const char *output_path) return elems; } + /* Return a NULL terminated list of the directories next to output_path that have the same owner, group, permissions and device as output_path. Cache the result for future calls. */ @@ -434,6 +459,7 @@ siblings (const char *output_path) return last_result; } + /* Read as many bytes from a file descriptor as possible. */ static ssize_t full_read (int fd, void *bufarea, size_t nbyte) @@ -457,6 +483,7 @@ full_read (int fd, void *bufarea, size_t nbyte) return buf - (char *) bufarea; } + /* Compare the contents of two regular files of the same size. Return 0 if they are equal, 1 if they are different, or -1 if an error occurs. */ static int @@ -506,9 +533,10 @@ compare_files (const char *filename1, const char *filename2, size_t size, return ret; } + /* Write a locale file, with contents given by N_ELEM and VEC. */ void -write_locale_data (const char *output_path, const char *category, +write_locale_data (const char *output_path, int catidx, const char *category, size_t n_elem, struct iovec *vec) { size_t cnt, step, maxiov; @@ -516,6 +544,32 @@ write_locale_data (const char *output_path, const char *category, char *fname; const char **other_paths; + if (! no_archive) + { + /* The data will be added to the archive. For now we simply + generate the image which will be written. First determine + the size. */ + int cnt; + void *endp; + + to_archive[catidx].size = 0; + for (cnt = 0; cnt < n_elem; ++cnt) + to_archive[catidx].size += vec[cnt].iov_len; + + /* Allocate the memory for it. */ + to_archive[catidx].addr = xmalloc (to_archive[catidx].size); + + /* Fill it in. */ + for (cnt = 0, endp = to_archive[catidx].addr; cnt < n_elem; ++cnt) + endp = mempcpy (endp, vec[cnt].iov_base, vec[cnt].iov_len); + + /* Compute the MD5 sum for the data. */ + __md5_buffer (to_archive[catidx].addr, to_archive[catidx].size, + to_archive[catidx].sum); + + return; + } + fname = xmalloc (strlen (output_path) + 2 * strlen (category) + 7); /* Normally we write to the directory pointed to by the OUTPUT_PATH. @@ -680,8 +734,7 @@ failure while writing data for category `%s'"), category)); char * tmp_fname = (char *) xmalloc (strlen (fname) + 4 + 1); - strcpy (tmp_fname, fname); - strcat (tmp_fname, ".tmp"); + strcpy (stpcpy (tmp_fname, fname), ".tmp"); if (link (other_fname, tmp_fname) >= 0) { |