2 * lar - Lua Archive Library
4 * Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
30 #include <arpa/inet.h>
31 #include <sys/types.h>
39 fprintf(stderr, "%s(%i): %s(): %s\n", \
40 __FILE__, __LINE__, __FUNCTION__, s); \
41 if( errno ) fprintf(stderr, "%s(%i): %s\n", \
42 __FILE__, __LINE__, strerror(errno) ); \
47 #define LAR_FNAME_BUFFER 1024
48 #define LAR_FNAME(s) char s[LAR_FNAME_BUFFER]
50 #define LAR_TYPE_REGULAR 0x0000
51 #define LAR_TYPE_FILELIST 0xFFFF
54 #define LAR_DIRSEP '\\'
56 #define LAR_DIRSEP '/'
60 struct lar_index_item {
67 struct lar_index_item *next;
70 struct lar_member_item {
79 struct lar_archive_handle {
83 char filename[LAR_FNAME_BUFFER];
84 struct lar_index_item *index;
87 typedef struct lar_index_item lar_index;
88 typedef struct lar_member_item lar_member;
89 typedef struct lar_archive_handle lar_archive;
92 lar_index * lar_get_index( lar_archive *ar );
94 lar_member * lar_mmap_member( lar_archive *ar, lar_index *idx_ptr );
96 lar_member * lar_open_member( lar_archive *ar, const char *name );
98 int lar_close_member( lar_member *member );
100 lar_archive * lar_open( const char *filename );
102 int lar_close( lar_archive *ar );
104 lar_archive * lar_find_archive( const char *package, const char *path, int pkg);
106 lar_member * lar_find_member( lar_archive *ar, const char *package );