-
-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #842 from AppImage/appimage-extract-and-run
--appimage-extract-and-run
- Loading branch information
Showing
8 changed files
with
773 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
char* appimage_hexlify(const char* bytes, const size_t numBytes) { | ||
// first of all, allocate the new string | ||
// a hexadecimal representation works like "every byte will be represented by two chars" | ||
// additionally, we need to null-terminate the string | ||
char* hexlified = (char*) calloc((2 * numBytes + 1), sizeof(char)); | ||
|
||
for (size_t i = 0; i < numBytes; i++) { | ||
char buffer[3]; | ||
sprintf(buffer, "%02x", (unsigned char) bytes[i]); | ||
strcat(hexlified, buffer); | ||
} | ||
|
||
return hexlified; | ||
} |
Oops, something went wrong.