SHA256
1
0
forked from pool/file

Accepting request 131364 from Base:System

add documentation (bnc#776532) (forwarded request 131178 from yecril71pl)

OBS-URL: https://build.opensuse.org/request/show/131364
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/file?expand=0&rev=60
This commit is contained in:
Ismail Dönmez 2012-08-26 09:31:23 +00:00 committed by Git OBS Bridge
commit 8446c10a6d
3 changed files with 191 additions and 7 deletions

172
file-endian.patch Normal file
View File

@ -0,0 +1,172 @@
--- src/apprentice.c.orig
+++ src/apprentice.c
@@ -48,6 +48,7 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.
#include <sys/mman.h>
#endif
#include <dirent.h>
+#include <byteswap.h>
#define EATAB {while (isascii((unsigned char) *l) && \
isspace((unsigned char) *l)) ++l;}
@@ -97,9 +98,11 @@ private int apprentice_load(struct magic
const char *, int);
private void byteswap(struct magic *, uint32_t);
private void bs1(struct magic *);
-private uint16_t swap2(uint16_t);
-private uint32_t swap4(uint32_t);
-private uint64_t swap8(uint64_t);
+
+#define swap2(x) bswap_16(x)
+#define swap4(x) bswap_32(x)
+#define swap8(x) bswap_64(x)
+
private char *mkdbname(struct magic_set *, const char *, int);
private int apprentice_map(struct magic_set *, struct magic **, uint32_t *,
const char *);
@@ -662,7 +665,7 @@ set_test_type(struct magic *mstart, stru
/* invalid search type, but no need to complain here */
break;
}
- return 0;
+ //return 0;
}
/*
@@ -2412,67 +2415,6 @@ byteswap(struct magic *magic, uint32_t n
}
/*
- * swap a short
- */
-private uint16_t
-swap2(uint16_t sv)
-{
- uint16_t rv;
- uint8_t *s = (uint8_t *)(void *)&sv;
- uint8_t *d = (uint8_t *)(void *)&rv;
- d[0] = s[1];
- d[1] = s[0];
- return rv;
-}
-
-/*
- * swap an int
- */
-private uint32_t
-swap4(uint32_t sv)
-{
- uint32_t rv;
- uint8_t *s = (uint8_t *)(void *)&sv;
- uint8_t *d = (uint8_t *)(void *)&rv;
- d[0] = s[3];
- d[1] = s[2];
- d[2] = s[1];
- d[3] = s[0];
- return rv;
-}
-
-/*
- * swap a quad
- */
-private uint64_t
-swap8(uint64_t sv)
-{
- uint64_t rv;
- uint8_t *s = (uint8_t *)(void *)&sv;
- uint8_t *d = (uint8_t *)(void *)&rv;
-#if 0
- d[0] = s[3];
- d[1] = s[2];
- d[2] = s[1];
- d[3] = s[0];
- d[4] = s[7];
- d[5] = s[6];
- d[6] = s[5];
- d[7] = s[4];
-#else
- d[0] = s[7];
- d[1] = s[6];
- d[2] = s[5];
- d[3] = s[4];
- d[4] = s[3];
- d[5] = s[2];
- d[6] = s[1];
- d[7] = s[0];
-#endif
- return rv;
-}
-
-/*
* byteswap a single magic entry
*/
private void
--- src/cdf.c.orig
+++ src/cdf.c
@@ -50,6 +50,7 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.50 2012
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
+#include <byteswap.h>
#ifndef EFTYPE
#define EFTYPE EINVAL
@@ -75,56 +76,9 @@ static union {
#define CDF_TOLE2(x) ((uint16_t)(NEED_SWAP ? _cdf_tole2(x) : (uint16_t)(x)))
#define CDF_GETUINT32(x, y) cdf_getuint32(x, y)
-
-/*
- * swap a short
- */
-static uint16_t
-_cdf_tole2(uint16_t sv)
-{
- uint16_t rv;
- uint8_t *s = (uint8_t *)(void *)&sv;
- uint8_t *d = (uint8_t *)(void *)&rv;
- d[0] = s[1];
- d[1] = s[0];
- return rv;
-}
-
-/*
- * swap an int
- */
-static uint32_t
-_cdf_tole4(uint32_t sv)
-{
- uint32_t rv;
- uint8_t *s = (uint8_t *)(void *)&sv;
- uint8_t *d = (uint8_t *)(void *)&rv;
- d[0] = s[3];
- d[1] = s[2];
- d[2] = s[1];
- d[3] = s[0];
- return rv;
-}
-
-/*
- * swap a quad
- */
-static uint64_t
-_cdf_tole8(uint64_t sv)
-{
- uint64_t rv;
- uint8_t *s = (uint8_t *)(void *)&sv;
- uint8_t *d = (uint8_t *)(void *)&rv;
- d[0] = s[7];
- d[1] = s[6];
- d[2] = s[5];
- d[3] = s[4];
- d[4] = s[3];
- d[5] = s[2];
- d[6] = s[1];
- d[7] = s[0];
- return rv;
-}
+#define _cdf_tole2(x) bswap_16(x)
+#define _cdf_tole4(x) bswap_32(x)
+#define _cdf_tole8(x) bswap_64(x)
/*
* grab a uint32_t from a possibly unaligned address, and return it in

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Sun Aug 19 19:22:01 UTC 2012 - giecrilj@stegny.2a.pl
- add documentation (bnc#776532)
-------------------------------------------------------------------
Tue Aug 14 04:06:35 UTC 2012 - crrodriguez@opensuse.org
- Use the OS's byteswapping routines.
-------------------------------------------------------------------
Tue Jun 26 07:45:16 UTC 2012 - cfarrell@suse.com

View File

@ -58,6 +58,7 @@ Patch30: file-5.10-visibility.patch
Patch31: file-5.07-biorad.dif
Patch32: file-5.07-clicfs.dif
Patch33: file-ocloexec.patch
Patch34: file-endian.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%global _sysconfdir /etc
%global _miscdir %{_datadir}/misc
@ -70,7 +71,6 @@ used by apsfilter to permit automatic printing of different file types.
%package -n file-devel
Summary: Include Files and Libraries mandatory for Development
License: BSD-2-Clause
Group: Development/Libraries/Other
Provides: file:/usr/include/magic.h
Requires: file = %{version}
@ -108,7 +108,7 @@ to develop applications that require the magic "file" interface.
%patch32 -p0 -b .clicfs
%patch33 -p0 -b .clexe
%patch -b .0
%patch34
%build
export LANG=POSIX
export LC_ALL=POSIX
@ -132,7 +132,7 @@ make DESTDIR=%{buildroot} install pkgdatadir='$(datadir)'
rm -vf %{buildroot}%{_sysconfdir}/magic
echo '# Localstuff: file(1) magic(5) for locally observed files' > %{buildroot}%{_sysconfdir}/magic
echo '# global magic file is %{_miscdir}/magic(.mgc)' >> %{buildroot}%{_sysconfdir}/magic
#install -s dcore %{buildroot}%{_bindir}
%{nil install -s dcore %{buildroot}%{_bindir}}
# Check out that the binary does not bail out:
LD_LIBRARY_PATH=%{buildroot}%{_libdir}
export LD_LIBRARY_PATH
@ -148,18 +148,20 @@ unset LD_LIBRARY_PATH
%files
%defattr (644,root,root,755)
%config(noreplace) %{_sysconfdir}/magic
#%{_bindir}/dcore
%{nil %{_bindir}/dcore}
%attr(755,root,root) %{_bindir}/file
%{_libdir}/lib*.so.*
%{_miscdir}/magic
%{_miscdir}/magic.mgc
%attr(644,root,root) %{_mandir}/man1/file.1.gz
%attr(644,root,root) %{_mandir}/man5/magic.5.gz
%doc %{_mandir}/man1/file.1.gz
%doc %{_mandir}/man5/magic.5.gz
%doc README COPYING AUTHORS NEWS ChangeLog
%files -n file-devel
%defattr (644,root,root,755)
%{_libdir}/lib*.so
%{_includedir}/magic.h
%attr(644,root,root) %{_mandir}/man3/libmagic.3.gz
%doc %{_mandir}/man3/libmagic.3.gz
%doc README COPYING AUTHORS NEWS ChangeLog
%changelog