/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef __ELFEDIT_H
#define __ELFEDIT_H
#include <setjmp.h>
#include <libtecla.h>
#include <elfedit.h>
/*
* Local include file for elfedit.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Maximum command line, and history
*/
/* Maximum number of command completion arguments */
/* Maximum length of a module name */
/*
* In elfedit.h, you will find elfedit32_cmd_t and elfedit64_cmd_t
* typedefs. These types are identical, except for the definition
* of the cmd_func and cmd_cplfunc function pointers. These function
* pointers have different argument definitions that reflect the
* different object state definition blocks for the 32 and 64-bit cases.
* Yet, From a strictly machine based view, these two types are identical
* in size and layout:
*
* - At the machine level, all function pointers are simply
* machine sized words containing an address.
*
* - Other than the function pointers, the remaining fields
* are exactly the same in both cases.
*
* The vast majority of elfedit's internals that examine elfedit_cmd_t
* are looking at the non-function pointer fields. It simplfiies
* a great deal of code if we can treat elfedit32_cmd_t and elfedit64_cmd_t
* as equivalent types for this purpose. In C++, we would do this with
* a superclass. In C, we do it by defining another variant named
* elfeditGC_cmd_t (GC stands for "Generic Class"). The function pointers
* are replaced with (void *) pointers. This variant has the same size
* and layout as the others. We use it internally to represent either type.
* In the cases where we need to use the function pointers, we first cast
* them to the proper type for the ELFCLASS being processed.
*
* The existance of elfeditGC_cmd_t implies the need for elfeditGC_module_t,
* for the same reasons.
*
* It is extremely important that these definitions exactly mirror the
* definitions in elfedit.h.
*/
typedef struct {
void *cmd_func;
void *cmd_cplfunc;
const char **cmd_name;
typedef struct {
const char *mod_name;
/*
* The result of parsing a user command is one of these blocks entered
* at the end of state.user_cmd. They encapsulate the arguments and
* the command function to call. In combination with an elfedit_obj_state_t,
* they contain everything needed to execute a specified operation. A single
* call to free() suffices to release the ELFEDIT_USER_CMD and any memory
* it references.
*/
typedef struct user_cmd_t {
/* output style active */
} USER_CMD_T;
/*
* MODLIST_T is used to manage module definitions. Note that a simple linked
* list is used to maintain the set of active modules. This can be easily
* changed if the number of modules grows to a point where the lookup
* time is noticible.
*/
typedef struct moddef_t {
} MODLIST_T;
/*
* Type of the global variable used to maintain elfedit state.
*/
typedef struct {
struct {
/* False otherwise */
/*
* The remaining file fields are not to be accessed
* unless present is True.
*/
} file;
struct { /* Jump buffer used for ELFEDIT_MSG_ERR */
} msg_jbuf;
struct { /* Search path used to find modules */
size_t n; /* # of path segments */
} modpath;
struct { /* Linked list of user commands to execute */
size_t n; /* # of commands */
} ucmd;
struct { /* Pager related state */
} pager;
struct {
} input;
struct { /* ELF file state */
/* Recheck elfconst strs */
/*
* Information for the ELF object being edited.
* The value of elfclass determines which of these
* fields is valid in the current session. This is
* only usable if file.present is True. Otherwise, there
* is no object state, and these pointers will be NULL.
*/
union {
} obj_state;
} elf;
} STATE_T;
/*
* Type of item argument to elfedit_next_optarg(), used to pull together
* the information for a single command option or argument, handling
* the ELFEDIT_CMDOA_F_VALUE and ELFEDIT_CMDOA_F_INHERIT cases.
*/
typedef struct {
/* ELFEDIT_CMDOA_F_VALUE */
/* Global state is accessible between elfedit files */
/*
* getopt related routines that are not public
*/
extern void elfedit_set_cmd_outstyle(const char *str);
/* elfedit internal functions used by sys module */
extern void elfedit_exit(int status);
int allow_abs_path);
int abs_path);
extern void elfedit_load_modpath(void);
extern void elfedit_unload_module(const char *name);
/* Used by elfedit_getopt_init() to access options array for command */
elfeditGC_cmd_t *elfedit_curcmd(void);
/* elfedit_machelf functions used by elfedit */
#ifdef __cplusplus
}
#endif
#endif /* __ELFEDIT_H */