English 中文(简体)
静态调节(c/c++文档类型探测)
原标题:Compiling libmagic statically (c/c++ file type detection)
最佳回答

这是一种骗局,我相信你能够这样做......我已经下载了神灵的消息来源,并看着它......。

minifile.c内有以下功能:magic_read_entries/code>。 (这是我从sourceforge 下载的纯范式资料来源。) 从外部档案读取。

您可以将<条码>魔法文档(载于/etc名录)贴到图书馆法典的末尾,如<条码>散射魔法”;>libmagic.a。 在我的系统中,magic为474443 bytes,libmagic.a为38588 bytes。

magic.c文档中,您需要在功能结束时修改magichandle_t* magic_init(未签名国旗)功能,在功能结束时添加“条码”栏目:即已读-entries,并将功能本身改为由图书馆自己在数据中抽取,将其视作指向点(char **)的指使器,并使用从档案中读取。 由于你知道图书馆数据可读之处,这不应是困难的。

现在这一功能将不再使用<条码>魔法_read_entries,因为它不会再从档案中读过。 “魔法-t* magic_init(未签名的旗帜)”这一功能将谨慎装载这些条目,你应当在那里 。

如果需要进一步帮助,让我知道,

Edit: I have used the old libmagic from sourceforge.net and here is what I did:

  1. Extracted the downloaded archive into my home directory, ungzipping/untarring the archive will create a folder called libmagic.
  2. Create a folder within libmagic and call it Test
  3. Copy the original magic.c and minifile.c into Test
  4. Using the enclosed diff output highlighting the difference, apply it onto the magic.c source.
48a49,51
> #define MAGIC_DATA_OFFSET     0x971C
> #define MAGIC_STAT_LIB_NAME "libmagic.a"
>
125a129,130
>       /* magic_read_entries is obsolete... */
>       magic_read_entries(mh, MAGIC_STAT_LIB_NAME);
251c256,262
<
---
>
>       if (!fseek(fp, MAGIC_DATA_OFFSET, SEEK_SET)){
>               if (ftell(fp) != MAGIC_DATA_OFFSET) return 0;
>       }else{
>               return 0;
>       }
>
  • Then issue make
  • The magic file (which I copied from /etc, under Slackware Linux 12.2) is concatenated to the libmagic.a file, i.e. cat magic >> libmagic.a. The SHA checksum for magic is (4abf536f2ada050ce945fbba796564342d6c9a61 magic), here s the exact data for magic (-rw-r--r-- 1 root root 474443 2007-06-03 00:52 /etc/file/magic) as found on my system.
  • Here s the diff for the minifile.c source, apply it and rebuild minifile executable by running make again.
40c40
<       magic_read_entries(mh,"magic");
---
>       /*magic_read_entries(mh,"magic");*/

届时它应当工作。 否则,你将需要调整冲抵图书馆,以便阅读,修改MAGIC_DATA_OFFSET。 如果你愿意,我可以把魔法数据文档上 stick。 让我知道。

Hope this helps, Best regards, Tom.

问题回答

我可以告诉你,如何静态地汇编一个图书馆——你只是把这条路通过到你方位指挥结束时的档案中——a 档案只是汇编物体的档案(o)。 采用“原始文件Type 试验”将显示有活力联系的图书馆——Petlibdir}/libmagic。 这里就是如此。

关于外部数据档案中的链接...... 我不知道——你没有包办申请(deb.rpm. Cantar.bz2)? 在窗户上,我写了一台安装器,使用NSIS。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签