ar.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* ar.h: Definitions for archive files
  2. Copyright (C) 2002-2003 Sebastian Reichelt
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  14. #ifndef AR_H
  15. #define AR_H
  16. #include "../generic.h"
  17. #include "../integers.h"
  18. // *** Constants ***
  19. #define AR_MEMBER_BOUNDARY 2
  20. #define AR_MEMBER_PADDING_CHAR '\012'
  21. // *** File Mapping Definitions ***
  22. // Archive File Header
  23. #define AR_FILE_HEADER_STRING "!<arch>\012"
  24. #define AR_FILE_HEADER_SIZE 8
  25. // Archive Member Header
  26. typedef struct ATTRIBUTE_PACKED {
  27. char Name[16]; // '/'-terminated file member name.
  28. char Date[12]; // File time in ASCII-encoded decimal.
  29. char UID[6]; // User ID in ASCII-encoded decimal.
  30. char GID[6]; // Group ID in ASCII-encoded decimal.
  31. char Mode[8]; // File mode in ASCII-encoded octal.
  32. char Size[10]; // Size in ASCII-encoded decimal.
  33. char Magic[2]; // Magic string: "`\012".
  34. } AR_MEMBER_HEADER;
  35. #define AR_MEMBER_HEADER_SIZE (sizeof (AR_MEMBER_HEADER))
  36. #define AR_MEMBER_MAX_NAME_LENGTH 15
  37. #define AR_MEMBER_MAGIC "`\012"
  38. #define AR_MEMBER_MAGIC_SIZE 2
  39. // Archive Symbol Table
  40. typedef struct ATTRIBUTE_PACKED {
  41. TI4 SymbolCount;
  42. TI4 PSymbols VAR_ARRAY;
  43. } AR_SYMBOL_TABLE_HEADER;
  44. // *** File Type Check ***
  45. #include <string.h>
  46. #define IsArchiveFile(File,FileSize) (((FileSize) > AR_FILE_HEADER_SIZE) && (!(strncmp ((const char *) (File), AR_FILE_HEADER_STRING, AR_FILE_HEADER_SIZE))))
  47. #endif