21 #include <sys/mount.h> /* for BLKGETSIZE */
25 void LSEEK(int fd
, INT where
);
26 int LSEEK_(int fd
, INT where
);
28 /*******************************************************************************/
30 /*******************************************************************************/
31 #define BIGGEST_COPYING (1 * 1024 * 1024)
32 #define BLOCK_SEARCH_SIZE (4 * 1024)
33 #define SECTOR_SIZE ((INT) 512)
35 #define CTRL(c) ((c) & 0x1F)
37 #define ALT(c) ((c) | 0xa0)
38 #define DIE(M) { fprintf(stderr, M, progName); exit(1); }
39 #define FREE(p) if (p) free(p)
40 #define MIN(a, b) ((a) < (b) ? (a) : (b))
41 #define MAX(a, b) ((a) > (b) ? (a) : (b))
42 #define NORMAL A_NORMAL
43 #define MARKED A_REVERSE
44 #define MODIFIED A_BOLD
45 #define ATTRPRINTW(attr, a) do { if (oldattr != (attr)) attrset(attr), oldattr = (attr); printw a; } while (0)
46 #define MAXATTRPRINTW(attr, a) do { if (oldattr & (~(attr))) attrset(attr & oldattr), oldattr &= (attr); printw a; } while (0)
47 #define PRINTW(a) ATTRPRINTW(NORMAL, a)
49 #define getnstr(str, n) wgetnstr(stdscr, str, n)
53 /*******************************************************************************/
54 /* Configuration parameters */
55 /*******************************************************************************/
56 typedef enum { bySector
, maximized
, LAST
} modeType
;
58 int blocSize
, lineLength
, page
;
61 extern modeParams modes
[LAST
];
66 #define pressAnyKey "(press any key)"
69 /*******************************************************************************/
71 /*******************************************************************************/
72 typedef struct _typePage
{
73 struct _typePage
*next
;
81 /*******************************************************************************/
82 /* Global variables */
83 /*******************************************************************************/
85 extern INT lastEditedLoc
, biggestLoc
, fileSize
;
86 extern INT mark_min
, mark_max
, mark_set
;
87 extern INT base
, oldbase
;
88 extern int normalSpaces
, cursor
, cursorOffset
, hexOrAscii
;
89 extern int cursor
, blocSize
, lineLength
, colsUsed
, page
;
90 extern int isReadOnly
, fd
, nbBytes
, oldcursor
, oldattr
, oldcursorOffset
;
91 extern int sizeCopyBuffer
, *bufferAttr
;
92 extern char *progName
, *fileName
, *baseName
;
93 extern unsigned char *buffer
, *copyBuffer
;
94 extern typePage
*edited
;
96 extern char *lastFindFile
, *lastYankToAFile
, *lastAskHexString
, *lastAskAsciiString
, *lastFillWithStringHexa
, *lastFillWithStringAscii
;
99 /*******************************************************************************/
100 /* Miscellaneous functions declaration */
101 /*******************************************************************************/
102 INT
getfilesize(void);
103 int key_to_function(int key
);
110 int computeLineSize(void);
111 int computeCursorXCurrentPos(void);
112 int computeCursorXPos(int cursor
, int hexOrAscii
);
113 void updateMarked(void);
114 int ask_about_save(void);
115 int ask_about_save_and_redisplay(void);
116 void ask_about_save_and_quit(void);
118 void setToChar(int i
, unsigned char c
);
120 /*******************************************************************************/
121 /* Pages handling functions declaration */
122 /*******************************************************************************/
123 void discardEdited(void);
124 void addToEdited(INT base
, int size
, unsigned char *vals
);
125 void removeFromEdited(INT base
, int size
);
126 typePage
*newPage(INT base
, int size
);
127 void freePage(typePage
*page
);
130 /*******************************************************************************/
131 /* Cursor manipulation function declarations */
132 /*******************************************************************************/
133 int move_cursor(INT delta
);
134 int set_cursor(INT loc
);
135 int move_base(INT delta
);
136 int set_base(INT loc
);
138 /*******************************************************************************/
139 /* Curses functions declaration */
140 /*******************************************************************************/
141 void initCurses(void);
142 void exitCurses(void);
144 void displayLine(int offset
, int max
);
145 void clr_line(int line
);
146 void displayCentered(char *msg
, int line
);
147 void displayOneLineMessage(char *msg
);
148 void displayTwoLineMessage(char *msg1
, char *msg2
);
149 void displayMessageAndWaitForKey(char *msg
);
150 int displayMessageAndGetString(char *msg
, char **last
, char *p
, int p_size
);
151 void ungetstr(char *s
);
152 int get_number(INT
*i
);
155 /*******************************************************************************/
156 /* Search functions declaration */
157 /*******************************************************************************/
158 void search_forward(void);
159 void search_backward(void);
162 /*******************************************************************************/
163 /* Mark functions declaration */
164 /*******************************************************************************/
165 void markRegion(INT a
, INT b
);
166 void unmarkRegion(INT a
, INT b
);
167 void markSelectedRegion(void);
168 void unmarkAll(void);
170 void unmarkIt(int i
);
171 void copy_region(void);
173 void yank_to_a_file(void);
174 void fill_with_string(void);
177 /*******************************************************************************/
178 /* Small common functions declaration */
179 /*******************************************************************************/
180 int streq(const char *s1
, const char *s2
);
181 int strbeginswith(const char *a
, const char *prefix
);
182 int myceil(int a
, int b
);
183 INT
myfloor(INT a
, INT b
);
184 int setLowBits(int p
, int val
);
185 int setHighBits(int p
, int val
);
186 char *strconcat3(char *a
, char *b
, char *c
);
187 int hexCharToInt(int c
);
189 char *mymemmem(char *a
, int sizea
, char *b
, int sizeb
);
190 char *mymemrmem(char *a
, int sizea
, char *b
, int sizeb
);
191 int is_file(char *name
);
192 int hexStringToBinString(char *p
, int *l
);
194 #endif /* HEXEDIT_H */