summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimo Savinen <tjsa@iki.fi>2005-10-09 14:36:39 +0000
committerHadrien Dorio <hadrien.dorio@gmail.com>2017-12-16 00:24:05 +0100
commitb8e1dc4200c8e57024b9a37edc67f9a24c02f0e5 (patch)
tree49e33aa104913d84863a2228ca0edaf912345492 /src
parent11460c1f56ed4939c8f0df0482059f5fecd289fa (diff)
downloadbinary-block-editor-b8e1dc4200c8e57024b9a37edc67f9a24c02f0e5.tar.gz
binary-block-editor-b8e1dc4200c8e57024b9a37edc67f9a24c02f0e5.zip
0.1.3
Diffstat (limited to 'src')
-rw-r--r--src/bbe.c8
-rw-r--r--src/execute.c31
2 files changed, 30 insertions, 9 deletions
diff --git a/src/bbe.c b/src/bbe.c
index 6a57fab..ae456cc 100644
--- a/src/bbe.c
+++ b/src/bbe.c
@@ -20,7 +20,7 @@
*
*/
-/* $Id: bbe.c,v 1.33 2005/09/30 10:58:15 timo Exp $ */
+/* $Id: bbe.c,v 1.35 2005/10/06 16:48:06 timo Exp $ */
#include "bbe.h"
#ifdef HAVE_GETOPT_H
@@ -43,7 +43,7 @@ static char *program = "bbe";
#ifdef VERSION
static char *version = VERSION;
#else
-static char *version = "0.1.2";
+static char *version = "0.1.3";
#endif
#ifdef PACKAGE_BUGREPORT
@@ -73,7 +73,7 @@ char *convert_strings[] = {
};
/* format types for p command */
-char *p_formats="DOHA";
+char *p_formats="DOHAB";
/* formats for F and B commands */
char *FB_formats="DOH";
@@ -662,7 +662,7 @@ help(FILE *stream)
fprintf(stream,"\t\tSuppress normal output, print only block contents.\n");
fprintf(stream,"-?, --help\n");
fprintf(stream,"\t\tDisplay this help and exit.\n");
- fprintf(stream,"-V, --Version\n");
+ fprintf(stream,"-V, --version\n");
#else
fprintf(stream,"-b BLOCK\n");
fprintf(stream,"\t\tBlock definition.\n");
diff --git a/src/execute.c b/src/execute.c
index a69932b..ffadc3c 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -20,7 +20,7 @@
*
*/
-/* $Id: execute.c,v 1.23 2005/09/30 10:58:15 timo Exp $ */
+/* $Id: execute.c,v 1.25 2005/10/05 16:06:11 timo Exp $ */
#include "bbe.h"
#include <stdlib.h>
@@ -51,6 +51,9 @@ static struct command *current_commands;
/* commands to be executed at end of buffer */
#define BLOCK_END_COMMANDS "AJL"
+/* most significant bit of byte */
+#define BYTE_MASK (1 << (sizeof(unsigned char) * 8 - 1))
+
/* byte_to_string, convert byte value to visible string,
either hex (H), decimal (D), octal (O) or ascii (A)
@@ -58,7 +61,9 @@ static struct command *current_commands;
char *
byte_to_string(unsigned char byte,char format)
{
- static char string[10];
+ static char string[128];
+ int i;
+ int j;
switch(format)
{
@@ -74,6 +79,15 @@ byte_to_string(unsigned char byte,char format)
case 'A':
sprintf(string,"%c",isprint(byte) ? byte : ' ');
break;
+ case 'B':
+ i = 0;
+ do
+ {
+ string[i] = ((BYTE_MASK >> i) & byte) ? '1' : '0';
+ i++;
+ } while (BYTE_MASK >> i);
+ string[i] = 0;
+ break;
default:
string[0] = 0;
break;
@@ -233,7 +247,7 @@ execute_commands(struct command *c,char *command_letters)
c->rpos = 0;
if(last_byte()) // unless last byte of block
{
- if(*out_buffer.write_pos >= '0' && *out_buffer.write_pos <= '9')
+ if(*out_buffer.write_pos >= '0' && *out_buffer.write_pos <= '9')
{
a = *out_buffer.write_pos - '0';
a = (a << 4) & 0xf0;
@@ -257,6 +271,7 @@ execute_commands(struct command *c,char *command_letters)
} else
{
b = 0x0f;
+ if(*out_buffer.write_pos == 'F' || *out_buffer.write_pos == 'f') delete_this_byte=1;
}
out_buffer.write_pos[-1] = a | b;
}
@@ -273,10 +288,16 @@ execute_commands(struct command *c,char *command_letters)
a = (*out_buffer.write_pos >> 4) & 0x0f;
b = *out_buffer.write_pos & 0x0f;
*out_buffer.write_pos = '0' + a;
- if(!delete_this_byte && b != 0x0f)
+ if(!delete_this_byte)
{
write_next_byte();
- *out_buffer.write_pos = '0' + b;
+ if(b == 0x0f)
+ {
+ *out_buffer.write_pos = 'F';
+ } else
+ {
+ *out_buffer.write_pos = '0' + b;
+ }
}
}
break;
OpenPOWER on IntegriCloud