read image from url

Q

quickcur

quickcur said:
[...]

On 23/12/2007 20:05, jacob navia wrote:


[...]

Please send me any problems to the mail address below
and you will get a prompt answer.

Do not send it to the group since it is compiler specific


[...]

Please pay attention to what jacob wrote. Your questions are
inappropriate for comp.lang.c.


Why???

Well whatever, I think I'll look for another solution. lcc-win seems
very unstable and buggy, and the library won't work with Microsoft
Visual C/C++.



I compiled this:

#include <netutils.h>
int GetHttpUrl(char *URL, char *localfilename);

int main(void)
{
GetHttpURL("http://www.google.com/logos/holiday07_3.gif", "test.gif");
}

The command line is:

lc tnet.c netutils.lib winhttp.lib

and I have a gif in my current directory containing the logo of
google.

Yes that works, thanks.

So I guess the remaining questions are:
1) Is it possible to link properly from the IDE without using a DOS prompt?
2) Is there a similar function that will put the image into a memory
buffer instead of saving to a file, or should I use ReadFile()?

Thanks.
 
J

jacob navia

quickcur said:
quickcur said:
On 23/12/2007 20:47, Keith Thompson wrote:

[...]

On 23/12/2007 20:05, jacob navia wrote:


[...]

Please send me any problems to the mail address below
and you will get a prompt answer.

Do not send it to the group since it is compiler specific


[...]

Please pay attention to what jacob wrote. Your questions are
inappropriate for comp.lang.c.


Why???

Well whatever, I think I'll look for another solution. lcc-win seems
very unstable and buggy, and the library won't work with Microsoft
Visual C/C++.



I compiled this:

#include <netutils.h>
int GetHttpUrl(char *URL, char *localfilename);

int main(void)
{
GetHttpURL("http://www.google.com/logos/holiday07_3.gif",
"test.gif");
}

The command line is:

lc tnet.c netutils.lib winhttp.lib

and I have a gif in my current directory containing the logo of
google.

Yes that works, thanks.

So I guess the remaining questions are:
1) Is it possible to link properly from the IDE without using a DOS prompt?
2) Is there a similar function that will put the image into a memory
buffer instead of saving to a file, or should I use ReadFile()?

Thanks.
I can't answer you in this group because I will get flamed for
answering compiler specific questions

PLEEZE write to
jacob at jacob.remcomp.fr
or
in the newsgroup dedicated to this compiler
comp.compilers.lcc

To 1)
Yes you can use the IDE. Just make a project and compile
To 2)
As K. Thompson suggested, I could write a function that reads into
a buffer but... how big would need to be the buffer?

Of course I can reallocate as needed but that would severely LIMIT the
size of the files that can be downloaded... At most you can transfer
1GB or so (what is maybe more than you will ever need anyway !)

I will try to write such a function during the holidays.
 
K

Keith Thompson

quickcur said:
On 23/12/2007 20:47, Keith Thompson wrote: [...]
Please pay attention to what jacob wrote. Your questions are
inappropriate for comp.lang.c.

Why???

Because this newsgroup discusses the C programming language. Your
questions are about how to use a particular implementation, and about
certain extensions provided by that implementation. That
implementation has its own newsgroup (comp.compilers.lcc), and its
maintainer, though he frequently posts here, has already asked you to
contact him directly.

(Actually, comp.compilers.lcc is primarily, or at least originally,
about the "lcc" compiler; "lcc-win" is derived from "lcc". In any
case, comp.compilers.lcc is the place to ask about anything that's
specific to lcc-win.)

Before posting to a newsgroup, it's usually a good idea to take a look
at what's already been posted, to get an idea of what the newsgroup is
about.

[...]
 
G

Gordon Burditt

#include said:
int GetHttpUrl(char *URL, char *localfilename);

void main()
{
// gethttputrl("http://www.google.com/logos/holiday07_3.gif",
"c:\test.gif");
GetHttpUrl("http://www.google.com/logos/holiday07_3.gif",
"c:\test.gif");
^^^^^^^^^^^^

You want a file name with a TAB in the middle of it? Although you
didn't manage to link this program I expect you will have problems
with the strange file name once you get that fixed (try "c:\\test.gif").

Friends don't let friends void main().
 
G

Gordon Burditt

// gethttputrl("http://www.google.com/logos/holiday07_3.gif",
Please do not write to the root of drive C!!!!

