Converting filesystem to ".C" prog file

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View


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?



Re: Converting filesystem to ".C" prog file


Quoted text here. Click to load it
file.
direction?

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

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



Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it

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

There seems little sense in reinventing wheels.



Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it

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
http://www.oreilly.com/catalog/learnperl4/ and
http://www.oreilly.com/catalog/lperlwin/

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

Re: Converting filesystem to ".C" prog file




<snip>
Quoted text here. Click to load it

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.




Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it

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

Re: Converting filesystem to ".C" prog file


Quoted text here. Click to load it

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
http://www.fivetrees.com



Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it

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.



Re: Converting filesystem to ".C" prog file


Quoted text here. Click to load it

If a windows program is acceptable for you, then try this one:
http://www.qsl.net/dk8pp/downloads/bin2c.zip

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


Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it

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.



Re: Converting filesystem to ".C" prog file


Quoted text here. Click to load it
  My pleasure...

Quoted text here. Click to load it
  Neither do I. It is all Ansi C.

Quoted text here. Click to load it
  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.


Re: Converting filesystem to ".C" prog file


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
http://www.qsl.net/dk8pp/downloads/supplement.zip


Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it

Many thanks - only just downloaded Watcom!



Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it
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
We've slightly trimmed the long signature. Click to see the full one.
Re: Converting filesystem to ".C" prog file


In comp.arch.embedded,
Quoted text here. Click to load it
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.:
We've slightly trimmed the long signature. Click to see the full one.
Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it

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

Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it

Google found 22,000 sites!  Many thanks.



Re: Converting filesystem to ".C" prog file


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 http://www.microchip.com .


Re: Converting filesystem to ".C" prog file



Quoted text here. Click to load it

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

Many thanks.



Site Timeline