public/sourcepawn/sp_file_headers.h
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/public/sourcepawn/sp_file_headers.h	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,227 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourcePawn
     1.8 - * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     1.9 - * =============================================================================
    1.10 - *
    1.11 - * This program is free software; you can redistribute it and/or modify it under
    1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 - * Free Software Foundation.
    1.14 - * 
    1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 - * details.
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License along with
    1.21 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 - *
    1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 - * or <http://www.sourcemod.net/license.php>.
    1.31 - *
    1.32 - * Version: $Id$
    1.33 - */
    1.34 -
    1.35 -#ifndef _INCLUDE_SPFILE_HEADERS_H
    1.36 -#define _INCLUDE_SPFILE_HEADERS_H
    1.37 -
    1.38 -/** 
    1.39 - * @file sp_file_headers.h
    1.40 - * @brief Defines the structure present in a SourcePawn compiled binary.
    1.41 - *
    1.42 - * Note: These structures should be 1-byte packed to match the file format.
    1.43 - */
    1.44 -
    1.45 -#include <stddef.h>
    1.46 -#if defined __GNUC__ || defined HAVE_STDINT_
    1.47 -#include <stdint.h>
    1.48 -#else
    1.49 - #if !defined HAVE_STDINT_H
    1.50 -	typedef unsigned __int64	uint64_t;		/**< 64bit unsigned integer */
    1.51 -	typedef __int64				int64_t;		/**< 64bit signed integer */
    1.52 -	typedef unsigned __int32	uint32_t;		/**< 32bit unsigned integer */
    1.53 -	typedef __int32				int32_t;		/**< 32bit signed integer */
    1.54 -	typedef unsigned __int16	uint16_t;		/**< 16bit unsigned integer */
    1.55 -	typedef __int16				int16_t;		/**< 16bit signed integer */
    1.56 -	typedef unsigned __int8		uint8_t;		/**< 8bit unsigned integer */
    1.57 -	typedef __int8				int8_t;			/**< 8bit signed integer */
    1.58 - #define HAVE_STDINT_H
    1.59 - #endif
    1.60 -#endif
    1.61 -
    1.62 -#define SPFILE_MAGIC	0x53504646		/**< Source Pawn File Format (SPFF) */
    1.63 -#define SPFILE_VERSION	0x0101			/**< Uncompressed bytecode */
    1.64 -
    1.65 -//:TODO: better compiler/nix support
    1.66 -#if defined __linux__
    1.67 -	#pragma pack(1)         /* structures must be packed (byte-aligned) */
    1.68 -#else
    1.69 -	#pragma pack(push)
    1.70 -	#pragma pack(1)         /* structures must be packed (byte-aligned) */
    1.71 -#endif
    1.72 -
    1.73 -#define SPFILE_COMPRESSION_NONE		0		/**< No compression in file */
    1.74 -#define SPFILE_COMPRESSION_GZ		1		/**< GZ compression */
    1.75 -
    1.76 -/**
    1.77 - * @brief File section header format.
    1.78 - */
    1.79 -typedef struct sp_file_section_s
    1.80 -{
    1.81 -	uint32_t	nameoffs;	/**< Relative offset into global string table */
    1.82 -	uint32_t	dataoffs;	/**< Offset into the data section of the file */
    1.83 -	uint32_t	size;		/**< Size of the section's entry in the data section */
    1.84 -} sp_file_section_t;
    1.85 -
    1.86 -/**
    1.87 - * @brief File header format.  If compression is 0, then disksize may be 0 
    1.88 - * to mean that only the imagesize is needed.
    1.89 - */
    1.90 -typedef struct sp_file_hdr_s
    1.91 -{
    1.92 -	uint32_t	magic;		/**< Magic number */
    1.93 -	uint16_t	version;	/**< Version code */
    1.94 -	uint8_t		compression;/**< Compression algorithm */
    1.95 -	uint32_t	disksize;	/**< Size on disk */
    1.96 -	uint32_t	imagesize;	/**< Size in memory */
    1.97 -	uint8_t		sections;	/**< Number of sections */
    1.98 -	uint32_t	stringtab;	/**< Offset to string table */
    1.99 -	uint32_t	dataoffs;	/**< Offset to file proper (any compression starts here) */
   1.100 -} sp_file_hdr_t;
   1.101 -
   1.102 -#define SP_FLAG_DEBUG	(1<<0)		/**< Debug information is present in the file */
   1.103 -
   1.104 -/**
   1.105 - * @brief File-encoded format of the ".code" section.
   1.106 - */
   1.107 -typedef struct sp_file_code_s
   1.108 -{
   1.109 -	uint32_t	codesize;		/**< Codesize in bytes */
   1.110 -	uint8_t		cellsize;		/**< Cellsize in bytes */
   1.111 -	uint8_t		codeversion;	/**< Version of opcodes supported */
   1.112 -	uint16_t	flags;			/**< Flags */
   1.113 -	uint32_t	main;			/**< Address to "main," if any */
   1.114 -	uint32_t	code;			/**< Relative offset to code */
   1.115 -} sp_file_code_t;
   1.116 -
   1.117 -/** 
   1.118 - * @brief File-encoded format of the ".data" section.
   1.119 - */
   1.120 -typedef struct sp_file_data_s
   1.121 -{
   1.122 -	uint32_t	datasize;		/**< Size of data section in memory */
   1.123 -	uint32_t	memsize;		/**< Total mem required (includes data) */
   1.124 -	uint32_t	data;			/**< File offset to data (helper) */
   1.125 -} sp_file_data_t;
   1.126 -
   1.127 -/**
   1.128 - * @brief File-encoded format of the ".publics" section.
   1.129 - */
   1.130 -typedef struct sp_file_publics_s
   1.131 -{
   1.132 -	uint32_t	address;		/**< Address relative to code section */
   1.133 -	uint32_t	name;			/**< Index into nametable */
   1.134 -} sp_file_publics_t;
   1.135 -
   1.136 -/**
   1.137 - * @brief File-encoded format of the ".natives" section.
   1.138 - */
   1.139 -typedef struct sp_file_natives_s
   1.140 -{
   1.141 -	uint32_t	name;			/**< Index into nametable */
   1.142 -} sp_file_natives_t;
   1.143 -
   1.144 -/**
   1.145 - * @brief File-encoded format of the ".pubvars" section.
   1.146 - */
   1.147 -typedef struct sp_file_pubvars_s
   1.148 -{
   1.149 -	uint32_t	address;		/**< Address relative to the DAT section */
   1.150 -	uint32_t	name;			/**< Index into nametable */
   1.151 -} sp_file_pubvars_t;
   1.152 -
   1.153 -/**
   1.154 - * @brief File-encoded tag info.
   1.155 - */
   1.156 -typedef struct sp_file_tag_s
   1.157 -{
   1.158 -	uint32_t	tag_id;			/**< Tag ID from compiler */
   1.159 -	uint32_t	name;			/**< Index into nametable */
   1.160 -} sp_file_tag_t;
   1.161 -
   1.162 -#if defined __linux__
   1.163 -	#pragma pack()    /* reset default packing */
   1.164 -#else
   1.165 -	#pragma pack(pop) /* reset previous packing */
   1.166 -#endif
   1.167 -
   1.168 -/**
   1.169 - * @brief File-encoded debug information table.
   1.170 - */
   1.171 -typedef struct sp_fdbg_info_s
   1.172 -{
   1.173 -	uint32_t	num_files;	/**< number of files */
   1.174 -	uint32_t	num_lines;	/**< number of lines */
   1.175 -	uint32_t	num_syms;	/**< number of symbols */
   1.176 -	uint32_t	num_arrays;	/**< number of symbols which are arrays */
   1.177 -} sp_fdbg_info_t;
   1.178 -
   1.179 -/**
   1.180 - * @brief File-encoded debug file table.
   1.181 - */
   1.182 -typedef struct sp_fdbg_file_s
   1.183 -{
   1.184 -	uint32_t	addr;		/**< Address into code */
   1.185 -	uint32_t	name;		/**< Offset into debug nametable */
   1.186 -} sp_fdbg_file_t;
   1.187 -
   1.188 -/**
   1.189 - * @brief File-encoded debug line table.
   1.190 - */
   1.191 -typedef struct sp_fdbg_line_s
   1.192 -{
   1.193 -	uint32_t	addr;		/**< Address into code */
   1.194 -	uint32_t	line;		/**< Line number */
   1.195 -} sp_fdbg_line_t;
   1.196 -
   1.197 -#define SP_SYM_VARIABLE  1  /**< Cell that has an address and that can be fetched directly (lvalue) */
   1.198 -#define SP_SYM_REFERENCE 2  /**< VARIABLE, but must be dereferenced */
   1.199 -#define SP_SYM_ARRAY     3	/**< Symbol is an array */
   1.200 -#define SP_SYM_REFARRAY  4  /**< An array passed by reference (i.e. a pointer) */
   1.201 -#define SP_SYM_FUNCTION	 9  /**< Symbol is a function */
   1.202 -
   1.203 -/**
   1.204 - * @brief File-encoded debug symbol information.
   1.205 - */
   1.206 -typedef struct sp_fdbg_symbol_s
   1.207 -{
   1.208 -	int32_t		addr;		/**< Address rel to DAT or stack frame */
   1.209 -	int16_t		tagid;		/**< Tag id */
   1.210 -	uint32_t	codestart;	/**< Start scope validity in code */
   1.211 -	uint32_t	codeend;	/**< End scope validity in code */
   1.212 -	uint8_t		ident;		/**< Variable type */
   1.213 -	uint8_t		vclass;		/**< Scope class (local vs global) */
   1.214 -	uint16_t	dimcount;	/**< Dimension count (for arrays) */
   1.215 -	uint32_t	name;		/**< Offset into debug nametable */
   1.216 -} sp_fdbg_symbol_t;
   1.217 -
   1.218 -/**
   1.219 - * @brief File-encoded debug symbol array dimension info.
   1.220 - */
   1.221 -typedef struct sp_fdbg_arraydim_s
   1.222 -{
   1.223 -	int16_t		tagid;		/**< Tag id */
   1.224 -	uint32_t	size;		/**< Size of dimension */
   1.225 -} sp_fdbg_arraydim_t;
   1.226 -
   1.227 -/** Typedef for .names table */
   1.228 -typedef char * sp_file_nametab_t;
   1.229 -
   1.230 -#endif //_INCLUDE_SPFILE_HEADERS_H