当前位置:网站首页>libmagic 介绍
libmagic 介绍
2022-06-26 09:35:00 【Ruo_Xiao】
libmagic 是一个用来根据文件头识别文件类型的开发库。
栗子
#include <magic.h>
#include <stdio.h>
int main(int argc, char **argv) {
struct magic_set *cookie = NULL;
cookie = magic_open(MAGIC_MIME);
magic_load(cookie, NULL);
puts(magic_file(cookie, argv[1]));
magic_close(cookie);
return 0;
}
编译
sudo apt install libmagic-dev
gcc -o main main.c -lmagic
运行
./main ~/桌面/LibreOfficeDraw
结果
application/vnd.oasis.opendocument.graphics; charset=binary
(SAW:Game Over!)
边栏推荐
- Why do some functions in the go standard library have only signatures but no function bodies?
- 國際化配置
- 2021 national vocational college skills competition (secondary vocational group) network security competition questions (1) detailed analysis tutorial
- Install new version cmake & swig & tinyspline
- pcl install
- Summary of common commands of vim
- The basis of C language grammar -- function nesting, Fibonacci sum of recursive applet and factorial
- mysql学习总结
- LeetCode 958. 二叉树的完全性校验
- 爬虫相关文章收藏:pyppeteer 、Burpsuite
猜你喜欢

logback

Install new version cmake & swig & tinyspline

This new change of go 1.16 needs to be adapted: the changes of go get and go install

Deep learning (tentsorflow2. version) three good student performance problems (1)

Extracting public fragments from thymeleaf

WGCLOUD的web ssh服务端口是多少

2021-11-29 轨迹规划五次多项式

调用api接口生成不同颜色的微信小程序二维码

Redis notes (15) - Pipeline (the client packages and sends batch commands to save network overhead)

MapReduce & yarn theory
随机推荐
A concise tutorial for getting started with go generics
Do you know the //go: instructions in the go source code, go:linkname?
Mysql database field query case sensitive setting
Upgrade idea to 2021.2 shortcut keys
MySQL单表500万条数据增、删、改、查速度测试
pcl install
Js--- get the data with the same key value in the object array to get a new array
Specific implementation comparison between different programming languages
Speed test of adding, deleting, modifying and querying 5million pieces of data in a single MySQL table
Leetcode connected to rainwater series 42 (one dimension) 407 (2D)
定制拦截器
Leetcode refers to offer II 091 Paint house - modify in place
install realsense2: The following packages have unmet dependencies: libgtk-3-dev
Differences between VI and vim and common commands
测试实践——app 测试注意点
2021-11-29 轨迹规划五次多项式
Tensorflow dynamically allocates video memory
Automated testing -- on the coexistence of Unitest and pytest initialization
我的创作纪念日
LeetCode 接雨水系列 42.(一维) 407.(二维)