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.3.2.2 by root, Sun Mar 31 19:52:07 2002 UTC vs.
Revision 1.3.2.3 by root, Sun Oct 13 13:03:08 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.3.2.2 2002/03/31 19:52:07 root Exp $"; 58char * uunconc_id = "$Id: uunconc.c,v 1.3.2.3 2002/10/13 13:03:08 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
714 if (*++s != '\0') { 715 if (*++s != '\0') {
715 d[count++] = (char) ((int) *s - 64 - 42); 716 d[count++] = (char) ((int) *s - 64 - 42);
716 s++; 717 s++;
717 } 718 }
718 } 719 }
719 else if (*s == '\t' || *s == '\n' || *s == '\r') { 720 else if (*s == '\n' || *s == '\r') {
720 s++; /* ignore */ 721 s++; /* ignore */
721 } 722 }
722 else { 723 else {
723 d[count++] = (char) ((int) *s++ - 42); 724 d[count++] = (char) ((int) *s++ - 42);
724 } 725 }
900{ 901{
901 char *line=uugen_fnbuffer, *oline=uuncdp_oline; 902 char *line=uugen_fnbuffer, *oline=uuncdp_oline;
902 int warning=0, vlc=0, lc[2], hadct=0; 903 int warning=0, vlc=0, lc[2], hadct=0;
903 int tc=0, tf=0, vflag, haddata=0, haddh=0; 904 int tc=0, tf=0, vflag, haddata=0, haddh=0;
904 long yefilesize=0, yepartends=0; 905 long yefilesize=0, yepartends=0;
906 crc32_t yepartcrc=crc32(0L, Z_NULL, 0);
907 static crc32_t yefilecrc=0;
905 static int bhflag=0; 908 static int bhflag=0;
906 size_t count=0; 909 size_t count=0;
910 size_t yepartsize=0;
907 char *ptr; 911 char *ptr;
908 912
909 if (datain == NULL || dataout == NULL) { 913 if (datain == NULL || dataout == NULL) {
914 yefilecrc = crc32(0L, Z_NULL, 0);
910 bhflag = 0; 915 bhflag = 0;
911 return UURET_OK; 916 return UURET_OK;
912 } 917 }
913 918
914 /* 919 /*
1029 else 1034 else
1030 continue; 1035 continue;
1031 } 1036 }
1032 else if (method == YENC_ENCODED && 1037 else if (method == YENC_ENCODED &&
1033 strncmp (line, "=ybegin ", 8) == 0 && 1038 strncmp (line, "=ybegin ", 8) == 0 &&
1034 _FP_strstr (line, " size=") != NULL &&
1035 _FP_strstr (line, " name=") != NULL) { 1039 _FP_strstr (line, " name=") != NULL) {
1036 *state = DATA; 1040 *state = DATA;
1037 1041
1038 ptr = _FP_strstr (line, " size=") + 6; 1042 if ((ptr = _FP_strstr (line, " size=")) != NULL) {
1043 ptr += 6;
1039 yefilesize = atoi (ptr); 1044 yefilesize = atoi (ptr);
1045 }
1046 else {
1047 yefilesize = -1;
1048 }
1040 1049
1041 if (_FP_strstr (line, " part=") != NULL) { 1050 if (_FP_strstr (line, " part=") != NULL) {
1042 if (_FP_fgets (line, 299, datain) == NULL) { 1051 if (_FP_fgets (line, 299, datain) == NULL) {
1043 break; 1052 break;
1044 } 1053 }
1067 } 1076 }
1068 } 1077 }
1069 1078
1070 if (*state == DATA && method == YENC_ENCODED && 1079 if (*state == DATA && method == YENC_ENCODED &&
1071 strncmp (line, "=yend ", 6) == 0) { 1080 strncmp (line, "=yend ", 6) == 0) {
1081 if ((ptr = _FP_strstr (line, " pcrc32=")) != NULL) {
1082 crc32_t pcrc32 = strtoul (ptr + 8, NULL, 16);
1083 if (pcrc32 != yepartcrc) {
1084 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1085 uustring (S_PCRC_MISMATCH), progress.curfile, progress.partno);
1086 }
1087 }
1088 if ((ptr = _FP_strstr (line, " crc32=")) != NULL)
1089 {
1090 crc32_t fcrc32 = strtoul (ptr + 7, NULL, 16);
1091 if (fcrc32 != yefilecrc) {
1092 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1093 uustring (S_CRC_MISMATCH), progress.curfile);
1094 }
1095 }
1096 if ((ptr = _FP_strstr (line, " size=")) != NULL)
1097 {
1098 size_t size = atol(ptr + 6);
1099 if (size != yepartsize && yefilesize != -1) {
1100 if (size != yefilesize)
1101 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1102 uustring (S_PSIZE_MISMATCH), progress.curfile,
1103 progress.partno, yepartsize, size);
1104 else
1105 UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
1106 uustring (S_SIZE_MISMATCH), progress.curfile,
1107 yepartsize, size);
1108 }
1109 }
1072 if (yepartends == 0 || yepartends >= yefilesize) { 1110 if (yepartends == 0 || yepartends >= yefilesize) {
1073 *state = DONE; 1111 *state = DONE;
1074 } 1112 }
1075 break; 1113 break;
1076 } 1114 }
1094 } 1132 }
1095 1133
1096 if (vflag == method) { 1134 if (vflag == method) {
1097 if (tf) { 1135 if (tf) {
1098 count = UUDecodeLine (line, oline, method); 1136 count = UUDecodeLine (line, oline, method);
1137 if (method == YENC_ENCODED) {
1138 if (yepartends)
1139 yepartcrc = crc32(yepartcrc, oline, count);
1140 yefilecrc = crc32(yefilecrc, oline, count);
1141 yepartsize += count;
1142 }
1099 vlc++; lc[1]++; 1143 vlc++; lc[1]++;
1100 } 1144 }
1101 else if (tc == 3) { 1145 else if (tc == 3) {
1102 count = UUDecodeLine (save[0], oline, method); 1146 count = UUDecodeLine (save[0], oline, method);
1103 count += UUDecodeLine (save[1], oline + count, method); 1147 count += UUDecodeLine (save[1], oline + count, method);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines