/* Copyright 1999 Element 14 Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* > unix.c */ /************************************************************************/ /* Copyright 1997-1999 Element 14 Ltd */ /* */ /* This material is the confidential trade secret and proprietary */ /* information of Element 14 Ltd. It may not be reproduced, used */ /* sold, or transferred to any third party without the prior written */ /* consent of Element 14 Ltd. All rights reserved. */ /* */ /************************************************************************/ #include <string.h> #include <stdio.h> #include "encpriv.h" int encoding__load_map_file(const char *leaf, UCS2 **ptable, int *pn_entries, int *palloc) { FILE *fh; int flen; char fname[1024]; void *table; int n_entries; int alloc; char *s = getenv("UNICODE_DIR"); if (s == NULL) s = "/usr/local/etc/unicode"; strncpy(fname, s, sizeof(fname)); if ( fname[ strlen(fname)-1 ] != '/' ) strcat( fname, "/" ); strncat(fname, "Encodings/", sizeof(fname)); strncat(fname, leaf, sizeof(fname)); fname[sizeof(fname)-1] = 0; fh = fopen(fname, "rb"); if (!fh) return 0; fseek(fh, 0, SEEK_END); flen = ftell(fh); fseek(fh, 0, SEEK_SET); alloc = 1; n_entries = flen/2; table = encoding__alloc(flen); if (table) { if (fread(table, flen, 1, fh) != 1) { encoding__free(table); table = NULL; } } fclose(fh); *ptable = table; *pn_entries = n_entries; *palloc = alloc; return table != NULL; } int encoding_current_alphabet(void) { return 0; } const UCS4 *encoding_alphabet_ucs_table(int a) { return NULL; } /* eof unix.c */