Converting filesystem to ".C" prog file

I need to convert a number of files which contain data to a C program file.

I have come across a perl script which is meant to do this. However it doesn't work with perl in the recent version of Cygwin.

Does anyone have anything which can help or point me in the right direction?

Reply to
Fred
Loading thread data ...

"Fred" schreef in bericht news:436768d7$0$23280$ snipped-for-privacy@news.zen.co.uk...

file.

direction?

Well, fix it or write something quick & dirty in C then.

--
Thanks, Frank.
(remove 'q' and '.invalid' when replying by email)
Reply to
Frank Bemelman

Yes thanks. I would like to fix it but I have abysmal knowledge of perl.

There seems little sense in reinventing wheels.

Reply to
Fred

"Fred" wrote in news:43677368$0$23288$ snipped-for-privacy@news.zen.co.uk:

We'd like to help, but you've provided exactly zero useful data to help us help you. "Convert data files to C program" can mean absolutely anything (and I'd be a little surprised if you can find some generic script which will do exactly what you need it to do). "Doesn't work with Cygwin" is even less useful. Is it running? Is it simply not producing the output you want? Are you getting an error message? Is it not finding your input file because of a path problem? I find perl to be very portable between distributions, so I'd be a more surprised if the code weren't doing exactly what it was written to do, as opposed to being written to do something other than what you need it to do.

You'll find that until you can provide well-formed questions, you'll be reinventing wheels quite a bit.

As for pointing you in the right direction, try

formatting link
and
formatting link

My estimate is that if you've done any programming in any language, you'll be able to fix your perl script in a week, if you spend about 25% of your time on it, or 2-3 days at 100%. You might get lucky, and fix the problem in an hour or two. Because of the nature of perl code, my bet is it will take you about the same amount of time to write your converter from scratch as it will to decipher someone else's code.

--
Scott
Reverse name to reply
Reply to
Scott Seidman

OK, I accept the criticism. I agree I can write my own code in C to convert html files into const char data for use with am embedded server. I was hoping for an open sourced solution which would go either the full or part way into creating this C code. I could then compile and link this with the rest of the webserver.

Thanks for the links of books on the subject but I don't think with the learning curve of perl it's an ideal approach.

Reply to
Fred

I'm still not sure if that's what you want, but you might want to look for file2c(1):

,---- | EXAMPLES | The command: | | date | file2c 'const char date[] = {' ',0};' | | will produce: | | const char date[] = { | 83,97,116,32,74,97,110,32,50,56,32,49,54,58,50,56,58,48,53, | 32,80,83,84,32,49,57,57,53,10 | ,0}; `----

tg

Reply to
Thomas Gellekum

Does your webserver have PHP? If so, it's quite easy to write a PHP script to produce C data. (I've done so many times). However you still haven't told us what kind of data you're trying to convert (other than it's HTML).

Steve

formatting link

Reply to
Steve at fivetrees

I haven't come across PHP. I'm trying to put together a very basic webpage which crudely gives the status of a system. The HTML is very basic!

I was hoping for a windows program which converted a filename into a const char name and the contents into hex data. Similar to the "file2c" pipe in an earlier post.

As intimated earlier, it would be fairly quick for me to write my own.

Many thanks.

Reply to
Fred

If a windows program is acceptable for you, then try this one:

formatting link

I wrote it for the purpose of embedding binary data (.png, .mp3, .wav and the like) into an embedded C-project. The zip-file contains the source and the project for the Open Watcom compiler. The program can convert individual files or a list of files. If multiple files are converted, then a "table of contents" can be created. Just play around and you will see how it works. Feel free to adapt the program to your requirements.

Michael

Reply to
Michael Krämer

That's immensely kind of you. I don't know C++ but the files convert very nicely. I will try a bit of tinkering. I see you can select multiple source files and that you used Watcom.

Reply to
Fred

My pleasure...

Neither do I. It is all Ansi C.

Yes, because it is free. I also consider the tools very reliable and the debugger is straightforward to understand. Only the resource editor is a bit weird and unstable, but maybe I'm using it in a wrong way.

Reply to
Michael Krämer

I made a common mistake: I forgot to include some files, which are required for compiling the project. They are in different folders on my PC, namely "include" and "lib". Please find the missing files at

formatting link

Reply to
Michael Krämer

Many thanks - only just downloaded Watcom!

Reply to
Fred

in one of the demo projects following freertos there is a perl script doing what you ask i think, it is called makefsdata.

It is a collegue that used this just helped him with some cygwin perl, so I haven't any URL for you, but google will help you.

--
Med venlig hilsen/mojn/regards
Martin Hansen
 Click to see the full signature
Reply to
mah_list1

Do you really need the C file or just need the data? If the later, objcopy can copy a binary input to elf or other output that you then can link with your application. It creates symbols for start end and size of the date that you can just pick up in your C program. This is how I link some pictures with my code.

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)

knowledge, n.:
 Click to see the full signature
Reply to
Stef

"Fred" wrote in news:436768d7$0$23280$ snipped-for-privacy@news.zen.co.uk:

google for a program named bin2c there are a million (ok, a few dozen) that are all available as source and various developers pages. One of them should work or you can easily modify to suit your needs.

--
dan
Reply to
Dan

Google found 22,000 sites! Many thanks.

Reply to
Fred

You can use Microchip MPFS(Microchip Pic File System). This is will convert your data files (*.*) to C file/ .Bin file. You can download MPFS in

formatting link
.

Reply to
ganeshcm

I had downloaded MCHPStack already but didn't realise it had MPFS within it.

Many thanks.

Reply to
Fred

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.