LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ArchiveInternals.h

Go to the documentation of this file.
00001 //===-- lib/Bytecode/ArchiveInternals.h -------------------------*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by Reid Spencer and is distributed under the 
00006 // University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // Internal implementation header for LLVM Archive files.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LIB_BYTECODE_ARCHIVEINTERNALS_H
00015 #define LIB_BYTECODE_ARCHIVEINTERNALS_H
00016 
00017 #include "llvm/Bytecode/Archive.h"
00018 #include "llvm/System/TimeValue.h"
00019 #include "llvm/ADT/StringExtras.h"
00020 
00021 #define ARFILE_MAGIC "!<arch>\n"                   ///< magic string 
00022 #define ARFILE_MAGIC_LEN (sizeof(ARFILE_MAGIC)-1)  ///< length of magic string 
00023 #define ARFILE_SVR4_SYMTAB_NAME "/               " ///< SVR4 symtab entry name
00024 #define ARFILE_LLVM_SYMTAB_NAME "#_LLVM_SYM_TAB_#" ///< LLVM symtab entry name
00025 #define ARFILE_BSD4_SYMTAB_NAME "__.SYMDEF SORTED" ///< BSD4 symtab entry name
00026 #define ARFILE_STRTAB_NAME      "//              " ///< Name of string table
00027 #define ARFILE_PAD "\n"                            ///< inter-file align padding
00028 #define ARFILE_MEMBER_MAGIC "`\n"                  ///< fmag field magic #
00029 
00030 namespace llvm {
00031 
00032   /// The ArchiveMemberHeader structure is used internally for bytecode 
00033   /// archives. 
00034   /// The header precedes each file member in the archive. This structure is 
00035   /// defined using character arrays for direct and correct interpretation
00036   /// regardless of the endianess of the machine that produced it.
00037   /// @brief Archive File Member Header
00038   class ArchiveMemberHeader {
00039     /// @name Data
00040     /// @{
00041     public:
00042       char name[16];///< Name of the file member. 
00043       char date[12];  ///< File date, decimal seconds since Epoch
00044       char uid[6];    ///< user id in ASCII decimal
00045       char gid[6];    ///< group id in ASCII decimal
00046       char mode[8];   ///< file mode in ASCII octal
00047       char size[10];  ///< file size in ASCII decimal
00048       char fmag[2];   ///< Always contains ARFILE_MAGIC_TERMINATOR
00049 
00050     /// @}
00051     /// @name Methods
00052     /// @{
00053     public:
00054     void init() {
00055       memset(name,' ',16);
00056       memset(date,' ',12);
00057       memset(uid,' ',6);
00058       memset(gid,' ',6);
00059       memset(mode,' ',8);
00060       memset(size,' ',10);
00061       fmag[0] = '`';
00062       fmag[1] = '\n';
00063     }
00064 
00065     bool checkSignature() {
00066       return 0 == memcmp(fmag, ARFILE_MEMBER_MAGIC,2);
00067     }
00068 
00069   };
00070 
00071 }
00072 
00073 #endif
00074 
00075 // vim: sw=2 ai