Use another directory since writing to the drive C will
make the program crash under vista.

I sincerely hope you don't mean that, even though the program is
permitted to because the programmer voided main(). I hope you mean
that attempting to create a file in the root of drive C will get
you some kind of "permission denied" error from fopen() (or similar
method of opening files), GetHttpUrl will gracefully check for the
error of failure to open the output file, and return error status
as well. Dereferencing NULL, calling abort(), or terminating
the program in response to an error is decidedly unfriendly.
 
R

Richard Heathfield

quickcur said:

For the same reason that the original lcc-win32 spam was inappropriate for
comp.lang.c - this group deals with the language, not with implementations
thereof.
Well whatever, I think I'll look for another solution. lcc-win seems
very unstable and buggy,

You might well say that. I couldn't possibly comment.
 
R

Richard Heathfield

Keith Thompson said:
If you're having problems with lcc-win, please ask about them in
comp.compilers.lcc,

The sad thing about all this is that the OP would *not* be having problems
with lcc-win if he hadn't listened to bad, self-serving, off-topic advice
from a notorious spammer.
 
R

Richard

Richard Heathfield said:
quickcur said:


For the same reason that the original lcc-win32 spam was inappropriate for
comp.lang.c - this group deals with the language, not with implementations
thereof.


You might well say that. I couldn't possibly comment.

Miaow. Good to see you showing your true colours once again. You can not
resist having a little bitchy slap at Jacob can you? I see its not
"spam" when you are knocking his product and him personally. You need to
get out more or take a good long look at yourself in the mirror.
 
R

Richard Heathfield

(e-mail address removed) said:
Notice the subject of this newsgroup is ISO C.
ISO C has not defined 'url' and the such.

Nevertheless, third-party libraries (such as libcurl) exist that can help
him to do what he needs, quickly and easily. Yes, it's true that such
libraries are not topical here, but saying "Cannot be done" conveys a
false impression. As a matter of fact, there is nothing about ISO C that
prevents a portable solution from being written, provided one is prepared
to delegate to some external system the responsibility for attaching
standard input and output to a remote server. (This can certainly be done
on some systems.)
Please try another platform-specific newsgroup.

When you suggest this (and I will concede that it is a perfectly proper
suggestion, although a networking-specific group might be more use to the
OP), you need to explain *why* the question isn't best asked here in clc,
and ideally it should be done in a way that doesn't leave the OP wanting
to punch your lights out.
 
J

jacob navia

Richard said:
Keith Thompson said:


The sad thing about all this is that the OP would *not* be having problems
with lcc-win if he hadn't listened to bad, self-serving, off-topic advice
from a notorious spammer.

Another spammer recommended libcurl.

Of course everyone knows that libcurl is standard C

Happy christmas
 
J

Joachim Schmitz

jacob navia said:
Another spammer recommended libcurl.

Of course everyone knows that libcurl is standard C
It's source code is freeely available, in contrast to lcc-win's...

Bye, Jojo
 
J

jacob navia

Joachim said:
It's source code is freeely available, in contrast to lcc-win's...

Bye, Jojo

The source code of netutils.c is distributed with lcc-win, together
with a whole chapter explaining how it works in the tutorial.

But I am not a believer in the GNU religion. So what?
 
J

Joachim Schmitz

jacob navia said:
The source code of netutils.c is distributed with lcc-win, together
with a whole chapter explaining how it works in the tutorial.

But I am not a believer in the GNU religion. So what?
You don't need to. It is perfecly OK (by me at least) that you earn money
with your software, but promoting it here is (rightly) considered SPAM.

Bye, Jojo

Bye, Jojo
 
Q

quickcur

quickcur said:
quickcur wrote:

On 23/12/2007 20:47, Keith Thompson wrote:

[...]

On 23/12/2007 20:05, jacob navia wrote:



[...]

Please send me any problems to the mail address below
and you will get a prompt answer.

Do not send it to the group since it is compiler specific



[...]

Please pay attention to what jacob wrote. Your questions are
inappropriate for comp.lang.c.



Why???

Well whatever, I think I'll look for another solution. lcc-win seems
very unstable and buggy, and the library won't work with Microsoft
Visual C/C++.




I compiled this:

#include <netutils.h>
int GetHttpUrl(char *URL, char *localfilename);

int main(void)
{
GetHttpURL("http://www.google.com/logos/holiday07_3.gif",
"test.gif");
}

