version 1.1.1.1, 1999/10/29 08:06:41 |
version 1.3, 1999/11/02 21:15:02 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/ox_math/bconv.c,v 1.2 1999/11/02 06:11:57 ohara Exp $ */ |
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
OX expression -> バイト列 |
OX expression -> バイト列 |
Line 12 CMO expression -> バイト列 |
|
Line 12 CMO expression -> バイト列 |
|
#include "ox.h" |
#include "ox.h" |
#include "parse.h" |
#include "parse.h" |
|
|
char* dump_ox_data(char* array, ox_data* m); |
static int display(ox *m) |
char* dump_ox_command(char* array, ox_command* m); |
|
|
|
int display(ox *m) |
|
{ |
{ |
int i; |
int i; |
int len = 0; |
int len = 0; |
unsigned char* array; |
unsigned char* d_buff; |
|
|
switch(m->tag) { |
switch(m->tag) { |
case OX_DATA: |
case OX_DATA: |
len = sizeof(int) + sizeof(int) + cmolen_cmo(((ox_data *)m)->cmo); |
len = sizeof(int) + sizeof(int) + cmolen_cmo(((ox_data *)m)->cmo); |
array = malloc(len); |
d_buff = malloc(len); |
dump_ox_data(array, (ox_data *)m); |
init_dump_buffer(d_buff); |
|
dump_ox_data((ox_data *)m); |
break; |
break; |
case OX_COMMAND: |
case OX_COMMAND: |
len = sizeof(int) + sizeof(int) + sizeof(int); |
len = sizeof(int) + sizeof(int) + sizeof(int); |
array = malloc(len); |
d_buff = malloc(len); |
dump_ox_command(array, (ox_command *)m); |
init_dump_buffer(d_buff); |
|
dump_ox_command((ox_command *)m); |
break; |
break; |
default: |
default: |
len = cmolen_cmo(m); |
len = cmolen_cmo((cmo *)m); |
array = malloc(len); |
d_buff = malloc(len); |
dump_cmo(array, m); |
init_dump_buffer(d_buff); |
|
dump_cmo((cmo *)m); |
} |
} |
|
|
for(i=0; i<len; i++) { |
for(i=0; i<len; i++) { |
fprintf(stdout, "%02x ", array[i]); |
fprintf(stdout, "%02x ", d_buff[i]); |
if(i%20==19) { |
if(i%20 == 19) { |
fprintf(stdout, "\n"); |
fprintf(stdout, "\n"); |
} |
} |
} |
} |
fprintf(stdout, "\n"); |
if(i%20 != 19) { |
|
fprintf(stdout, "\n"); |
|
} |
|
free(d_buff); |
} |
} |
|
|
#define SIZE_CMDLINE 4096 |
#define SIZE_CMDLINE 8192 |
|
|
char cmdline[SIZE_CMDLINE]; |
static int size = SIZE_CMDLINE; |
|
static char cmdline[SIZE_CMDLINE]; |
|
|
int prompt(char* s, int size) |
static int prompt() |
{ |
{ |
fprintf(stdout, "> "); |
fprintf(stdout, "> "); |
fgets(s, size, stdin); |
fgets(cmdline, size, stdin); |
setmode_mygetc(s, size); |
setmode_mygetc(cmdline, size); |
} |
} |
|
|
int main() |
int main() |
|
|
setbuf(stderr, NULL); |
setbuf(stderr, NULL); |
setbuf(stdout, NULL); |
setbuf(stdout, NULL); |
|
|
cmo_addrev = 1; |
setflag_parse(PFLAG_ADDREV); |
setgetc(mygetc); |
setgetc(mygetc); |
|
|
while(1) { |
for(prompt(); (m = parse()) != NULL; prompt()) { |
prompt(cmdline, SIZE_CMDLINE); |
|
if ((m = parse()) == NULL) { |
|
break; |
|
} |
|
display(m); |
display(m); |
} |
} |
return 0; |
return 0; |