GoldED+ sources: Initial revision.
This commit is contained in:
12
goldlib/uulib/Makefile
Normal file
12
goldlib/uulib/Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
VERSION=0.5
|
||||
PATCH=13
|
||||
|
||||
TOP=../..
|
||||
TARGET=uulib
|
||||
INCS=-I$(TOP)/goldlib/uulib
|
||||
CFLAGS=-DHAVE_CONFIG_H -DVERSION=\"$(VERSION)\" -DPATCH=\"$(PATCH)\"
|
||||
|
||||
include $(TOP)/GNUmakef.inc
|
||||
include $(TOP)/GNUmakef.lib
|
76
goldlib/uulib/config.h
Normal file
76
goldlib/uulib/config.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* config.h. Generated automatically by configure. */
|
||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/*
|
||||
* If your system is kinda special
|
||||
*/
|
||||
/* #undef SYSTEM_DOS */
|
||||
/* #undef SYSTEM_QUICKWIN */
|
||||
/* #undef SYSTEM_WINDLL */
|
||||
/* #undef SYSTEM_OS2 */
|
||||
|
||||
/*
|
||||
* If your system has stdin/stdout/stderr
|
||||
*/
|
||||
#define HAVE_STDIO 1
|
||||
|
||||
/*
|
||||
* how to declare functions that are exported from the UU library
|
||||
*/
|
||||
#define UUEXPORT
|
||||
|
||||
/*
|
||||
* how to declare functions that are exported from the fptools library
|
||||
*/
|
||||
#define TOOLEXPORT
|
||||
|
||||
/*
|
||||
* define if your compiler supports function prototypes
|
||||
*/
|
||||
#define PROTOTYPES 1
|
||||
|
||||
/*
|
||||
* Replacement functions.
|
||||
* #define strerror _FP_strerror
|
||||
* #define tempnam _FP_tempnam
|
||||
* if you don't have these functions
|
||||
*/
|
||||
|
||||
/* Define if you have the gettimeofday function. */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
|
||||
/* Define if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define if you have the <io.h> header file. */
|
||||
#undef HAVE_IO_H
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* Define if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define if you have the <stdarg.h> header file. */
|
||||
/* #undef HAVE_STDARG_H */
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define if you have the <varargs.h> header file. */
|
||||
/* #undef HAVE_VARARGS_H */
|
512
goldlib/uulib/fptools.c
Normal file
512
goldlib/uulib/fptools.c
Normal file
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
* fptools.c, some helper functions for getcgi.c and uu(en|de)view
|
||||
*
|
||||
* Distributed by the GNU General Public License. Use and be happy.
|
||||
* Read http://www.uni-frankfurt.de/~fp/Tools/Getcgi.html for more
|
||||
* information. fp@informatik.uni-frankfurt.de
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef SYSTEM_WINDLL
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifdef SYSTEM_OS2
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This file provides replacements for some handy functions that aren't
|
||||
* available on all systems, like most of the <string.h> functions. They
|
||||
* should behave exactly as their counterparts. There are also extensions
|
||||
* that aren't portable at all (like strirstr etc.).
|
||||
* The proper behaviour in a configure script is as follows:
|
||||
* AC_CHECK_FUNC(strrchr,AC_DEFINE(strrchr,_FP_strrchr))
|
||||
* This way, the (probably less efficient) replacements will only be used
|
||||
* where it is not provided by the default libraries. Be aware that this
|
||||
* does not work with replacements that just shadow wrong behaviour (like
|
||||
* _FP_free) or provide extended functionality (_FP_gets).
|
||||
* The above is not used in the uuenview/uudeview configuration script,
|
||||
* since both only use the replacement functions in non-performance-cri-
|
||||
* tical sections (except for _FP_tempnam and _FP_strerror, where some
|
||||
* functionality of the original would be lost).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#include <fptools.h>
|
||||
|
||||
#if 0
|
||||
#ifdef SYSTEM_WINDLL
|
||||
BOOL _export WINAPI
|
||||
DllEntryPoint (HINSTANCE hInstance, DWORD seginfo,
|
||||
LPVOID lpCmdLine)
|
||||
{
|
||||
/* Don't do anything, so just return true */
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
char * fptools_id = "$Id$";
|
||||
|
||||
/*
|
||||
* some versions of free can't handle a NULL pointer properly
|
||||
* (ANSI says, free ignores a NULL pointer, but some machines
|
||||
* prefer to SIGSEGV on it)
|
||||
*/
|
||||
|
||||
void TOOLEXPORT
|
||||
_FP_free (void *ptr)
|
||||
{
|
||||
if (ptr) free (ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is non-standard, so I'm defining my own
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_strdup (char *string)
|
||||
{
|
||||
char *result;
|
||||
|
||||
if (string == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((result = (char *) malloc (strlen (string) + 1)) == NULL)
|
||||
return NULL;
|
||||
|
||||
strcpy (result, string);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* limited-length string copy. this function behaves differently from
|
||||
* the original in that the dest string is always terminated with a
|
||||
* NULL character.
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_strncpy (char *dest, char *src, int length)
|
||||
{
|
||||
char *odest=dest;
|
||||
if (src == NULL || dest == NULL || length-- <= 0)
|
||||
return dest;
|
||||
|
||||
while (length-- && *src)
|
||||
*dest++ = *src++;
|
||||
|
||||
*dest++ = '\0';
|
||||
return odest;
|
||||
}
|
||||
|
||||
/*
|
||||
* duplicate a memory area
|
||||
*/
|
||||
|
||||
void * TOOLEXPORT
|
||||
_FP_memdup (void *ptr, int len)
|
||||
{
|
||||
void *result;
|
||||
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((result = malloc (len)) == NULL)
|
||||
return NULL;
|
||||
|
||||
memcpy (result, ptr, len);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* case-insensitive compare
|
||||
*/
|
||||
|
||||
int TOOLEXPORT
|
||||
_FP_stricmp (char *str1, char *str2)
|
||||
{
|
||||
if (str1==NULL || str2==NULL)
|
||||
return -1;
|
||||
|
||||
while (*str1) {
|
||||
if (tolower(*str1) != tolower(*str2))
|
||||
break;
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
return (tolower (*str1) - tolower (*str2));
|
||||
}
|
||||
|
||||
int TOOLEXPORT
|
||||
_FP_strnicmp (char *str1, char *str2, int count)
|
||||
{
|
||||
if (str1==NULL || str2==NULL)
|
||||
return -1;
|
||||
|
||||
while (*str1 && count) {
|
||||
if (tolower(*str1) != tolower(*str2))
|
||||
break;
|
||||
str1++;
|
||||
str2++;
|
||||
count--;
|
||||
}
|
||||
return count ? (tolower (*str1) - tolower (*str2)) : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* autoconf says this function might be a compatibility problem
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_strstr (char *str1, char *str2)
|
||||
{
|
||||
char *ptr1, *ptr2;
|
||||
|
||||
if (str1==NULL)
|
||||
return NULL;
|
||||
if (str2==NULL)
|
||||
return str1;
|
||||
|
||||
while (*(ptr1=str1)) {
|
||||
for (ptr2=str2;
|
||||
*ptr1 && *ptr2 && *ptr1==*ptr2;
|
||||
ptr1++, ptr2++)
|
||||
/* empty loop */ ;
|
||||
|
||||
if (*ptr2 == '\0')
|
||||
return str1;
|
||||
str1++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_strpbrk (char *str, char *accept)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
if (accept == NULL || *accept == '\0')
|
||||
return str;
|
||||
|
||||
for (; *str; str++)
|
||||
for (ptr=accept; *ptr; ptr++)
|
||||
if (*str == *ptr)
|
||||
return str;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* autoconf also complains about this one
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_strtok (char *str1, char *str2)
|
||||
{
|
||||
static char *optr;
|
||||
char *ptr;
|
||||
|
||||
if (str2 == NULL)
|
||||
return NULL;
|
||||
|
||||
if (str1) {
|
||||
optr = str1;
|
||||
}
|
||||
else {
|
||||
if (*optr == '\0')
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (*optr && strchr (str2, *optr)) /* look for beginning of token */
|
||||
optr++;
|
||||
|
||||
if (*optr == '\0') /* no token found */
|
||||
return NULL;
|
||||
|
||||
ptr = optr;
|
||||
while (*optr && strchr (str2, *optr) == NULL) /* look for end of token */
|
||||
optr++;
|
||||
|
||||
if (*optr) {
|
||||
*optr++ = '\0';
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* case insensitive strstr.
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_stristr (char *str1, char *str2)
|
||||
{
|
||||
char *ptr1, *ptr2;
|
||||
|
||||
if (str1==NULL)
|
||||
return NULL;
|
||||
if (str2==NULL)
|
||||
return str1;
|
||||
|
||||
while (*(ptr1=str1)) {
|
||||
for (ptr2=str2;
|
||||
*ptr1 && *ptr2 && tolower(*ptr1)==tolower(*ptr2);
|
||||
ptr1++, ptr2++)
|
||||
/* empty loop */ ;
|
||||
|
||||
if (*ptr2 == '\0')
|
||||
return str1;
|
||||
str1++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Nice fake of the real (non-standard) one
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_strrstr (char *ptr, char *str)
|
||||
{
|
||||
char *found=NULL, *new, *iter=ptr;
|
||||
|
||||
if (ptr==NULL || str==NULL)
|
||||
return NULL;
|
||||
|
||||
if (*str == '\0')
|
||||
return ptr;
|
||||
|
||||
while ((new = _FP_strstr (iter, str)) != NULL) {
|
||||
found = new;
|
||||
iter = new + 1;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_strirstr (char *ptr, char *str)
|
||||
{
|
||||
char *found=NULL, *iter=ptr, *new;
|
||||
|
||||
if (ptr==NULL || str==NULL)
|
||||
return NULL;
|
||||
if (*str == '\0')
|
||||
return ptr;
|
||||
|
||||
while ((new = _FP_stristr (iter, str)) != NULL) {
|
||||
found = new;
|
||||
iter = new + 1;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/*
|
||||
* convert whole string to case
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_stoupper (char *input)
|
||||
{
|
||||
char *iter = input;
|
||||
|
||||
if (input == NULL)
|
||||
return NULL;
|
||||
|
||||
while (*iter) {
|
||||
*iter = toupper (*iter);
|
||||
iter++;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_stolower (char *input)
|
||||
{
|
||||
char *iter = input;
|
||||
|
||||
if (input == NULL)
|
||||
return NULL;
|
||||
|
||||
while (*iter) {
|
||||
*iter = tolower (*iter);
|
||||
iter++;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
/*
|
||||
* string matching with wildcards
|
||||
*/
|
||||
|
||||
int TOOLEXPORT
|
||||
_FP_strmatch (char *string, char *pattern)
|
||||
{
|
||||
char *p1 = string, *p2 = pattern;
|
||||
|
||||
if (pattern==NULL || string==NULL)
|
||||
return 0;
|
||||
|
||||
while (*p1 && *p2) {
|
||||
if (*p2 == '?') {
|
||||
p1++; p2++;
|
||||
}
|
||||
else if (*p2 == '*') {
|
||||
if (*++p2 == '\0')
|
||||
return 1;
|
||||
while (*p1 && *p1 != *p2)
|
||||
p1++;
|
||||
}
|
||||
else if (*p1 == *p2) {
|
||||
p1++; p2++;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
if (*p1 || *p2)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_strrchr (char *string, int tc)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
if (string == NULL)
|
||||
return NULL;
|
||||
|
||||
ptr = string + strlen (string) - 1;
|
||||
|
||||
while (ptr != string && *ptr != tc)
|
||||
ptr--;
|
||||
|
||||
if (*ptr == tc)
|
||||
return ptr;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* strip directory information from a filename. Works only on DOS and
|
||||
* Unix systems so far ...
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_cutdir (char *filename)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
if (filename == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((ptr = _FP_strrchr (filename, '/')) != NULL)
|
||||
ptr++;
|
||||
else if ((ptr = _FP_strrchr (filename, '\\')) != NULL)
|
||||
ptr++;
|
||||
else
|
||||
ptr = filename;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* My own fgets function. It handles all kinds of line terminators
|
||||
* properly: LF (Unix), CRLF (DOS) and CR (Mac). In all cases, the
|
||||
* terminator is replaced by a single LF
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_fgets (char *buf, int n, FILE *stream)
|
||||
{
|
||||
char *obp = buf;
|
||||
int c;
|
||||
|
||||
if (feof (stream))
|
||||
return NULL;
|
||||
|
||||
while (--n) {
|
||||
if ((c = fgetc (stream)) == EOF) {
|
||||
if (ferror (stream))
|
||||
return NULL;
|
||||
else {
|
||||
if (obp == buf)
|
||||
return NULL;
|
||||
*buf = '\0';
|
||||
return obp;
|
||||
}
|
||||
}
|
||||
if (c == '\015') { /* CR */
|
||||
/*
|
||||
* Peek next character. If it's no LF, push it back.
|
||||
* ungetc(EOF, stream) is handled correctly according
|
||||
* to the manual page
|
||||
*/
|
||||
if ((c = fgetc (stream)) != '\012')
|
||||
if (!feof (stream))
|
||||
ungetc (c, stream);
|
||||
*buf++ = '\012';
|
||||
*buf = '\0';
|
||||
return obp;
|
||||
}
|
||||
else if (c == '\012') { /* LF */
|
||||
*buf++ = '\012';
|
||||
*buf = '\0';
|
||||
return obp;
|
||||
}
|
||||
/*
|
||||
* just another standard character
|
||||
*/
|
||||
*buf++ = c;
|
||||
}
|
||||
/*
|
||||
* n-1 characters already transferred
|
||||
*/
|
||||
*buf = '\0';
|
||||
|
||||
return obp;
|
||||
}
|
||||
|
||||
/*
|
||||
* A replacement strerror function that just returns the error code
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_strerror (int errcode)
|
||||
{
|
||||
static char number[8];
|
||||
|
||||
sprintf (number, "%03d", errcode);
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
/*
|
||||
* tempnam is not ANSI, but tmpnam is. Ignore the prefix here.
|
||||
*/
|
||||
|
||||
char * TOOLEXPORT
|
||||
_FP_tempnam (char *dir, char *pfx)
|
||||
{
|
||||
return _FP_strdup (tmpnam (NULL));
|
||||
}
|
60
goldlib/uulib/fptools.h
Normal file
60
goldlib/uulib/fptools.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* fptools.c, some helper functions for getcgi.c and uu(en|de)view
|
||||
*
|
||||
* Distributed by the GNU General Public License. Use and be happy.
|
||||
* Read http://www.uni-frankfurt.de/~fp/Tools/Getcgi.html for more
|
||||
* information. fp@informatik.uni-frankfurt.de
|
||||
*/
|
||||
|
||||
/*
|
||||
* Some handy, nonstandard functions. Note that the original may
|
||||
* be both faster and better. ``better'', if your compiler allows
|
||||
* cleaner use of such functions by proper use of ``const''.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __FPTOOLS_H__
|
||||
#define __FPTOOLS_H__
|
||||
|
||||
#ifndef _ANSI_ARGS_
|
||||
#ifdef PROTOTYPES
|
||||
#define _ANSI_ARGS_(c) c
|
||||
#else
|
||||
#define _ANSI_ARGS_(c) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef TOOLEXPORT
|
||||
#define TOOLEXPORT
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void TOOLEXPORT _FP_free _ANSI_ARGS_((void *));
|
||||
char * TOOLEXPORT _FP_strdup _ANSI_ARGS_((char *));
|
||||
char * TOOLEXPORT _FP_strncpy _ANSI_ARGS_((char *, char *, int));
|
||||
void * TOOLEXPORT _FP_memdup _ANSI_ARGS_((void *, int));
|
||||
int TOOLEXPORT _FP_stricmp _ANSI_ARGS_((char *, char *));
|
||||
int TOOLEXPORT _FP_strnicmp _ANSI_ARGS_((char *, char *, int));
|
||||
char * TOOLEXPORT _FP_strrstr _ANSI_ARGS_((char *, char *));
|
||||
char * TOOLEXPORT _FP_stoupper _ANSI_ARGS_((char *));
|
||||
char * TOOLEXPORT _FP_stolower _ANSI_ARGS_((char *));
|
||||
int TOOLEXPORT _FP_strmatch _ANSI_ARGS_((char *, char *));
|
||||
char * TOOLEXPORT _FP_strstr _ANSI_ARGS_((char *, char *));
|
||||
char * TOOLEXPORT _FP_stristr _ANSI_ARGS_((char *, char *));
|
||||
char * TOOLEXPORT _FP_strirstr _ANSI_ARGS_((char *, char *));
|
||||
char * TOOLEXPORT _FP_strrchr _ANSI_ARGS_((char *, int));
|
||||
char * TOOLEXPORT _FP_fgets _ANSI_ARGS_((char *, int, FILE *));
|
||||
char * TOOLEXPORT _FP_strpbrk _ANSI_ARGS_((char *, char *));
|
||||
char * TOOLEXPORT _FP_strtok _ANSI_ARGS_((char *, char *));
|
||||
char * TOOLEXPORT _FP_cutdir _ANSI_ARGS_((char *));
|
||||
char * TOOLEXPORT _FP_strerror _ANSI_ARGS_((int));
|
||||
char * TOOLEXPORT _FP_tempnam _ANSI_ARGS_((char *, char *));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
1468
goldlib/uulib/uucheck.c
Normal file
1468
goldlib/uulib/uucheck.c
Normal file
File diff suppressed because it is too large
Load Diff
245
goldlib/uulib/uudeview.h
Normal file
245
goldlib/uulib/uudeview.h
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* This file is part of uudeview, the simple and friendly multi-part multi-
|
||||
* file uudecoder program (c) 1994 by Frank Pilhofer. The author may be
|
||||
* contacted by his email address, fp@informatik.uni-frankfurt.de
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __UUDEVIEW_H__
|
||||
#define __UUDEVIEW_H__
|
||||
|
||||
/*
|
||||
* This include file features all the definitions that should
|
||||
* be externally visible. This isn't much.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _ANSI_ARGS_
|
||||
#ifdef PROTOTYPES
|
||||
#define _ANSI_ARGS_(c) c
|
||||
#else
|
||||
#define _ANSI_ARGS_(c) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Message Types
|
||||
*/
|
||||
|
||||
#define UUMSG_MESSAGE (0) /* just a message, nothing important */
|
||||
#define UUMSG_NOTE (1) /* something that should be noticed */
|
||||
#define UUMSG_WARNING (2) /* important msg, processing continues */
|
||||
#define UUMSG_ERROR (3) /* processing has been terminated */
|
||||
#define UUMSG_FATAL (4) /* decoder cannot process further requests */
|
||||
#define UUMSG_PANIC (5) /* recovery impossible, app must terminate */
|
||||
|
||||
/*
|
||||
* Return Values
|
||||
*/
|
||||
|
||||
#define UURET_OK (0) /* everything went fine */
|
||||
#define UURET_IOERR (1) /* I/O Error - examine errno */
|
||||
#define UURET_NOMEM (2) /* not enough memory */
|
||||
#define UURET_ILLVAL (3) /* illegal value for operation */
|
||||
#define UURET_NODATA (4) /* decoder didn't find any data */
|
||||
#define UURET_NOEND (5) /* encoded data wasn't ended properly */
|
||||
#define UURET_UNSUP (6) /* unsupported function (encoding) */
|
||||
#define UURET_EXISTS (7) /* file exists (decoding) */
|
||||
#define UURET_CONT (8) /* continue -- special from ScanPart */
|
||||
#define UURET_CANCEL (9) /* operation canceled */
|
||||
|
||||
/*
|
||||
* File states, may be OR'ed
|
||||
*/
|
||||
|
||||
#define UUFILE_READ (0) /* Read in, but not further processed */
|
||||
#define UUFILE_MISPART (1) /* Missing Part(s) detected */
|
||||
#define UUFILE_NOBEGIN (2) /* No 'begin' found */
|
||||
#define UUFILE_NOEND (4) /* No 'end' found */
|
||||
#define UUFILE_NODATA (8) /* File does not contain valid uudata */
|
||||
#define UUFILE_OK (16) /* All Parts found, ready to decode */
|
||||
#define UUFILE_ERROR (32) /* Error while decoding */
|
||||
#define UUFILE_DECODED (64) /* Successfully decoded */
|
||||
#define UUFILE_TMPFILE (128) /* Temporary decoded file exists */
|
||||
|
||||
/*
|
||||
* Encoding Types
|
||||
*/
|
||||
|
||||
#define UU_ENCODED (1) /* UUencoded data */
|
||||
#define B64ENCODED (2) /* Mime-Base64 data */
|
||||
#define XX_ENCODED (3) /* XXencoded data */
|
||||
#define BH_ENCODED (4) /* Binhex encoded */
|
||||
#define PT_ENCODED (5) /* Plain-Text encoded (MIME) */
|
||||
#define QP_ENCODED (6) /* Quoted-Printable (MIME) */
|
||||
|
||||
/*
|
||||
* Option indices for GetOption / SetOption
|
||||
*/
|
||||
|
||||
#define UUOPT_VERSION (0) /* version number MAJOR.MINORplPATCH (ro) */
|
||||
#define UUOPT_FAST (1) /* assumes only one part per file */
|
||||
#define UUOPT_DUMBNESS (2) /* switch off the program's intelligence */
|
||||
#define UUOPT_BRACKPOL (3) /* give numbers in [] higher precendence */
|
||||
#define UUOPT_VERBOSE (4) /* generate informative messages */
|
||||
#define UUOPT_DESPERATE (5) /* try to decode incomplete files */
|
||||
#define UUOPT_IGNREPLY (6) /* ignore RE:plies (off by default) */
|
||||
#define UUOPT_OVERWRITE (7) /* whether it's OK to overwrite ex. files */
|
||||
#define UUOPT_SAVEPATH (8) /* prefix to save-files on disk */
|
||||
#define UUOPT_IGNMODE (9) /* ignore the original file mode */
|
||||
#define UUOPT_DEBUG (10) /* print messages with FILE/LINE info */
|
||||
#define UUOPT_ERRNO (14) /* get last error code for UURET_IOERR (ro) */
|
||||
#define UUOPT_PROGRESS (15) /* retrieve progress information */
|
||||
#define UUOPT_USETEXT (16) /* handle text messages */
|
||||
#define UUOPT_PREAMB (17) /* handle Mime preambles/epilogues */
|
||||
#define UUOPT_TINYB64 (18) /* detect short B64 outside of Mime */
|
||||
#define UUOPT_ENCEXT (19) /* extension for single-part encoded files */
|
||||
|
||||
/*
|
||||
* Code for the "action" in the progress structure
|
||||
*/
|
||||
|
||||
#define UUACT_IDLE (0) /* we don't do anything */
|
||||
#define UUACT_SCANNING (1) /* scanning an input file */
|
||||
#define UUACT_DECODING (2) /* decoding into a temp file */
|
||||
#define UUACT_COPYING (3) /* copying temp to target */
|
||||
#define UUACT_ENCODING (4) /* encoding a file */
|
||||
|
||||
/*
|
||||
* forward definition
|
||||
*/
|
||||
|
||||
struct _uufile;
|
||||
|
||||
/*
|
||||
* Structure for holding the list of files that have been found
|
||||
* uufile items are inserted into this list with UUInsertPartToList
|
||||
* After inserting a bunch of files, UUCheckGlobalList must be called
|
||||
* to update the states.
|
||||
*/
|
||||
|
||||
typedef struct _uulist {
|
||||
short state; /* Status as described by the macros above */
|
||||
short mode; /* file mode as found on begin line */
|
||||
|
||||
int begin; /* part number where begin was detected */
|
||||
int end; /* part number where end was detected */
|
||||
|
||||
short uudet; /* Encoding type (see macros above) */
|
||||
int flags; /* flags, especially for single-part files */
|
||||
|
||||
long size; /* approximate size of resulting file */
|
||||
char *filename; /* malloc'ed file name */
|
||||
char *subfname; /* malloc'ed ID from subject line */
|
||||
char *mimeid; /* malloc'ed MIME-ID, if available */
|
||||
char *mimetype; /* malloc'ed Content-Type, if available */
|
||||
|
||||
char *binfile; /* name of temp file, if already decoded */
|
||||
|
||||
struct _uufile *thisfile; /* linked list of this file's parts */
|
||||
|
||||
int *haveparts; /* the parts we have (max. 256 are listed) */
|
||||
int *misparts; /* list of missing parts (max. 256) */
|
||||
|
||||
struct _uulist *NEXT; /* next item of the list */
|
||||
struct _uulist *PREV; /* previous item of the list */
|
||||
} uulist;
|
||||
|
||||
/*
|
||||
* The "progress" structure which is passed to the Busy Callback
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int action; /* see UUACT_* definitions above */
|
||||
char curfile[256]; /* the file we are working on, incl. path */
|
||||
int partno; /* part we're currently decoding */
|
||||
int numparts; /* total number of parts of this file */
|
||||
long fsize; /* size of the current file */
|
||||
int percent; /* % of _current part_ */
|
||||
long foffset; /* file offset -- internal use only */
|
||||
long totsize; /* file total size -- internal use only */
|
||||
} uuprogress;
|
||||
|
||||
|
||||
/*
|
||||
* Externally visible Functions
|
||||
*/
|
||||
|
||||
#ifndef UUEXPORT
|
||||
#define UUEXPORT
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int UUEXPORT UUInitialize _ANSI_ARGS_((void));
|
||||
int UUEXPORT UUGetOption _ANSI_ARGS_((int, int *, char *, int));
|
||||
int UUEXPORT UUSetOption _ANSI_ARGS_((int, int, char *));
|
||||
char * UUEXPORT UUstrerror _ANSI_ARGS_((int));
|
||||
int UUEXPORT UUSetMsgCallback _ANSI_ARGS_((void *,
|
||||
void (*) (void *,
|
||||
char *,
|
||||
int)));
|
||||
int UUEXPORT UUSetBusyCallback _ANSI_ARGS_((void *,
|
||||
int (*) (void *,
|
||||
uuprogress *),
|
||||
long));
|
||||
int UUEXPORT UUSetFileCallback _ANSI_ARGS_((void *,
|
||||
int (*) (void *, char *,
|
||||
char *, int)));
|
||||
int UUEXPORT UUSetFNameFilter _ANSI_ARGS_((void *,
|
||||
char * (*) (void *,
|
||||
char *)));
|
||||
char * UUEXPORT UUFNameFilter _ANSI_ARGS_((char *));
|
||||
int UUEXPORT UULoadFile _ANSI_ARGS_((char *, char *, int));
|
||||
uulist *UUEXPORT UUGetFileListItem _ANSI_ARGS_((int));
|
||||
int UUEXPORT UURenameFile _ANSI_ARGS_((uulist *, char *));
|
||||
int UUEXPORT UUDecodeToTemp _ANSI_ARGS_((uulist *));
|
||||
int UUEXPORT UURemoveTemp _ANSI_ARGS_((uulist *));
|
||||
int UUEXPORT UUDecodeFile _ANSI_ARGS_((uulist *, char *));
|
||||
int UUEXPORT UUInfoFile _ANSI_ARGS_((uulist *, void *,
|
||||
int (*) (void *,
|
||||
char *)));
|
||||
int UUEXPORT UUSmerge _ANSI_ARGS_((int));
|
||||
int UUEXPORT UUCleanUp _ANSI_ARGS_((void));
|
||||
|
||||
int UUEXPORT UUQuickDecode _ANSI_ARGS_((FILE *, FILE *,
|
||||
char *, long));
|
||||
|
||||
int UUEXPORT UUEncodeMulti _ANSI_ARGS_((FILE *, FILE *,
|
||||
char *, int,
|
||||
char *, char *, int));
|
||||
int UUEXPORT UUEncodePartial _ANSI_ARGS_((FILE *, FILE *,
|
||||
char *, int,
|
||||
char *, char *,
|
||||
int, int, long));
|
||||
int UUEXPORT UUEncodeToStream _ANSI_ARGS_((FILE *, FILE *,
|
||||
char *, int,
|
||||
char *, int));
|
||||
int UUEXPORT UUEncodeToFile _ANSI_ARGS_((FILE *, char *, int,
|
||||
char *, char *, long));
|
||||
int UUEXPORT UUE_PrepSingle _ANSI_ARGS_((FILE *, FILE *,
|
||||
char *, int,
|
||||
char *, int,
|
||||
char *, char *,
|
||||
char *, int));
|
||||
int UUEXPORT UUE_PrepPartial _ANSI_ARGS_((FILE *, FILE *,
|
||||
char *, int,
|
||||
char *, int,
|
||||
int, long, long, char *,
|
||||
char *, char *, int));
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
1230
goldlib/uulib/uuencode.c
Normal file
1230
goldlib/uulib/uuencode.c
Normal file
File diff suppressed because it is too large
Load Diff
336
goldlib/uulib/uuint.h
Normal file
336
goldlib/uulib/uuint.h
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* This file is part of uudeview, the simple and friendly multi-part multi-
|
||||
* file uudecoder program (c) 1994 by Frank Pilhofer. The author may be
|
||||
* contacted by his email address, fp@informatik.uni-frankfurt.de
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __UUINT_H__
|
||||
#define __UUINT_H__
|
||||
|
||||
/*
|
||||
* This file describes the internal structures, variables and definitions
|
||||
* of UUDeview. It should not be included from other packages. Subject to
|
||||
* change without notice. Do not depend on anything here.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _ANSI_ARGS_
|
||||
#ifdef PROTOTYPES
|
||||
#define _ANSI_ARGS_(c) c
|
||||
#else
|
||||
#define _ANSI_ARGS_(c) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Busy Polls will be made after processing ... lines
|
||||
*/
|
||||
|
||||
#define BUSY_LINE_TICKS 50
|
||||
|
||||
/*
|
||||
* States of MIME scanner
|
||||
*/
|
||||
|
||||
#define MS_HEADERS 1 /* still inside of headers */
|
||||
#define MS_BODY 2 /* body of `simple' messages */
|
||||
#define MS_PREAMBLE 3 /* preamble of Multipart/Mixed */
|
||||
#define MS_SUBPART 4 /* within one of the Multiparts */
|
||||
#define MS_EPILOGUE 5 /* epilogue of Multipart/Mixed */
|
||||
|
||||
/*
|
||||
* Number of subsequent encoded lines we require to believe this
|
||||
* is valid data.
|
||||
*/
|
||||
|
||||
#define ELC_COUNT 4
|
||||
|
||||
/*
|
||||
* Flags a part may have. FL_PROPER means that we are sure about the file's
|
||||
* encoding, beginning and end, and don't have to use special care when de-
|
||||
* coding.
|
||||
*/
|
||||
|
||||
#define FL_NONE 0 /* no flag, just plain normal */
|
||||
#define FL_SINGLE 1 /* standalone MSG, do not mix */
|
||||
#define FL_PARTIAL 2 /* from Message/Partial */
|
||||
#define FL_PROPER 4 /* proper MIME part */
|
||||
#define FL_TOEND 8 /* part continues to EOF */
|
||||
|
||||
/*
|
||||
* Auxiliary macro: compute the percentage of a against b.
|
||||
* The obvious answer is (100*a)/b, but this overflows for large a.
|
||||
* a/(b/100) is better; we use a/((b/100)+1) so that we don't divide
|
||||
* by zero for b<100 and the result doesn't become larger than 100%
|
||||
*/
|
||||
|
||||
#define UUPERCENT(a,b) ((int) ((unsigned long)(a) / \
|
||||
(((unsigned long)(b)/100)+1)))
|
||||
|
||||
/*
|
||||
* Make the Busy Callback easier. The macro returns true if the BusyCallback
|
||||
* wants us to terminate.
|
||||
*/
|
||||
|
||||
extern unsigned long uuyctr;
|
||||
#define UUBUSYPOLL(a,b) (((++uuyctr%BUSY_LINE_TICKS)==0) ? (progress.percent=UUPERCENT((a),(b)),UUBusyPoll()):0)
|
||||
|
||||
/*
|
||||
* How many lines of headers do we need to believe another mail
|
||||
* header is approaching? Use more restrictive values for MIME
|
||||
* mails, less restrictive for Freestyle
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int restart; /* restarting after a MIME body (not subpart) */
|
||||
int afterdata; /* after we had useful data in freestyle mode */
|
||||
int afternl; /* after an empty line in freestyle mode */
|
||||
} headercount;
|
||||
|
||||
extern headercount hlcount;
|
||||
|
||||
/*
|
||||
* Information from the headers of a message. Each instance must
|
||||
* have its very own copy of the strings. If `mimevers' is NULL,
|
||||
* then this message does not comply to the MIME standard.
|
||||
*/
|
||||
|
||||
typedef struct _headers {
|
||||
char *from; /* From: */
|
||||
char *subject; /* Subject: */
|
||||
char *rcpt; /* To: */
|
||||
char *date; /* Date: */
|
||||
char *mimevers; /* MIME-Version: */
|
||||
char *ctype; /* Content-Type: */
|
||||
char *ctenc; /* Content-Transfer-Encoding: */
|
||||
char *fname; /* Potential Filename from Content-Type Parameter */
|
||||
char *boundary; /* MIME-Boundary from Content-Type Parameter */
|
||||
char *mimeid; /* MIME-Id for Message/Partial */
|
||||
int partno; /* part number for Message/Partial */
|
||||
int numparts; /* number of parts for Message/Partial */
|
||||
} headers;
|
||||
|
||||
/*
|
||||
* Scanner state
|
||||
*/
|
||||
|
||||
typedef struct _scanstate {
|
||||
int isfolder; /* if we think this is a valid email folder */
|
||||
int ismime; /* if we are within a valid MIME message */
|
||||
int mimestate; /* state of MIME scanner */
|
||||
int mimeenc; /* encoding of this MIME file */
|
||||
char *source; /* source filename */
|
||||
headers envelope; /* mail envelope headers */
|
||||
} scanstate;
|
||||
|
||||
/*
|
||||
* Structure that holds the information for a single file / part of
|
||||
* a file. If a subject line is encountered, it is copied to subject;
|
||||
* if a begin is found, the mode and name of the file is extracted.
|
||||
* flags are set if 'begin' or 'end' is detected and 'uudet' if valid
|
||||
* uuencoded data is found. If the file contains a 'From:' line with
|
||||
* a '@' in it (indicating an origin email address), it is preserved
|
||||
* in 'origin'.
|
||||
**/
|
||||
|
||||
typedef struct _fileread {
|
||||
char *subject; /* Whole subject line */
|
||||
char *filename; /* Only filled in if begin detected */
|
||||
char *origin; /* Whole 'From:' line */
|
||||
char *mimeid; /* the ID for Mime-encoded files */
|
||||
char *mimetype; /* Content-Type */
|
||||
short mode; /* Mode of File (from 'begin') */
|
||||
int begin; /* begin detected */
|
||||
int end; /* end detected */
|
||||
int flags; /* associated flags */
|
||||
|
||||
short uudet; /* valid encoded data. value indicates encoding */
|
||||
short partno; /* Mime-files have a part number within */
|
||||
short maxpno; /* ... plus the total number of parts */
|
||||
|
||||
char *sfname; /* Associated source file */
|
||||
long startpos; /* ftell() position where data starts */
|
||||
long length; /* length of data */
|
||||
} fileread;
|
||||
|
||||
/*
|
||||
* Structure for holding one part of a file, with some more information
|
||||
* about it. The UUPreProcessPart() function takes one a fileread structure
|
||||
* and produces this uufile structure.
|
||||
* Linked List, ordered by partno.
|
||||
**/
|
||||
|
||||
typedef struct _uufile {
|
||||
char *filename;
|
||||
char *subfname;
|
||||
char *mimeid;
|
||||
char *mimetype;
|
||||
short partno;
|
||||
fileread *data;
|
||||
struct _uufile *NEXT;
|
||||
} uufile;
|
||||
|
||||
extern void *uu_MsgCBArg;
|
||||
extern void *uu_BusyCBArg;
|
||||
extern void *uu_FileCBArg;
|
||||
extern void *uu_FFCBArg;
|
||||
|
||||
/*
|
||||
* variables
|
||||
*/
|
||||
|
||||
extern int uu_fast_scanning;
|
||||
extern int uu_bracket_policy;
|
||||
extern int uu_verbose;
|
||||
extern int uu_desperate;
|
||||
extern int uu_ignreply;
|
||||
extern int uu_debug;
|
||||
extern int uu_errno;
|
||||
extern int uu_dumbness;
|
||||
extern int uu_overwrite;
|
||||
extern int uu_ignmode;
|
||||
extern int uu_headercount;
|
||||
extern int uu_usepreamble;
|
||||
extern int uu_handletext;
|
||||
extern int uu_tinyb64;
|
||||
|
||||
extern char *uusavepath;
|
||||
extern char *uuencodeext;
|
||||
|
||||
/*
|
||||
* Encoding/Decoding tables
|
||||
*/
|
||||
|
||||
extern unsigned char UUEncodeTable[];
|
||||
extern unsigned char XXEncodeTable[];
|
||||
extern unsigned char B64EncodeTable[];
|
||||
extern unsigned char BHEncodeTable[];
|
||||
|
||||
/*
|
||||
* String tables from uustring.c
|
||||
*/
|
||||
|
||||
extern char *msgnames[];
|
||||
extern char *codenames[];
|
||||
extern char *uuretcodes[];
|
||||
|
||||
extern uulist *UUGlobalFileList;
|
||||
|
||||
/*
|
||||
* State of MIME variables and current progress
|
||||
*/
|
||||
|
||||
extern int nofnum, mssdepth;
|
||||
extern int mimseqno, lastvalid;
|
||||
extern int lastenc;
|
||||
extern scanstate multistack[];
|
||||
extern headers localenv;
|
||||
extern scanstate sstate;
|
||||
extern uuprogress progress;
|
||||
|
||||
/*
|
||||
* mallocable areas
|
||||
*/
|
||||
|
||||
extern char *uugen_fnbuffer, *uugen_inbuffer;
|
||||
extern char *uucheck_lastname, *uucheck_tempname;
|
||||
extern char *uuestr_itemp, *uuestr_otemp;
|
||||
extern char *uulib_msgstring, *uuncdl_fulline;
|
||||
extern char *uuncdp_oline, *uuscan_shlline;
|
||||
extern char *uuscan_pvvalue, *uuscan_phtext;
|
||||
extern char *uuscan_sdline, *uuscan_sdbhds1;
|
||||
extern char *uuscan_sdbhds2, *uuscan_spline;
|
||||
extern char *uuutil_bhwtmp;
|
||||
extern char *uunconc_UUxlat, *uunconc_UUxlen;
|
||||
extern char *uunconc_B64xlat, *uunconc_XXxlat;
|
||||
extern char *uunconc_BHxlat, *uunconc_save;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void (*uu_MsgCallback) _ANSI_ARGS_((void *, char *, int));
|
||||
extern int (*uu_BusyCallback) _ANSI_ARGS_((void *, uuprogress *));
|
||||
extern int (*uu_FileCallback) _ANSI_ARGS_((void *, char *, char *, int));
|
||||
extern char * (*uu_FNameFilter) _ANSI_ARGS_((void *, char *));
|
||||
|
||||
/*
|
||||
* Functions from uulib.c that aren't defined in <uudeview.h>
|
||||
* Be careful about the definition with variable arguments.
|
||||
*/
|
||||
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STDARG_H)
|
||||
int UUMessage _ANSI_ARGS_((char *, int,
|
||||
int, char *, ...));
|
||||
#else
|
||||
int UUMessage ();
|
||||
#endif
|
||||
int UUBusyPoll _ANSI_ARGS_((void));
|
||||
|
||||
/*
|
||||
* Functions from uucheck.c
|
||||
*/
|
||||
|
||||
uufile * UUPreProcessPart _ANSI_ARGS_((fileread *, int *));
|
||||
int UUInsertPartToList _ANSI_ARGS_((uufile *));
|
||||
uulist * UUCheckGlobalList _ANSI_ARGS_((void));
|
||||
|
||||
/*
|
||||
* Functions from uuutil.c
|
||||
*/
|
||||
|
||||
void UUkillfread _ANSI_ARGS_((fileread *));
|
||||
void UUkillfile _ANSI_ARGS_((uufile *));
|
||||
void UUkilllist _ANSI_ARGS_((uulist *));
|
||||
void UUkillheaders _ANSI_ARGS_((headers *));
|
||||
|
||||
fileread * ScanPart _ANSI_ARGS_((FILE *, char *, int *));
|
||||
|
||||
int UUbhdecomp _ANSI_ARGS_((char *, char *,
|
||||
char *, int *,
|
||||
size_t, size_t,
|
||||
size_t *));
|
||||
size_t UUbhwrite _ANSI_ARGS_((char *, size_t, size_t,
|
||||
FILE *));
|
||||
|
||||
/*
|
||||
* Functions from uunconc.c
|
||||
*/
|
||||
|
||||
int UURepairData _ANSI_ARGS_((FILE *, char *,
|
||||
int, int *));
|
||||
|
||||
void UUInitConc _ANSI_ARGS_((void));
|
||||
int UUValidData _ANSI_ARGS_((char *, int, int *));
|
||||
size_t UUDecodeLine _ANSI_ARGS_((char *, char *, int));
|
||||
int UUDecodePart _ANSI_ARGS_((FILE *, FILE *, int *,
|
||||
long, int, int, char *));
|
||||
int UUDecode _ANSI_ARGS_((uulist *));
|
||||
|
||||
/*
|
||||
* Message retrieval from uustring.c
|
||||
*/
|
||||
|
||||
char * uustring _ANSI_ARGS_((int));
|
||||
|
||||
/*
|
||||
* From uuscan.c
|
||||
*/
|
||||
|
||||
int UUScanHeader _ANSI_ARGS_((FILE *, headers *));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
8
goldlib/uulib/uulib.all
Normal file
8
goldlib/uulib/uulib.all
Normal file
@@ -0,0 +1,8 @@
|
||||
fptools c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg
|
||||
uucheck c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg
|
||||
uuencode c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg
|
||||
uulib c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg
|
||||
uunconc c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg
|
||||
uuscan c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg
|
||||
uustring c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg
|
||||
uuutil c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg
|
1200
goldlib/uulib/uulib.c
Normal file
1200
goldlib/uulib/uulib.c
Normal file
File diff suppressed because it is too large
Load Diff
1500
goldlib/uulib/uunconc.c
Normal file
1500
goldlib/uulib/uunconc.c
Normal file
File diff suppressed because it is too large
Load Diff
2751
goldlib/uulib/uuscan.c
Normal file
2751
goldlib/uulib/uuscan.c
Normal file
File diff suppressed because it is too large
Load Diff
165
goldlib/uulib/uustring.c
Normal file
165
goldlib/uulib/uustring.c
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* This file is part of uudeview, the simple and friendly multi-part multi-
|
||||
* file uudecoder program (c) 1994 by Frank Pilhofer. The author may be
|
||||
* contacted by his email address, fp@informatik.uni-frankfurt.de
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Strings used in the library for easier translation etc.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef SYSTEM_WINDLL
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifdef SYSTEM_OS2
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#include <uudeview.h>
|
||||
#include <uuint.h>
|
||||
#include <uustring.h>
|
||||
|
||||
char * uustring_id = "$Id$";
|
||||
|
||||
typedef struct {
|
||||
int code;
|
||||
char * msg;
|
||||
} stringmap;
|
||||
|
||||
/*
|
||||
* Map of messages. This table is not exported, the messages must
|
||||
* be retrieved via the below uustring() function.
|
||||
*/
|
||||
|
||||
static stringmap messages[] = {
|
||||
/* I/O related errors/messages. Last parameter is strerror() */
|
||||
{ S_NOT_OPEN_SOURCE, "Could not open source file %s: %s" },
|
||||
{ S_NOT_OPEN_TARGET, "Could not open target file %s for writing: %s" },
|
||||
{ S_NOT_OPEN_FILE, "Could not open file %s: %s" },
|
||||
{ S_NOT_STAT_FILE, "Could not stat file %s: %s" },
|
||||
{ S_SOURCE_READ_ERR, "Read error on source file: %s" },
|
||||
{ S_READ_ERROR, "Error reading from %s: %s" },
|
||||
{ S_IO_ERR_TARGET, "I/O error on target file %s: %s" },
|
||||
{ S_WR_ERR_TARGET, "Write error on target file %s: %s" },
|
||||
{ S_WR_ERR_TEMP, "Write error on temp file: %s" },
|
||||
{ S_TMP_NOT_REMOVED, "Could not remove temp file %s: %s (ignored)" },
|
||||
|
||||
/* some other problems */
|
||||
{ S_OUT_OF_MEMORY, "Out of memory allocating %d bytes" },
|
||||
{ S_TARGET_EXISTS, "Target file %s exists and overwriting is not allowed" },
|
||||
{ S_NOT_RENAME, "Could not change name of %s to %s" },
|
||||
{ S_ERR_ENCODING, "Error while encoding %s: %s" },
|
||||
{ S_STAT_ONE_PART, "Could not stat input, encoding to one part only" },
|
||||
{ S_PARM_CHECK, "Parameter check failed in %s" },
|
||||
{ S_SHORT_BINHEX, "BinHex encoded file %s ended prematurely (%ld bytes left)" },
|
||||
{ S_DECODE_CANCEL, "Decode operation canceled" },
|
||||
{ S_ENCODE_CANCEL, "Encode operation canceled" },
|
||||
{ S_SCAN_CANCEL, "Scanning canceled" },
|
||||
|
||||
/* informational messages */
|
||||
{ S_LOADED_PART, "Loaded from %s: '%s' (%s): %s part %d %s %s %s" },
|
||||
{ S_NO_DATA_FOUND, "No encoded data found in %s" },
|
||||
{ S_NO_BIN_FILE, "Oops, could not find decoded file?" },
|
||||
{ S_STRIPPED_SETUID, "Stripped setuid/setgid bits from target file %s mode %d" },
|
||||
{ S_DATA_SUSPICIOUS, "Data looks suspicious. Decoded file might be corrupt." },
|
||||
{ S_NO_TEMP_NAME, "Could not get name for temporary file" },
|
||||
{ S_BINHEX_SIZES, "BinHex file: data/resource fork sizes %ld/%ld" },
|
||||
{ S_BINHEX_BOTH, "BinHex file: both forks non-empty, decoding data fork" },
|
||||
{ S_SMERGE_MERGED, "Parts of '%s' merged with parts of '%s' (%d)" },
|
||||
|
||||
/* MIME-related messages */
|
||||
{ S_MIME_NO_BOUNDARY, "Multipart message without boundary ignored" },
|
||||
{ S_MIME_B_NOT_FOUND, "Boundary expected on Multipart message but found EOF" },
|
||||
{ S_MIME_MULTI_DEPTH, "Multipart message nested too deep" },
|
||||
{ S_MIME_PART_MULTI, "Handling partial multipart message as plain text" },
|
||||
|
||||
{ 0, "" }
|
||||
};
|
||||
|
||||
/*
|
||||
* description of the return values UURET_*
|
||||
*/
|
||||
|
||||
char *uuretcodes[] = {
|
||||
"OK",
|
||||
"File I/O Error",
|
||||
"Not Enough Memory",
|
||||
"Illegal Value",
|
||||
"No Data found",
|
||||
"Unexpected End of File",
|
||||
"Unsupported function",
|
||||
"File exists",
|
||||
"Continue -- no error", /* only to be seen internally */
|
||||
"Operation Canceled"
|
||||
};
|
||||
|
||||
/*
|
||||
* Names of encoding types
|
||||
*/
|
||||
|
||||
char *codenames[7] = {
|
||||
"", "UUdata", "Base64", "XXdata", "Binhex", "Text", "Text"
|
||||
};
|
||||
|
||||
/*
|
||||
* Message types
|
||||
*/
|
||||
|
||||
char *msgnames[6] = {
|
||||
"", "Note: ", "Warning: ", "ERROR: ", "FATAL ERROR: ", "PANIC: "
|
||||
};
|
||||
|
||||
/*
|
||||
* Retrieve one of the messages. We never return NULL
|
||||
* but instead escape to "oops".
|
||||
*/
|
||||
|
||||
char *
|
||||
uustring (int codeno)
|
||||
{
|
||||
static char * faileddef = "oops";
|
||||
stringmap *ptr = messages;
|
||||
|
||||
while (ptr->code) {
|
||||
if (ptr->code == codeno)
|
||||
return ptr->msg;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
UUMessage (uustring_id, __LINE__, UUMSG_ERROR,
|
||||
"Could not retrieve string no %d",
|
||||
codeno);
|
||||
|
||||
return faileddef;
|
||||
}
|
34
goldlib/uulib/uustring.h
Normal file
34
goldlib/uulib/uustring.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* extracted from Id: uustring.c,v 1.1 2000/01/27 18:44:38 asa Exp */
|
||||
#define S_NOT_OPEN_SOURCE 1
|
||||
#define S_NOT_OPEN_TARGET 2
|
||||
#define S_NOT_OPEN_FILE 3
|
||||
#define S_NOT_STAT_FILE 4
|
||||
#define S_SOURCE_READ_ERR 5
|
||||
#define S_READ_ERROR 6
|
||||
#define S_IO_ERR_TARGET 7
|
||||
#define S_WR_ERR_TARGET 8
|
||||
#define S_WR_ERR_TEMP 9
|
||||
#define S_TMP_NOT_REMOVED 10
|
||||
#define S_OUT_OF_MEMORY 11
|
||||
#define S_TARGET_EXISTS 12
|
||||
#define S_NOT_RENAME 13
|
||||
#define S_ERR_ENCODING 14
|
||||
#define S_STAT_ONE_PART 15
|
||||
#define S_PARM_CHECK 16
|
||||
#define S_SHORT_BINHEX 17
|
||||
#define S_DECODE_CANCEL 18
|
||||
#define S_ENCODE_CANCEL 19
|
||||
#define S_SCAN_CANCEL 20
|
||||
#define S_LOADED_PART 21
|
||||
#define S_NO_DATA_FOUND 22
|
||||
#define S_NO_BIN_FILE 23
|
||||
#define S_STRIPPED_SETUID 24
|
||||
#define S_DATA_SUSPICIOUS 25
|
||||
#define S_NO_TEMP_NAME 26
|
||||
#define S_BINHEX_SIZES 27
|
||||
#define S_BINHEX_BOTH 28
|
||||
#define S_SMERGE_MERGED 29
|
||||
#define S_MIME_NO_BOUNDARY 30
|
||||
#define S_MIME_B_NOT_FOUND 31
|
||||
#define S_MIME_MULTI_DEPTH 32
|
||||
#define S_MIME_PART_MULTI 33
|
485
goldlib/uulib/uuutil.c
Normal file
485
goldlib/uulib/uuutil.c
Normal file
@@ -0,0 +1,485 @@
|
||||
/*
|
||||
* This file is part of uudeview, the simple and friendly multi-part multi-
|
||||
* file uudecoder program (c) 1994 by Frank Pilhofer. The author may be
|
||||
* contacted by his email address, fp@informatik.uni-frankfurt.de
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* certain utilitarian functions that didn't fit anywhere else
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef SYSTEM_WINDLL
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifdef SYSTEM_OS2
|
||||
#include <os2.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <uudeview.h>
|
||||
#include <uuint.h>
|
||||
#include <fptools.h>
|
||||
#include <uustring.h>
|
||||
|
||||
char * uuutil_id = "$Id$";
|
||||
|
||||
/*
|
||||
* Parts with different known extensions will not be merged by SPMS.
|
||||
* if first character is '@', it is synonymous to the previous one.
|
||||
*/
|
||||
|
||||
static char *knownexts[] = {
|
||||
"mpg", "@mpeg", "avi", "mov",
|
||||
"gif", "jpg", "@jpeg", "tif",
|
||||
"voc", "wav", "@wave", "au",
|
||||
"zip", "arj", "tar",
|
||||
NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* forward declarations of local functions
|
||||
*/
|
||||
|
||||
static int UUSMPKnownExt _ANSI_ARGS_((char *filename));
|
||||
static uulist * UU_smparts_r _ANSI_ARGS_((uulist *, int));
|
||||
|
||||
/*
|
||||
* mallocable areas
|
||||
*/
|
||||
|
||||
char *uuutil_bhwtmp;
|
||||
|
||||
/*
|
||||
* free some memory
|
||||
**/
|
||||
|
||||
void
|
||||
UUkillfread (fileread *data)
|
||||
{
|
||||
if (data != NULL) {
|
||||
_FP_free (data->subject);
|
||||
_FP_free (data->filename);
|
||||
_FP_free (data->origin);
|
||||
_FP_free (data->mimeid);
|
||||
_FP_free (data->mimetype);
|
||||
_FP_free (data->sfname);
|
||||
_FP_free (data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UUkillfile (uufile *data)
|
||||
{
|
||||
uufile *next;
|
||||
|
||||
while (data) {
|
||||
_FP_free (data->filename);
|
||||
_FP_free (data->subfname);
|
||||
_FP_free (data->mimeid);
|
||||
_FP_free (data->mimetype);
|
||||
UUkillfread (data->data);
|
||||
|
||||
next = data->NEXT;
|
||||
_FP_free (data);
|
||||
data = next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UUkilllist (uulist *data)
|
||||
{
|
||||
uulist *next;
|
||||
|
||||
while (data) {
|
||||
if (data->binfile != NULL)
|
||||
if (unlink (data->binfile))
|
||||
UUMessage (uuutil_id, __LINE__, UUMSG_WARNING,
|
||||
uustring (S_TMP_NOT_REMOVED),
|
||||
data->binfile, strerror (errno));
|
||||
|
||||
_FP_free (data->filename);
|
||||
_FP_free (data->subfname);
|
||||
_FP_free (data->mimeid);
|
||||
_FP_free (data->mimetype);
|
||||
_FP_free (data->binfile);
|
||||
UUkillfile (data->thisfile);
|
||||
_FP_free (data->haveparts);
|
||||
_FP_free (data->misparts);
|
||||
|
||||
next = data->NEXT;
|
||||
_FP_free (data);
|
||||
data = next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* this kill function is an exception in that it doesn't kill data itself
|
||||
*/
|
||||
|
||||
void
|
||||
UUkillheaders (headers *data)
|
||||
{
|
||||
if (data != NULL) {
|
||||
_FP_free (data->from);
|
||||
_FP_free (data->subject);
|
||||
_FP_free (data->rcpt);
|
||||
_FP_free (data->date);
|
||||
_FP_free (data->mimevers);
|
||||
_FP_free (data->ctype);
|
||||
_FP_free (data->ctenc);
|
||||
_FP_free (data->fname);
|
||||
_FP_free (data->boundary);
|
||||
_FP_free (data->mimeid);
|
||||
memset (data, 0, sizeof (headers));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* checks for various well-known extensions. if two parts have different
|
||||
* known extensions, we won't merge them.
|
||||
*/
|
||||
|
||||
static int
|
||||
UUSMPKnownExt (char *filename)
|
||||
{
|
||||
char **eiter = knownexts, *ptr=_FP_strrchr(filename, '.');
|
||||
int count=0, where=0;
|
||||
|
||||
if (ptr == NULL)
|
||||
return -1;
|
||||
ptr++;
|
||||
|
||||
while (*eiter) {
|
||||
if (_FP_stricmp (ptr, (**eiter=='@')?*eiter+1:*eiter) == 0)
|
||||
return where;
|
||||
else
|
||||
eiter++;
|
||||
|
||||
if (*eiter == NULL)
|
||||
break;
|
||||
|
||||
if (**eiter=='@')
|
||||
count++;
|
||||
else
|
||||
where = ++count;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* de-compress a binhex RLE stream
|
||||
* the data read from in is uncompressed, and at most maxcount bytes
|
||||
* (or octets, as they say) are copied to out. Because an uncompression
|
||||
* might not be completed because of this maximum number of bytes. There-
|
||||
* for, the leftover character and repetition count is saved. If a marker
|
||||
* has been read but not the repetition count, *rpc is set to -256.
|
||||
*
|
||||
* the function returns the number of bytes eaten from in. If opc is not
|
||||
* NULL, the total number of characters stored in out is saved there
|
||||
*
|
||||
* with repetition counts, remember that we've already transferred *one*
|
||||
* occurence
|
||||
*/
|
||||
|
||||
int
|
||||
UUbhdecomp (char *in, char *out, char *last, int *rpc,
|
||||
size_t inc, size_t max, size_t *opc)
|
||||
{
|
||||
size_t count, used=0, dummy;
|
||||
char marker = '\220' /* '\x90' */;
|
||||
|
||||
if (opc == NULL)
|
||||
opc = &dummy;
|
||||
else
|
||||
*opc = 0;
|
||||
|
||||
if (*rpc == -256) {
|
||||
if (inc == 0)
|
||||
return 0;
|
||||
*rpc = (int) (unsigned char) *in++; used++;
|
||||
|
||||
if (*rpc == 0) {
|
||||
*last = *out++ = marker;
|
||||
max--; *opc+=1;
|
||||
}
|
||||
else
|
||||
*rpc-=1;
|
||||
}
|
||||
|
||||
if (*rpc) {
|
||||
count = (max > (size_t) *rpc) ? (size_t) *rpc : max;
|
||||
|
||||
memset (out, *last, count);
|
||||
|
||||
out += count;
|
||||
*opc += count;
|
||||
max -= count;
|
||||
*rpc -= count;
|
||||
}
|
||||
|
||||
while (used < inc && max) {
|
||||
if (*in == marker) {
|
||||
used++; in++;
|
||||
if (used == inc) {
|
||||
*rpc = -256;
|
||||
return used;
|
||||
}
|
||||
*rpc = (int) (unsigned char) *in++; used++;
|
||||
|
||||
if (*rpc == 0) {
|
||||
*last = *out++ = marker;
|
||||
max--; *opc+=1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
*rpc -= 1;
|
||||
|
||||
count = (max > (size_t) *rpc) ? (size_t) *rpc : max;
|
||||
memset (out, *last, count);
|
||||
|
||||
out += count;
|
||||
*opc += count;
|
||||
max -= count;
|
||||
*rpc -= count;
|
||||
}
|
||||
else {
|
||||
*last = *out++ = *in++;
|
||||
used++; *opc+=1; max--;
|
||||
}
|
||||
}
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
/*
|
||||
* write to binhex file
|
||||
*/
|
||||
|
||||
size_t
|
||||
UUbhwrite (char *ptr, size_t sel, size_t nel, FILE *file)
|
||||
{
|
||||
char *tmpstring=uuutil_bhwtmp;
|
||||
static int rpc = 0;
|
||||
static char lc;
|
||||
int count, tc=0;
|
||||
size_t opc;
|
||||
|
||||
if (ptr == NULL) { /* init */
|
||||
rpc = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (nel || (rpc != 0 && rpc != -256)) {
|
||||
count = UUbhdecomp (ptr, tmpstring, &lc, &rpc,
|
||||
nel, 256, &opc);
|
||||
if (fwrite (tmpstring, 1, opc, file) != opc)
|
||||
return 0;
|
||||
if (ferror (file))
|
||||
return 0;
|
||||
nel -= count;
|
||||
ptr += count;
|
||||
tc += count;
|
||||
}
|
||||
|
||||
return tc;
|
||||
}
|
||||
|
||||
static uulist *
|
||||
UU_smparts_r (uulist *addit, int pass)
|
||||
{
|
||||
uulist *iter = UUGlobalFileList;
|
||||
uufile *fiter, *dest, *temp;
|
||||
int count, flag, a, b;
|
||||
|
||||
while (iter) {
|
||||
if ((iter->state & UUFILE_OK) || iter->uudet == 0) {
|
||||
iter = iter->NEXT;
|
||||
continue;
|
||||
}
|
||||
if (iter == addit) {
|
||||
iter = iter->NEXT;
|
||||
continue;
|
||||
}
|
||||
if ((iter->begin && addit->begin) || (iter->end && addit->end) ||
|
||||
(iter->uudet != addit->uudet)) {
|
||||
iter = iter->NEXT;
|
||||
continue;
|
||||
}
|
||||
if ((a = UUSMPKnownExt (addit->subfname)) != -1 &&
|
||||
(b = UUSMPKnownExt (iter->subfname)) != -1)
|
||||
if (a != b) {
|
||||
iter = iter->NEXT;
|
||||
continue;
|
||||
}
|
||||
|
||||
flag = count = 0;
|
||||
fiter = iter->thisfile;
|
||||
temp = addit->thisfile;
|
||||
dest = NULL;
|
||||
|
||||
while (temp) {
|
||||
if (!(temp->data->uudet)) {
|
||||
temp = temp->NEXT;
|
||||
continue;
|
||||
}
|
||||
|
||||
while (fiter && fiter->partno < temp->partno) {
|
||||
dest = fiter;
|
||||
fiter = fiter->NEXT;
|
||||
}
|
||||
if (fiter && fiter->partno == temp->partno) {
|
||||
flag = 0;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
flag = 1;
|
||||
count += ((dest) ? temp->partno - dest->partno - 1 : 0) +
|
||||
((fiter) ? fiter->partno - temp->partno - 1 : 0);
|
||||
}
|
||||
|
||||
temp = temp->NEXT;
|
||||
}
|
||||
if (flag == 0 ||
|
||||
(pass == 0 && count > 0) ||
|
||||
(pass == 1 && count > 5)) {
|
||||
iter = iter->NEXT;
|
||||
continue;
|
||||
}
|
||||
|
||||
dest = iter->thisfile;
|
||||
fiter = addit->thisfile;
|
||||
|
||||
if (iter->filename == NULL && addit->filename != NULL)
|
||||
iter->filename = _FP_strdup (addit->filename);
|
||||
|
||||
if (addit->begin) iter->begin = 1;
|
||||
if (addit->end) iter->end = 1;
|
||||
|
||||
if (addit->mode != 0 && iter->mode == 0)
|
||||
iter->mode = addit->mode;
|
||||
|
||||
while (fiter) {
|
||||
flag = 0;
|
||||
|
||||
if (fiter->partno == iter->thisfile->partno ||
|
||||
(dest->NEXT != NULL && fiter->partno == dest->NEXT->partno)) {
|
||||
temp = fiter->NEXT;
|
||||
fiter->NEXT = NULL;
|
||||
|
||||
UUkillfile (fiter);
|
||||
|
||||
addit->thisfile= temp;
|
||||
fiter = temp;
|
||||
continue;
|
||||
}
|
||||
if (fiter->partno < iter->thisfile->partno) {
|
||||
temp = fiter->NEXT;
|
||||
fiter->NEXT = iter->thisfile;
|
||||
iter->thisfile = fiter;
|
||||
dest = fiter;
|
||||
addit->thisfile= temp;
|
||||
fiter = temp;
|
||||
}
|
||||
else if (dest->NEXT == NULL || fiter->partno < dest->NEXT->partno) {
|
||||
temp = fiter->NEXT;
|
||||
fiter->NEXT = dest->NEXT;
|
||||
dest->NEXT = fiter;
|
||||
addit->thisfile= temp;
|
||||
fiter = temp;
|
||||
}
|
||||
else {
|
||||
dest = dest->NEXT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return iter;
|
||||
}
|
||||
|
||||
int UUEXPORT
|
||||
UUSmerge (int pass)
|
||||
{
|
||||
uulist *iter = UUGlobalFileList, *last=NULL, *res, *temp;
|
||||
int flag = 0;
|
||||
|
||||
while (iter) {
|
||||
if ((iter->state & UUFILE_OK) || iter->uudet == 0) {
|
||||
last = iter;
|
||||
iter = iter->NEXT;
|
||||
continue;
|
||||
}
|
||||
if ((res = UU_smparts_r (iter, pass)) != NULL) {
|
||||
UUMessage (uuutil_id, __LINE__, UUMSG_MESSAGE,
|
||||
uustring (S_SMERGE_MERGED),
|
||||
(iter->subfname) ? iter->subfname : "",
|
||||
(res->subfname) ? res->subfname : "", pass);
|
||||
|
||||
temp = iter->NEXT;
|
||||
iter->NEXT = NULL;
|
||||
UUkilllist (iter);
|
||||
|
||||
flag++;
|
||||
|
||||
if (last == NULL) {
|
||||
UUGlobalFileList = temp;
|
||||
iter = temp;
|
||||
}
|
||||
else {
|
||||
last->NEXT = temp;
|
||||
iter = temp;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
last = iter;
|
||||
iter = iter->NEXT;
|
||||
}
|
||||
|
||||
/*
|
||||
* check again
|
||||
*/
|
||||
|
||||
UUCheckGlobalList ();
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
+ Frank Pilhofer fp@informatik.uni-frankfurt.de +
|
||||
+---------------------------------------------------------------------------+
|
||||
| Department of Computer Sciences * University of Frankfurt / Main, Germany |
|
||||
*****************************************************************************/
|
Reference in New Issue
Block a user