1 /*
2  * $Id: chk_fmsg.c,v 1.2 2003/02/07 17:21:01 andrew_belov Exp $
3  * ---------------------------------------------------------------------------
4  * The purpose of this module is to check the integrity of the message section
5  * by comparing its CRC-32 with the stored value.
6  *
7  */
8 
9 #include "arj.h"
10 
DEBUGHDR(__FILE__)11 DEBUGHDR(__FILE__)                      /* Debug information block */
12 
13 /* Checks the integrity of FMSG section. Reports CRC error in case of CRC
14    mismatch. */
15 
16 void check_fmsg(int skip_check)
17 {
18  FMSGP *index_ptr;
19  #if SFX_LEVEL>=ARJ
20   char fmsg_buf[MSGTEXT_MAX];
21  #endif
22 
23  crc32term=CRC_MASK;
24  #if SFX_LEVEL>=ARJ
25  if(skip_check!=CHKMSG_SKIP)
26  #else
27  if(skip_check==CHKMSG_SKIP)
28  #endif
29  {
30   for(index_ptr=FARMSGS; *index_ptr!=NULL; index_ptr++)
31   {
32    #ifdef FMSG_ST
33     far_strcpyn((char FAR *)fmsg_buf, (char FAR *)*index_ptr, sizeof(fmsg_buf));
34     crc32_for_string(fmsg_buf);
35    #else
36     crc32_for_string(*index_ptr);
37    #endif
38   }
39   if(crc32term!=FARMSGS_CRC32)
40    error(M_CRC_ERROR);
41  }
42  #if SFX_LEVEL<=ARJSFXV
43  else
44  {
45   msg_cprintf(0, strform, M_SFX_USAGE);
46   msg_cprintf(0, strform, M_SFX_COMMANDS);
47  }
48  #endif
49 }
50