| 893 | */ |
| 894 | |
| 895 | cups_array_t * /* O - New message array */ |
| 896 | _cupsMessageLoad(const char *filename, /* I - Message catalog to load */ |
| 897 | int flags) /* I - Load flags */ |
| 898 | { |
| 899 | cups_file_t *fp; /* Message file */ |
| 900 | cups_array_t *a; /* Message array */ |
| 901 | _cups_message_t *m; /* Current message */ |
| 902 | char s[4096], /* String buffer */ |
| 903 | *ptr, /* Pointer into buffer */ |
| 904 | *temp; /* New string */ |
| 905 | size_t length, /* Length of combined strings */ |
| 906 | ptrlen; /* Length of string */ |
| 907 | |
| 908 | |
| 909 | DEBUG_printf(("4_cupsMessageLoad(filename=\"%s\")", filename)); |
| 910 | |
| 911 | /* |
| 912 | * Create an array to hold the messages... |
| 913 | */ |
| 914 | |
| 915 | if ((a = _cupsMessageNew(NULL)) == NULL) |
| 916 | { |
| 917 | DEBUG_puts("5_cupsMessageLoad: Unable to allocate array!"); |
| 918 | return (NULL); |
| 919 | } |
| 920 | |
| 921 | /* |
| 922 | * Open the message catalog file... |
| 923 | */ |
| 924 | |
| 925 | if ((fp = cupsFileOpen(filename, "r")) == NULL) |
| 926 | { |
| 927 | DEBUG_printf(("5_cupsMessageLoad: Unable to open file: %s", |
| 928 | strerror(errno))); |
| 929 | return (a); |
| 930 | } |
| 931 | |
| 932 | if (flags & _CUPS_MESSAGE_STRINGS) |
| 933 | { |
| 934 | while (cups_read_strings(fp, flags, a)); |
| 935 | } |
| 936 | else |
| 937 | { |
| 938 | /* |
| 939 | * Read messages from the catalog file until EOF... |
| 940 | * |
| 941 | * The format is the GNU gettext .po format, which is fairly simple: |
| 942 | * |
| 943 | * msgid "some text" |
| 944 | * msgstr "localized text" |
| 945 | * |
| 946 | * The ID and localized text can span multiple lines using the form: |
| 947 | * |
| 948 | * msgid "" |
| 949 | * "some long text" |
| 950 | * msgstr "" |
| 951 | * "localized text spanning " |
| 952 | * "multiple lines" |
no test coverage detected