From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- .../x-cvsweb-markup/index.html | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 cvs/cvsweb.cgi/code/tool/bin2c/bin2c.cpp?rev=1.1&content-type=text/x-cvsweb-markup/index.html (limited to 'cvs/cvsweb.cgi/code/tool/bin2c/bin2c.cpp?rev=1.1&content-type=text/x-cvsweb-markup/index.html') diff --git a/cvs/cvsweb.cgi/code/tool/bin2c/bin2c.cpp?rev=1.1&content-type=text/x-cvsweb-markup/index.html b/cvs/cvsweb.cgi/code/tool/bin2c/bin2c.cpp?rev=1.1&content-type=text/x-cvsweb-markup/index.html new file mode 100644 index 00000000..ed037a8d --- /dev/null +++ b/cvs/cvsweb.cgi/code/tool/bin2c/bin2c.cpp?rev=1.1&content-type=text/x-cvsweb-markup/index.html @@ -0,0 +1,92 @@ + + + +code/tool/bin2c/bin2c.cpp - view - 1.1 + +
[BACK] Return to bin2c.cpp + CVS log [TXT][DIR] Up to Nevrax / code / tool / bin2c

File: Nevrax / code / tool / bin2c / bin2c.cpp (download)
+Revision 1.1, Tue Dec 5 15:02:11 2000 UTC (18 months, 3 weeks ago) by corvazier +
Branch: MAIN +
CVS Tags: HEAD
+no message
+
+

// bin2c.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include "stdio.h"
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char* argv[])
+{
+        if (argc<2)
+        {
+                printf ("bin2c [filename.bin] [filename.c]\n");
+        }
+        else
+        {
+                char sDir[256];
+                char sPath[256];
+                char sName[256];
+                char sExt[256];
+                _splitpath (argv[1], sDir, sPath, sName, sExt);
+
+                char sOutput[256];
+                if (argc>2)
+                        strcpy (sOutput, argv[2]);
+                else
+                {
+                        _makepath (sOutput, sDir, sPath, sName, ".cpp");
+                }
+
+                FILE *pIn=fopen( argv[1], "rb");
+                if (pIn==NULL)
+                        printf ("Can't open %s.", argv[1]);
+                else
+                {
+                        FILE *pOut=fopen( sOutput, "w");
+                        if (pOut==NULL)
+                                printf ("Can't open %s.", sOutput);
+                        else
+                        {
+                                fprintf (pOut, 
+                                        "/**\n"
+                                        "  * Generated by bin2c.exe\n"
+                                        "  * binfile: %s\n"
+                                        "  */\n"
+                                        "\n"
+                                        "extern const unsigned char %s[];\n"
+                                        "extern const unsigned int %sSize;\n\n"
+                                        "static const unsigned char %s[] =\n"
+                                        "{\n", argv[1], sName, sName, sName);
+
+                                unsigned int size=0;
+                                while (1)
+                                {
+                                        fprintf (pOut, "\t");
+                                        for (int i=0; i<8; i++)
+                                        {
+                                                int c=fgetc (pIn);
+                                                if (c==EOF)
+                                                        break;
+                                                fprintf (pOut, "0x%02x, ", c);
+                                                size++;
+                                        }
+                                        fprintf (pOut, "\n");
+                                        if (i!=8)
+                                                break;
+                                }
+                                fprintf (pOut, "};\n\n");
+                                
+                                fprintf (pOut, "static const unsigned int %sSize = %d;\n\n", sName, size);
+
+                                fclose (pOut);
+                                fclose (pIn);
+                        }
+                }
+        }
+        
+        return 0;
+}
+
\ No newline at end of file -- cgit v1.2.1