X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=contrib%2Flar%2Flar.h;h=5888f7e658dd252c1db051ae0cd259adff7d5f72;hb=e1db49c923c208aadc733aeffbeeb9d1d38ed457;hp=04245ce63241d7e4e6d1217459b4a3da3404edec;hpb=acf5ea72c70ddbdb90b18a2ae1169ad82e455876;p=project%2Fluci.git diff --git a/contrib/lar/lar.h b/contrib/lar/lar.h index 04245ce63..5888f7e65 100644 --- a/contrib/lar/lar.h +++ b/contrib/lar/lar.h @@ -1,3 +1,22 @@ +/* + * lar - Lua Archive Library + * + * Copyright (C) 2009 Jo-Philipp Wich + * + * 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. + */ + + #ifndef __LAR_H #define __LAR_H @@ -13,6 +32,7 @@ #include #include +#include "md5.h" #define LAR_DIE(s) \ do { \ @@ -27,6 +47,9 @@ #define LAR_FNAME_BUFFER 1024 #define LAR_FNAME(s) char s[LAR_FNAME_BUFFER] +#define LAR_TYPE_REGULAR 0x0000 +#define LAR_TYPE_FILELIST 0xFFFF + #ifdef __WIN32__ #define LAR_DIRSEP '\\' #else @@ -35,12 +58,12 @@ struct lar_index_item { - uint32_t noffset; - uint32_t nlength; - uint32_t foffset; - uint32_t flength; + uint32_t offset; + uint32_t length; uint16_t type; uint16_t flags; + char id[16]; + char *filename; struct lar_index_item *next; }; @@ -55,6 +78,7 @@ struct lar_member_item { struct lar_archive_handle { int fd; + int has_filenames; off_t length; char filename[LAR_FNAME_BUFFER]; struct lar_index_item *index; @@ -65,13 +89,9 @@ typedef struct lar_member_item lar_member; typedef struct lar_archive_handle lar_archive; -int lar_read32( int fd, uint32_t *val ); -int lar_read16( int fd, uint16_t *val ); - lar_index * lar_get_index( lar_archive *ar ); -uint32_t lar_get_filename( lar_archive *ar, - lar_index *idx_ptr, char *filename ); +lar_member * lar_mmap_member( lar_archive *ar, lar_index *idx_ptr ); lar_member * lar_open_member( lar_archive *ar, const char *name ); @@ -81,7 +101,7 @@ lar_archive * lar_open( const char *filename ); int lar_close( lar_archive *ar ); -lar_archive * lar_find_archive( const char *package, const char *path ); +lar_archive * lar_find_archive( const char *package, const char *path, int pkg); lar_member * lar_find_member( lar_archive *ar, const char *package );