Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/codeplea/hexembed

A small utility to embed files into C or C++ programs.
https://github.com/codeplea/hexembed

Last synced: 6 days ago
JSON representation

A small utility to embed files into C or C++ programs.

Awesome Lists containing this project

README

        

# hexembed

hexembed is a very small utility to help embed files in C or C++ programs in an easy, cross-platform way.

## Usage

```
> gcc hexembed.c -o hexembed
> hexembed some_file.jpg > some_file.c
> cat some_file.c

/* Embedded file: some_file.jpg */
const int fsize = 1873;
const unsigned char *file = {
0x2f,0x2a,0x0a,0x20,0x2a,0x20,0x68,0x65,0x78,0x65,0x6d,0x62,0x65,0x64,0x20,0x2d,
0x20,0x61,0x20,0x73,0x69,0x6d,0x70,0x6c,0x65,0x20,0x75,0x74,0x69,0x6c,0x69,0x74,
0x79,0x20,0x74,0x6f,0x20,0x68,0x65,0x6c,0x70,0x20,0x65,0x6d,0x62,0x65,0x64,0x20,
0x66,0x69,0x6c,0x65,0x73,0x20,0x69,0x6e,0x20,0x43,0x20,0x70,0x72,0x6f,0x67,0x72,
...
};
```

Now you can simply `#include "some_file.c"` file in your program, and you have access to that file's data.

You can find more info and alternative methods here: https://codeplea.com/embedding-files-in-c-programs