- use chmlib-0.40 instead of embedded chmlib-0.19, remove patch-bb
- improve Makefile, remove unnecessary do-install target - remove ONLY_FOR_ARCH, new chmlib does not have such a limitation - give maintainership to submitter PR: ports/165287 Submitted by: Alex Kozlov <spam@rm-rf.kiev.ua>
This commit is contained in:
parent
2655b730c7
commit
34a2d51f60
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=291854
5 changed files with 22 additions and 280 deletions
|
@ -6,28 +6,28 @@
|
|||
#
|
||||
|
||||
PORTNAME= chmview
|
||||
DISTVERSION= 2.0b3
|
||||
PORTREVISION= 1
|
||||
DISTVERSION= 2.0b4
|
||||
CATEGORIES= converters textproc
|
||||
MASTER_SITES= SF/trexinc/CHMView/2.0%20beta%203
|
||||
MASTER_SITES= ${MASTER_SITE_GOOGLE_CODE}
|
||||
DISTNAME= CHMView_${DISTVERSION}
|
||||
|
||||
MAINTAINER= ports@FreeBSD.org
|
||||
MAINTAINER= spam@rm-rf.kiev.ua
|
||||
COMMENT= Extractor from .chm files
|
||||
|
||||
USE_ZIP= yes
|
||||
USE_DOS2UNIX= yes
|
||||
LICENSE= GPLv2
|
||||
|
||||
LIB_DEPENDS= chm:${PORTSDIR}/misc/chmlib
|
||||
|
||||
PROJECTHOST= ak-various-projects
|
||||
|
||||
USE_XZ= yes
|
||||
USE_DOS2UNIX= chmview.c utf8.c utf8.h
|
||||
|
||||
WRKSRC= ${WRKDIR}/src
|
||||
PLIST_FILES= bin/chmview
|
||||
MAKE_JOBS_SAFE= yes
|
||||
|
||||
ONLY_FOR_ARCHS= i386 amd64
|
||||
|
||||
pre-patch:
|
||||
@${CP} ${FILESDIR}/Makefile ${WRKSRC}
|
||||
|
||||
do-install:
|
||||
@${INSTALL_PROGRAM} ${WRKSRC}/chmview ${PREFIX}/bin/
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
SHA256 (CHMView_2.0b3.zip) = d9cd81b1f5a1851e2ea47f6e6b7dd6ba76578fcd26c8d636df2d80be4a050adf
|
||||
SIZE (CHMView_2.0b3.zip) = 50891
|
||||
SHA256 (CHMView_2.0b4.tar.xz) = 122d6d3f027a0ff3070d61aa3245d3091788ac6bd3fd506b41aaae53c401b910
|
||||
SIZE (CHMView_2.0b4.tar.xz) = 30528
|
||||
|
|
|
@ -1,27 +1,16 @@
|
|||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
OBJDIR = .
|
||||
EXEDIR = .
|
||||
EXENAME = $(EXEDIR)/chmview
|
||||
|
||||
CFLAGS += -DUNIX
|
||||
BINDIR?= ${PREFIX}/bin
|
||||
|
||||
all: $(EXENAME)
|
||||
CFLAGS+= -DUNIX -I${LOCALBASE}/include
|
||||
LDADD+= -L${LOCALBASE}/lib -lchm
|
||||
|
||||
OBJS = $(OBJDIR)/chmview.o \
|
||||
$(OBJDIR)/chm_lib.o \
|
||||
$(OBJDIR)/lzx.o \
|
||||
$(OBJDIR)/utf8.o
|
||||
WARNS?= 6
|
||||
|
||||
$(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
|
||||
NO_MAN= yes
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c ${.IMPSRC}
|
||||
PROG= chmview
|
||||
|
||||
$(EXENAME): $(OBJS)
|
||||
echo $(OBJS)
|
||||
$(CC) $(LFLAGS) -o $(EXENAME) ${.ALLSRC}
|
||||
SRCS= chmview.c utf8.h utf8.c
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,224 +0,0 @@
|
|||
diff -ruN src.old/chmview.c src/chmview.c
|
||||
--- src.old/chmview.c 2005-03-07 21:29:18.000000000 +0100
|
||||
+++ chmview.c 2008-08-18 14:39:39.000000000 +0200
|
||||
@@ -17,19 +17,33 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
+#ifndef UNIX
|
||||
#include <windows.h>
|
||||
+#endif
|
||||
+
|
||||
#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 0755
|
||||
+#endif
|
||||
+
|
||||
struct cb_data
|
||||
{
|
||||
- int extractwithoutpath;
|
||||
+ long extractwithoutpath;
|
||||
char *path;
|
||||
int pathlen;
|
||||
};
|
||||
@@ -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[] = "()_!__'";
|
||||
@@ -94,7 +142,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
-static int savetofile(struct chmFile *c, struct chmUnitInfo *ui, int extractwithoutpath)
|
||||
+static int savetofile(struct chmFile *c, struct chmUnitInfo *ui, long extractwithoutpath)
|
||||
{
|
||||
LONGINT64 length=0;
|
||||
char *outbuf=NULL;
|
||||
@@ -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)
|
||||
@@ -147,26 +217,30 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
-void extract(struct chmFile *c, struct chmUnitInfo *ui, int extractwithoutpath)
|
||||
+void extract(struct chmFile *c, struct chmUnitInfo *ui, long extractwithoutpath)
|
||||
{
|
||||
char target[CHM_MAX_PATHLEN*2+1];
|
||||
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;
|
||||
- }
|
||||
+ } else
|
||||
printf("OK\n");
|
||||
}
|
||||
|
||||
int _extract_callback_all(struct chmFile *c, struct chmUnitInfo *ui, void *context)
|
||||
{
|
||||
- extract(c,ui,(int)context);
|
||||
+ extract(c,ui,(long)context);
|
||||
return CHM_ENUMERATOR_CONTINUE;
|
||||
}
|
||||
|
||||
@@ -180,7 +254,7 @@
|
||||
return CHM_ENUMERATOR_CONTINUE;
|
||||
}
|
||||
|
||||
-extractdir(struct chmFile *c, char *path, int extractwithoutpath)
|
||||
+extractdir(struct chmFile *c, char *path, long extractwithoutpath)
|
||||
{
|
||||
struct cb_data data = {extractwithoutpath,path,strlen(path)};
|
||||
chm_enumerate(c,CHM_ENUMERATE_ALL,_extract_callback_dir,(void *)&data);
|
||||
@@ -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);
|
||||
@@ -265,7 +346,7 @@
|
||||
char target[CHM_MAX_PATHLEN*2+1];
|
||||
wchar_t temp[CHM_MAX_PATHLEN+1];
|
||||
int status;
|
||||
- int extractwithoutpath = command[0]=='e'?1:0;
|
||||
+ long extractwithoutpath = command[0]=='e'?1:0;
|
||||
|
||||
if (argc == 4)
|
||||
{
|
||||
@@ -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,23 +0,0 @@
|
|||
diff -ruN src.old/chm_lib.c src/chm_lib.c
|
||||
--- src.old/chm_lib.c 2008-08-18 10:22:30.000000000 +0200
|
||||
+++ chm_lib.c 2008-08-18 11:10:20.000000000 +0200
|
||||
@@ -170,8 +170,18 @@
|
||||
typedef unsigned long UInt32;
|
||||
typedef long long Int64;
|
||||
typedef unsigned long long UInt64;
|
||||
-#else
|
||||
|
||||
+/* AMD64 */
|
||||
+#elif __amd64__
|
||||
+typedef unsigned char UChar;
|
||||
+typedef short Int16;
|
||||
+typedef unsigned short UInt16;
|
||||
+typedef long Int32;
|
||||
+typedef unsigned long UInt32;
|
||||
+typedef long long Int64;
|
||||
+typedef unsigned long long UInt64;
|
||||
+
|
||||
+#else
|
||||
/* yielding an error is preferable to yielding incorrect behavior */
|
||||
#error "Please define the sized types for your platform in chm_lib.c"
|
||||
#endif
|
Loading…
Reference in a new issue