Maker Pro
Maker Pro

Converting filesystem to ".C" prog file

F

Fred

Jan 1, 1970
0
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?
 
F

Frank Bemelman

Jan 1, 1970
0
Fred said:
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?

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

Fred

Jan 1, 1970
0
Frank Bemelman said:
direction?

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

--

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

There seems little sense in reinventing wheels.
 
S

Scott Seidman

Jan 1, 1970
0
Yes thanks. I would like to fix it but I have abysmal knowledge of
perl.

There seems little sense in reinventing wheels.

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.
 
F

Fred

Jan 1, 1970
0
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).

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.
 
T

Thomas Gellekum

Jan 1, 1970
0
Fred said:
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'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
 
S

Steve at fivetrees

Jan 1, 1970
0
Fred said:
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.

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
 
F

Fred

Jan 1, 1970
0
Steve at fivetrees said:
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

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.
 
F

Fred

Jan 1, 1970
0
Michael Krämer said:
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

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.
 
Fred said:
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?
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.
 
S

Stef

Jan 1, 1970
0
In comp.arch.embedded,
Fred said:
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?
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.
 
D

Dan

Jan 1, 1970
0
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?

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.
 
F

Fred

Jan 1, 1970
0
Dan said:
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.

Google found 22,000 sites! Many thanks.
 
F

Fred

Jan 1, 1970
0
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 .

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

Many thanks.
 
Top