home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
CMDS
/
beav.1.40.lzh
/
BEAV140
/
osk.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-14
|
2KB
|
79 lines
#include <sys/types.h>
#include <module.h>
#include "def.h"
extern char MSG_crc_upd[];
extern char MSG_crc_updd[];
extern char MSG_par_updd[];
extern char MSG_no_module[];
updatecrc()
{
register WINDOW *wp = curwp;
register LINE *lp = wp->w_bufp->b_linep->l_fp;
register struct modhcom *header = (struct modhcom *) lp->l_text;
int accu = -1,i;
LINE *save_dotp = wp -> w_dotp; /* save dot position for later */
int save_doto = wp -> w_doto;
unsigned int size;
unsigned char ch;
unsigned short parity = MODSYNC;
writ_echo (MSG_crc_upd);
/* check for module sync */
if (((unsigned char)lp->l_text[0] != 0x4A) || ((unsigned char)lp->l_text[1] != 0xFC)) {
writ_echo (MSG_no_module);
return (FALSE);
}
/* buffer must be bigger than header+CRC */
if (BUF_SIZE(wp) < sizeof(struct modhcom)+4) {
writ_echo (MSG_no_module);
return (FALSE);
}
size = header->_msize = BUF_SIZE(wp);
for (i=sizeof(struct modhcom)/sizeof(parity)-2;i>0;i--)
parity ^= ((short*)header)[i];
parity = ~parity;
if (header->_mparity != parity) {
header->_mparity = parity;
writ_echo (MSG_crc_updd);
}
while (size - llength(lp) > 4) {
crc(lp->l_text,llength(lp),&accu);
size -= llength(lp);
lp = lforw(lp);
}
move_ptr (wp, header->_msize-size, TRUE, FALSE, FALSE);
while (size-- > 4) {
ch = DOT_CHAR(wp);
crc(&ch,1,&accu);
move_ptr (wp, 1L, TRUE, FALSE, TRUE);
}
crc(0,0,&accu);
accu = ~accu;
lreplace(1,accu>>24);
lreplace(1,accu>>16);
lreplace(1,accu>>8);
lreplace(1,accu);
wp -> w_dotp = save_dotp; /* restore dot position */
wp -> w_doto = save_doto;
wp -> w_flag |= WFHARD; /* update mode line */
update ();
writ_echo (MSG_crc_updd);
}