- Update to 2.0 beta 3
- Use USE_DOS2UNIX instead our own wheel PR: ports/109393 Submitted by: Ivan Petrov <petrovdear at gmail.com>
This commit is contained in:
parent
b73b1c0f64
commit
2ab017c14b
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=186575
6 changed files with 192 additions and 141 deletions
|
@ -6,31 +6,25 @@
|
|||
#
|
||||
|
||||
PORTNAME= chmview
|
||||
PORTVERSION= 1.0
|
||||
PORTREVISION= 2
|
||||
DISTVERSION= 2.0b3
|
||||
CATEGORIES= converters textproc
|
||||
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
|
||||
MASTER_SITE_SUBDIR= trexinc
|
||||
DISTNAME= chmview
|
||||
DISTNAME= CHMView_${DISTVERSION}
|
||||
|
||||
MAINTAINER= ports@FreeBSD.org
|
||||
COMMENT= Extractor from .chm files
|
||||
|
||||
USE_ZIP= yes
|
||||
USE_DOS2UNIX= yes
|
||||
|
||||
WRKSRC= ${WRKDIR}/src
|
||||
PLIST_FILES= bin/chmview
|
||||
PORTDOCS= chmformat.html
|
||||
|
||||
pre-patch:
|
||||
@${SH} ${FILESDIR}/convert.sh ${WRKSRC}
|
||||
@${CP} ${FILESDIR}/Makefile ${WRKSRC}
|
||||
|
||||
do-install:
|
||||
@${INSTALL_PROGRAM} ${WRKSRC}/chmview ${PREFIX}/bin/
|
||||
.if !defined(NOPORTDOCS)
|
||||
-@${MKDIR} ${DOCSDIR}
|
||||
@${INSTALL_DATA} ${WRKSRC}/${PORTDOCS} ${DOCSDIR}/
|
||||
.endif
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
MD5 (chmview.zip) = 8b9dcae298aeda972d4b5ab56af466f0
|
||||
SHA256 (chmview.zip) = c26d24ddb6be98b73f9e472d1c478462ba1c6fa59a3e49c697eb08955c35bb27
|
||||
SIZE (chmview.zip) = 66764
|
||||
MD5 (CHMView_2.0b3.zip) = ebe6b61bcf08672348b608969206e9a2
|
||||
SHA256 (CHMView_2.0b3.zip) = d9cd81b1f5a1851e2ea47f6e6b7dd6ba76578fcd26c8d636df2d80be4a050adf
|
||||
SIZE (CHMView_2.0b3.zip) = 50891
|
||||
|
|
|
@ -5,18 +5,19 @@ OBJDIR = .
|
|||
EXEDIR = .
|
||||
EXENAME = $(EXEDIR)/chmview
|
||||
|
||||
CFLAGS += -g
|
||||
LFLAGS += -g
|
||||
CFLAGS += -DUNIX
|
||||
|
||||
all: $(EXENAME)
|
||||
|
||||
OBJS = $(OBJDIR)/chmview.o \
|
||||
$(OBJDIR)/chmlib.o \
|
||||
$(OBJDIR)/lzx.o
|
||||
$(OBJDIR)/chm_lib.o \
|
||||
$(OBJDIR)/lzx.o \
|
||||
$(OBJDIR)/utf8.o
|
||||
|
||||
$(OBJDIR)/chmview.o: chmview.c chmlib.h
|
||||
$(OBJDIR)/chmlib.o: chmlib.c chmlib.h fixendian.h lzx.h
|
||||
$(OBJDIR)/lzx.o: lzx.c lzx.h lzx_int.h
|
||||
$(OBJDIR)/chmview.o: chmview.c chm_lib.h
|
||||
$(OBJDIR)/chm_lib.o: chm_lib.c chm_lib.h lzx.h
|
||||
$(OBJDIR)/utf8.o: utf8.c utf8.h
|
||||
$(OBJDIR)/lzx.o: lzx.c lzx.h
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c ${.IMPSRC}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ X$1 = X ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! cd $1
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm makefile
|
||||
|
||||
for FILE in *
|
||||
do
|
||||
tr -d '\r' <${FILE} >${FILE}.NEW
|
||||
mv ${FILE}.NEW ${FILE}
|
||||
done
|
||||
|
|
@ -1,9 +1,180 @@
|
|||
diff -r -u ../src/chmlib.h ./chmlib.h
|
||||
--- ../src/chmlib.h Sun Dec 1 01:26:02 2002
|
||||
+++ ./chmlib.h Fri Mar 28 17:40:39 2003
|
||||
@@ -129,3 +129,5 @@
|
||||
chmfile *chm_openfile(char *fname);
|
||||
--- ../src/chmview.c
|
||||
+++ chmview.c.new
|
||||
@@ -17,16 +17,30 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
void chm_close(chmfile *l);
|
||||
+#ifndef UNIX
|
||||
#include <windows.h>
|
||||
+#endif
|
||||
+
|
||||
+#define MODE 0755
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
+
|
||||
+#ifdef UNIX
|
||||
+#include <errno.h>
|
||||
+#include <locale.h>
|
||||
+#else
|
||||
#include <dir.h>
|
||||
+#endif
|
||||
|
||||
#include "chm_lib.h"
|
||||
#include "utf8.h"
|
||||
|
||||
+#ifdef UNIX
|
||||
+#define _strnicmp strncasecmp
|
||||
+#define MODE 755
|
||||
+#endif
|
||||
+
|
||||
struct cb_data
|
||||
{
|
||||
int extractwithoutpath;
|
||||
@@ -44,6 +58,7 @@
|
||||
return p;
|
||||
}
|
||||
|
||||
+#ifndef UNIX
|
||||
int makedir(char *path)
|
||||
{
|
||||
char *end;
|
||||
@@ -75,6 +90,39 @@
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
+#else
|
||||
+static int makedir(char *path)
|
||||
+{
|
||||
+ char *slash;
|
||||
+ int was_error, done, err;
|
||||
+
|
||||
+ slash = path;
|
||||
+ done = 0;
|
||||
+ was_error = 0;
|
||||
+
|
||||
+ do {
|
||||
+ slash = index(slash + 1, '/');
|
||||
+ if (slash)
|
||||
+ {
|
||||
+ *slash = 0;
|
||||
+ if (mkdir(path, MODE) == -1 && EEXIST != errno)
|
||||
+ was_error = 1;
|
||||
+ *slash = '/';
|
||||
+ }
|
||||
+ else
|
||||
+ done = 1;
|
||||
+ } while (! done && ! was_error);
|
||||
+
|
||||
+ if (was_error)
|
||||
+ {
|
||||
+ perror("mkdir");
|
||||
+ exit(1);
|
||||
+ /* return 0; */
|
||||
+ }
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+#endif
|
||||
|
||||
const char ILLEGAL_SYMB[] = "<>:|?*\"";
|
||||
const char ILLEGAL_REPL[] = "()_!__'";
|
||||
@@ -103,6 +151,9 @@
|
||||
char fullpath[CHM_MAX_PATHLEN*2+1];
|
||||
char target[CHM_MAX_PATHLEN*2+1];
|
||||
wchar_t temp[CHM_MAX_PATHLEN+1];
|
||||
+#ifdef UNIX
|
||||
+ size_t pathlen;
|
||||
+#endif
|
||||
|
||||
if (ui->length)
|
||||
{
|
||||
@@ -116,13 +167,32 @@
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+#ifndef UNIX
|
||||
GetCurrentDirectory(sizeof(fullpath)-1,fullpath);
|
||||
while ((p = strstr(fullpath,"\\")) != NULL)
|
||||
*p = '/';
|
||||
if (fullpath[strlen(fullpath)-1] != '/')
|
||||
strcat(fullpath,"/");
|
||||
+#else
|
||||
+ getcwd(fullpath, sizeof(fullpath)-1);
|
||||
+ pathlen = strlen(fullpath);
|
||||
+ if (pathlen == 0)
|
||||
+ return -1; /* impossible but... defensive programming */
|
||||
+ if (fullpath[pathlen - 1] != '/')
|
||||
+ {
|
||||
+ if (pathlen == PATH_MAX)
|
||||
+ return -1;
|
||||
+ else
|
||||
+ fullpath[pathlen] = '/';
|
||||
+ fullpath[pathlen+1] = 0;
|
||||
+ }
|
||||
+#endif
|
||||
decode_UTF8(temp,ui->path);
|
||||
+#ifndef UNIX
|
||||
WideCharToMultiByte(CP_ACP,0,temp,-1,target,sizeof(target),NULL,NULL);
|
||||
+#else
|
||||
+ wcstombs(target, temp, sizeof(target));
|
||||
+#endif
|
||||
ReplaceIllegalChars(target);
|
||||
strcat(fullpath,extractwithoutpath?pointtoname(target):(target[0]=='/'?target+1:target));
|
||||
if (!extractwithoutpath)
|
||||
@@ -153,15 +223,19 @@
|
||||
wchar_t temp[CHM_MAX_PATHLEN+1];
|
||||
|
||||
decode_UTF8(temp,ui->path);
|
||||
+#ifndef UNIX
|
||||
WideCharToMultiByte(CP_OEMCP,0,temp,-1,target,sizeof(target),NULL,NULL);
|
||||
+#else
|
||||
+ wcstombs(target, temp, sizeof(target));
|
||||
+#endif
|
||||
printf("Extracting %s ",target);
|
||||
if (savetofile(c, ui, extractwithoutpath))
|
||||
{
|
||||
printf("Error\n");
|
||||
error=1;
|
||||
//return CHM_ENUMERATOR_FAILURE;
|
||||
- }
|
||||
- printf("OK\n");
|
||||
+ } else
|
||||
+ printf("OK\n");
|
||||
}
|
||||
|
||||
int _extract_callback_all(struct chmFile *c, struct chmUnitInfo *ui, void *context)
|
||||
@@ -193,7 +267,11 @@
|
||||
wchar_t temp[CHM_MAX_PATHLEN+1];
|
||||
|
||||
decode_UTF8(temp,ui->path);
|
||||
+#ifndef UNIX
|
||||
WideCharToMultiByte(CP_OEMCP,0,temp,-1,target,sizeof(target),NULL,NULL);
|
||||
+#else
|
||||
+ wcstombs(target, temp, sizeof(target));
|
||||
+#endif
|
||||
|
||||
if ((target)[0] == '/')
|
||||
{
|
||||
@@ -243,6 +321,9 @@
|
||||
|
||||
infname = argv[2];
|
||||
|
||||
+#ifdef UNIX
|
||||
+ setlocale(LC_ALL,"");
|
||||
+#endif
|
||||
c = chm_open(infname);
|
||||
if (!c)
|
||||
exit(-1);
|
||||
@@ -305,7 +386,11 @@
|
||||
strcat(target,name+1);
|
||||
else
|
||||
strcat(target,name);
|
||||
+#ifndef UNIX
|
||||
MultiByteToWideChar(CP_ACP,0,target,-1,temp,sizeof(temp));
|
||||
+#else
|
||||
+ mbstowcs(temp, target, sizeof(target));
|
||||
+#endif
|
||||
encode_UTF8(target,temp);
|
||||
status = chm_resolve_object(c,target,&ui);
|
||||
if (status==CHM_RESOLVE_SUCCESS && ui.path[strlen(ui.path)-1]!='/')
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
diff -r -u ../src/chmview.c ./chmview.c
|
||||
--- ../src/chmview.c Fri Mar 28 20:59:31 2003
|
||||
+++ ./chmview.c Fri Mar 28 19:01:39 2003
|
||||
@@ -3,9 +3,7 @@
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
-#include <dir.h>
|
||||
#include "chmlib.h"
|
||||
-#define PATH_MAX 512
|
||||
|
||||
static char *pointtoname(char *path)
|
||||
{
|
||||
@@ -15,6 +13,7 @@
|
||||
return p;
|
||||
}
|
||||
|
||||
+#if 0
|
||||
static int makedir(char *path)
|
||||
{
|
||||
char *end;
|
||||
@@ -47,6 +46,38 @@
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
+#else
|
||||
+static int makedir(char *path)
|
||||
+{
|
||||
+ char *slash;
|
||||
+ int was_error, done, err;
|
||||
+
|
||||
+ slash = path;
|
||||
+ done = 0;
|
||||
+ was_error = 0;
|
||||
+
|
||||
+ do {
|
||||
+ slash = index(slash + 1, '/');
|
||||
+ if (slash)
|
||||
+ {
|
||||
+ *slash = 0;
|
||||
+ if (mkdir(path, MODE) == -1 && EEXIST != errno)
|
||||
+ was_error = 1;
|
||||
+ *slash = '/';
|
||||
+ }
|
||||
+ else
|
||||
+ done = 1;
|
||||
+ } while (! done && ! was_error);
|
||||
+
|
||||
+ if (was_error)
|
||||
+ {
|
||||
+ perror("mkdir");
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+#endif
|
||||
|
||||
static int savetofile(chmfile *c, char *target, int extractwithoutpath)
|
||||
{
|
||||
@@ -55,18 +86,25 @@
|
||||
char *rtarget;
|
||||
char *p;
|
||||
FILE *f;
|
||||
- char path[PATH_MAX];
|
||||
- char fullpath[PATH_MAX];
|
||||
+ char fullpath[PATH_MAX + 1];
|
||||
+ size_t pathlen;
|
||||
|
||||
if (chm_getfile(c, target, &length, &outbuf) != 0)
|
||||
return 1;
|
||||
- getcurdir(0,path);
|
||||
- fullpath[0]=getdisk()+'A'; fullpath[1]=':'; fullpath[2]='/'; fullpath[3]='\0';
|
||||
- strcat(fullpath,path);
|
||||
- while ((p = strstr(fullpath,"\\")) != NULL)
|
||||
- *p = '/';
|
||||
- if (fullpath[strlen(fullpath)-1] != '/')
|
||||
- strcat(fullpath,"/");
|
||||
+
|
||||
+ getcwd(fullpath,PATH_MAX-1);
|
||||
+ pathlen = strlen(fullpath);
|
||||
+ if (pathlen == 0)
|
||||
+ return -1; /* impossible but... defensive programming */
|
||||
+ if (fullpath[pathlen - 1] != '/')
|
||||
+ {
|
||||
+ if (pathlen == PATH_MAX)
|
||||
+ return -1;
|
||||
+ else
|
||||
+ fullpath[pathlen] = '/';
|
||||
+ fullpath[pathlen+1] = 0;
|
||||
+ }
|
||||
+
|
||||
strcat(fullpath,extractwithoutpath?pointtoname(target):target+1);
|
||||
if (!extractwithoutpath)
|
||||
if (!makedir(fullpath))
|
Loading…
Reference in a new issue