The command line is:

lc tnet.c netutils.lib winhttp.lib

and I have a gif in my current directory containing the logo of
google.


Yes that works, thanks.

So I guess the remaining questions are:
1) Is it possible to link properly from the IDE without using a DOS
prompt?
2) Is there a similar function that will put the image into a memory
buffer instead of saving to a file, or should I use ReadFile()?

Thanks.

I can't answer you in this group because I will get flamed for
answering compiler specific questions

PLEEZE write to
jacob at jacob.remcomp.fr
or
in the newsgroup dedicated to this compiler
comp.compilers.lcc

To 1)
Yes you can use the IDE. Just make a project and compile
To 2)
As K. Thompson suggested, I could write a function that reads into
a buffer but... how big would need to be the buffer?

Of course I can reallocate as needed but that would severely LIMIT the
size of the files that can be downloaded... At most you can transfer
1GB or so (what is maybe more than you will ever need anyway !)

I will try to write such a function during the holidays.

Dear Jacob-

Thanks for all the help.

I don't want to make you get flamed in the group - but my feeling is
that when a question comes up it's better to have the answer in the
group rather than personal email, so that it's an archive where people
with the same problem in future can also find help.

I figured out 2) - I just needed to edit the .prj file and change one of
the lines to
Libraries=netutils.lib winhttp.lib
then it compiles fine in the IDE.

For 1), I'd have a function like
int GetHttpUrlToBuffer(char *URL, void *buffer, int bufferLength);
and return the size of the image, or -1 if it didn't fit in the buffer
or there was a network error.

Happy Xmas to all!
 
D

Doug

quickcur said:



For the same reason that the original lcc-win32 spam was inappropriate for
comp.lang.c - this group deals with the language, not with implementations
thereof.


You might well say that. I couldn't possibly comment.

Merry xmas, Richard. You should ask Santa for some class.
 
R

Richard Heathfield

jacob navia said:
Another spammer recommended libcurl.

Do you really not understand the difference between suggesting someone
else's product and suggesting your own? It was not libcurl's author who
recommended it here.
Of course everyone knows that libcurl is standard C

It is because libcurl is /not/ standard C that those bright enough to
recommend it are also bright enough to suggest that discussion thereof
should be taken up in a more appropriate group.
 
F

Flash Gordon

Richard Heathfield wrote, On 24/12/07 12:52:
jacob navia said:

It is because libcurl is /not/ standard C that those bright enough to
recommend it are also bright enough to suggest that discussion thereof
should be taken up in a more appropriate group.

Richard, the last part of that is definitely unfair to Jacob. He did ask
the OP to take further discussion off this group. IIRC he actually asked
this a couple of times.

Also, since Jacob did not hide that it was his compiler and the only
solutions to the OPs problem would involve system specifics, I don't
think it was unreasonable for Jacob to point out his implementation as
one of the possible system-specific solutions.

By all means fight spam and off-topic posts and correct errors, but when
it is a system specific solution to a problem which requires a system
specific solution and further discussion is redirected else where you
have no valid (in my opinion) cause for complaint against Jacob.

On this occasion it does look like you've taken a dig at Jacob for no
other reason than to take a dig at him.
 
M

Mark McIntyre

Another spammer recommended libcurl.

Libcurl wasn't recommended by its author, and had it been so, I'm sure
its author would have explained he had a vested interest in the solution.
Of course everyone knows that libcurl is standard C

The mention of libcurl was a /redirect/.
 
R

Richard Heathfield

Flash Gordon said:

On this occasion it does look like you've taken a dig at Jacob for no
other reason than to take a dig at him.

I don't care what it looks like. What it *is* is an expression of
disapproval of his treating this newsgroup as a commercial channel.
 
M

Mark McIntyre

quickcur said:
On 23/12/2007 20:05, jacob navia wrote:
[...]

Please send me any problems to the mail address below and you will get
a prompt answer.

Do not send it to the group since it is compiler specific

[...]

Please pay attention to what jacob wrote. Your questions are
inappropriate for comp.lang.c.

Why???

Because networking, internet access and so forth are not part of the core
standard C. You need to ask specialists in for example
comp.unix.programmer, where, despite the unix bit, networking in general
is topical.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,951
Messages
2,570,113
Members
46,698
Latest member
alexxx

Latest Threads

Top