ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uunconc.c
(Generate patch)

Comparing Convert-UUlib/uulib/uunconc.c (file contents):
Revision 1.10 by root, Mon Aug 19 23:25:36 2002 UTC vs.
Revision 1.11 by root, Sun Oct 13 13:08:44 2002 UTC

47#endif 47#endif
48#ifdef HAVE_ERRNO_H 48#ifdef HAVE_ERRNO_H
49#include <errno.h> 49#include <errno.h>
50#endif 50#endif
51 51
52#include <crc32.h>
52#include <uudeview.h> 53#include <uudeview.h>
53#include <uuint.h> 54#include <uuint.h>
54#include <fptools.h> 55#include <fptools.h>
55#include <uustring.h> 56#include <uustring.h>
56 57
57char * uunconc_id = "$Id: uunconc.c,v 1.10 2002/08/19 23:25:36 root Exp $"; 58char * uunconc_id = "$Id: uunconc.c,v 1.11 2002/10/13 13:08:44 root Exp $";
58 59
59/* for braindead systems */ 60/* for braindead systems */
60#ifndef SEEK_SET 61#ifndef SEEK_SET
61#ifdef L_BEGIN 62#ifdef L_BEGIN
62#define SEEK_SET L_BEGIN 63#define SEEK_SET L_BEGIN
903{ 904{
904 char *line, *oline=uuncdp_oline; 905 char *line, *oline=uuncdp_oline;
905 int warning=0, vlc=0, lc[2], hadct=0; 906 int warning=0, vlc=0, lc[2], hadct=0;
906 int tc=0, tf=0, vflag, haddata=0, haddh=0; 907 int tc=0, tf=0, vflag, haddata=0, haddh=0;
907 long yefilesize=0, yepartends=0; 908 long yefilesize=0, yepartends=0;
909 crc32_t yepartcrc=crc32(0L, Z_NULL, 0);
910 static crc32_t yefilecrc=0;
908 static int bhflag=0; 911 static int bhflag=0;
909 size_t count=0; 912 size_t count=0;
913 size_t yepartsize=0;
910 char *ptr; 914 char *ptr;
911 915
912 if (datain == NULL || dataout == NULL) { 916 if (datain == NULL || dataout == NULL) {
917 yefilecrc = crc32(0L, Z_NULL, 0);
913 bhflag = 0; 918 bhflag = 0;
914 return UURET_OK; 919 return UURET_OK;
915 } 920 }
916 921
917 /* 922 /*
1036 else 1041 else
1037 continue; 1042 continue;
1038 } 1043 }
1039 else if (method == YENC_ENCODED && 1044 else if (method == YENC_ENCODED &&
1040 strncmp (line, "=ybegin ", 8) == 0 && 1045 strncmp (line, "=ybegin ", 8) == 0 &&
1041 _FP_strstr (line, " size=") != NULL &&
1042 _FP_strstr (line, " name=") != NULL) { 1046 _FP_strstr (line, " name=") != NULL) {
1043 *state = DATA; 1047 *state = DATA;
1044 1048
1045 ptr = _FP_strstr (line, " size=") + 6; 1049 if ((ptr = _FP_strstr (line, " size=")) != NULL) {
1050 ptr += 6;
1046 yefilesize = atoi (ptr); 1051 yefilesize = atoi (ptr);
1052 }
1053 else {
1054 yefilesize = -1;
1055 }
1047 1056
1048 if (_FP_strstr (line, " part=") != NULL) { 1057 if (_FP_strstr (line, " part=") != NULL) {
1049 if (_FP_fgets (line, 1200 - 5, datain) == NULL) { 1058 if (_FP_fgets (line, 1200 - 5, datain) == NULL) {
1050 break; 1059 break;
1051 } 1060 }
1074 } 1083 }
1075 } 1084 }
1076 1085
1077 if (*state == DATA && method == YENC_ENCODED && 1086 if (*state == DATA && method == YENC_ENCODED &&
1078 strncmp (line, "=yend ", 6) == 0) { 1087 strncmp (line, "=yend ", 6) == 0) {
1088 if ((ptr = _FP_strstr (line, " pcrc32=")) != NULL) {
1089 crc32_t pcrc32 = strtoul (ptr + 8, NULL, 16);
1090 if (pcrc32 != yepartcrc) {
1091 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1092 uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno);
1093 }
1094 }
1095 if ((ptr = _FP_strstr (line, " crc32=")) != NULL)
1096 {
1097 crc32_t fcrc32 = strtoul (ptr + 7, NULL, 16);
1098 if (fcrc32 != yefilecrc) {
1099 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1100 uustring (S_CRC_MISMATCH), progress.curfile);
1101 }
1102 }
1103 if ((ptr = _FP_strstr (line, " size=")) != NULL)
1104 {
1105 size_t size = atol(ptr + 6);
1106 if (size != yepartsize && yefilesize != -1) {
1107 if (size != yefilesize)
1108 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1109 uustring (S_PSIZE_MISMATCH), progress.curfile,
1110 progress.partno, yepartsize, size);
1111 else
1112 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1113 uustring (S_SIZE_MISMATCH), progress.curfile,
1114 yepartsize, size);
1115 }
1116 }
1079 if (yepartends == 0 || yepartends >= yefilesize) { 1117 if (yepartends == 0 || yepartends >= yefilesize) {
1080 *state = DONE; 1118 *state = DONE;
1081 } 1119 }
1082 break; 1120 break;
1083 } 1121 }
1101 } 1139 }
1102 1140
1103 if (vflag == method) { 1141 if (vflag == method) {
1104 if (tf) { 1142 if (tf) {
1105 count = UUDecodeLine (line, oline, method); 1143 count = UUDecodeLine (line, oline, method);
1144 if (method == YENC_ENCODED) {
1145 if (yepartends)
1146 yepartcrc = crc32(yepartcrc, oline, count);
1147 yefilecrc = crc32(yefilecrc, oline, count);
1148 yepartsize += count;
1149 }
1106 vlc++; lc[1]++; 1150 vlc++; lc[1]++;
1107 } 1151 }
1108 else if (tc == 3) { 1152 else if (tc == 3) {
1109 count = UUDecodeLine (save[0], oline, method); 1153 count = UUDecodeLine (save[0], oline, method);
1110 count += UUDecodeLine (save[1], oline + count, method); 1154 count += UUDecodeLine (save[1], oline + count, method);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines