- add sources.
[platform/framework/web/crosswalk.git] / src / third_party / sqlite / src / src / shell_icu_linux.c
1 /* Copyright 2007 Google Inc. All Rights Reserved.
2 **/
3
4 #include <limits.h>
5 #include <unistd.h>
6 #include "unicode/putil.h"
7 #include "unicode/udata.h"
8
9 /*
10 ** This function attempts to load the ICU data tables from a data file.
11 ** Returns 0 on failure, nonzero on success.
12 ** This a hack job of icu_utils.cc:Initialize().  It's Chrome-specific code.
13 */
14 int sqlite_shell_init_icu() {
15   char bin_dir[PATH_MAX + 1];
16   int bin_dir_size = readlink("/proc/self/exe", bin_dir, PATH_MAX);
17   if (bin_dir_size < 0 || bin_dir_size > PATH_MAX)
18     return 0;
19   bin_dir[bin_dir_size] = 0;;
20
21   u_setDataDirectory(bin_dir);
22   // Only look for the packaged data file;
23   // the default behavior is to look for individual files.
24   UErrorCode err = U_ZERO_ERROR;
25   udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
26   return err == U_ZERO_ERROR;
27 }