read url

G

Georg Klein

Hi all,
this is a newbie-question again, but i couldn't find a solution on the net:
I want to open a url (like
fopen ("http://www.site.com/welcome.jpg", "r");
) and copy the file to a local file (like "copy welcome.jpg A:")
How can I open the file?
Thanks
Georg
 
J

Jens.Toerring

Georg Klein said:
this is a newbie-question again, but i couldn't find a solution on the net:
I want to open a url (like
fopen ("http://www.site.com/welcome.jpg", "r");
) and copy the file to a local file (like "copy welcome.jpg A:")
How can I open the file?

You can't because what you try to open there isn't a file but something
that you only get at via a network connection, using the HTTP protocol.
Standard C has no functions for doing such things and if it is possible
to get at such an external file you will have to use some platform spe-
cific extensions. Thus you will have to ask in a group dedicated to the
system you're working with - I guess in your case some Windows programm-
ing group.
Regards, Jens
 
J

jacob navia

Georg said:
Hi all,
this is a newbie-question again, but i couldn't find a solution on the net:
I want to open a url (like
fopen ("http://www.site.com/welcome.jpg", "r");
) and copy the file to a local file (like "copy welcome.jpg A:")
How can I open the file?
Thanks
Georg
If you use the lcc-win32 compiler you can do:

GetHttpUrl("http://www.mysite.com/mydoc.html","c:\\temp\\mydoc.html");

Very easy.

lcc-win32: http://www.cs.virginia.edu/~lcc-win32

P.S.:
Disclaimer:
Of course this is not part of the C language as defined by ISO.
 
L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can't because what you try to open there isn't a file

I agree with you so far.
but something
that you only get at via a network connection, using the HTTP protocol.

Sorry, but here's where I disagree.

A file (at least in C), is something external. There are no more details
in the C standard than that as to how a file is implemented external to
C. A stream is associated to a file by way of the fopen() function. If
fopen() can manage it, then whatever the named resource actually
represents, it is a file to C.

Consider, on a MSWindowsish environment,
fopen("\\\\SERVER\\SHARE\\file.txt","r")
can be a valid file open, even though it represents data "that you only
get via a network connection".

Similarly, on MVS,
fopen("DDNAME:SYSIPT","r");
opens a real file, but the file isn't named "DDNAME:SYSIPT". The logical
name to physical name translation is managed by the stdio library.

/If/ the OP's C implementation handled URL-formatted filenames, /then/
fopen("http://server/file.jpg","r");
would be just as legal as
fopen("\\\\SERVER\\SHARE\\file.txt","r")
or
fopen("DDNAME:SYSIPT","r");
is to their respective C implementations. This is a
quality-of-implementation issue, not a language issue.
Standard C has no functions for doing such things

as managing, through an implementation-independant C language feature,
network access. However, the C standard does not restrict an
implementation from providing such a feature, so long as it is handled
as part of the "implementation defined" aspects of the standard C
language features.
and if it is possible
to get at such an external file you will have to use some platform spe-
cific extensions

if your C implementation does not offer such a facility through one of
the standard C language features
.

Thus you will have to ask in a group dedicated to the
system

or C compiler
you're working with - I guess in your case some Windows programm-
ing group.
Regards, Jens


- --

Lew Pitcher, IT Consultant, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBrL5QagVFX4UWr64RAuOnAJ9orQG8URxZl1fzD1QLPmD2Fee0rQCg5VJB
g/y0FeI7wnq58Ri8/jcES6Y=
=wsZt
-----END PGP SIGNATURE-----
 
L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Georg said:
Hi all,
this is a newbie-question again, but i couldn't find a solution on the net:
I want to open a url (like
fopen ("http://www.site.com/welcome.jpg", "r");
) and copy the file to a local file (like "copy welcome.jpg A:")
How can I open the file?

The long and short of it is that, if your C implementation does not
support url-name filenames, then there is no way to open such a file
using standard C.

If this is the case, then you will have to depend on platform-specific
extensions to the C language, and the best place to find out about those
would be a newsgroup that takes either your C compiler or your execution
environment as it's subject matter.

- --

Lew Pitcher, IT Consultant, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBrL7qagVFX4UWr64RAsvTAJsEjWIATWcfKi1tLzEwu4BtEZRaJgCaAnNV
fsrmUWEGqCVNh7VSI6Ka42I=
=xQb3
-----END PGP SIGNATURE-----
 
F

Flash Gordon

If you use the lcc-win32 compiler you can do:

GetHttpUrl("http://www.mysite.com/mydoc.html","c:\\temp\\mydoc.html");

<snip>

Strange. I tried this but the compiler failed to run on any of the
computers I own. I did not try it on my company laptop, but it certainly
doesn't run on any of the other half dozen or more computer I use at
work, nor on any of the many customers machines I can shell on to from
within the office. Of course, none of them are running MS software, but
I think giving up before trying the last machine I have access to is
reasonable.
P.S.:
Disclaimer:
Of course this is not part of the C language as defined by ISO.

Then stop posting this off topic rubbish here. You know it is off topic
since this has been pointed out to you often enough.
 
J

jacob navia

Flash said:
Then stop posting this off topic rubbish here. You know it is off topic
since this has been pointed out to you often enough.

I answered the OP question with a solution that fits exactly what he is
asking for.

Your objective is what?

To help the people that post questions or to post "off topic" messages?

I explicitly mentioned that GetHttpUrl is not part of ISO C, so there
is no possible misunderstanding of my post.
 
C

CBFalconer

jacob said:
If you use the lcc-win32 compiler you can do:

(something totally non-standard)

Surely you know by now that non-standard C is off-topic here, and
that it is bad to suggest such non-portable things to people with
insufficient knowledge to defend themselves. If you had limited
yourself to something like "try the lcc newsgroup for a
non-standard quasi-C system that can handle this" there would be no
objection.
 
G

Georg Klein

insufficient knowledge to defend themselves. If you had limited
yourself to something like "try the lcc newsgroup for a
non-standard quasi-C system that can handle this" there would be no
objection.

OK, the best would have been a standard-way to solve my problem. But for the
moment I'd be happy about every solution that works, and jacob told me it
was non-standard.
I didn't make it in lcc until now, so that might not have been the right for
me...
Georg
 
F

Flash Gordon

I answered the OP question with a solution that fits exactly what he
is asking for.

So how will he call that from his program written to use lots of
incompatable extensions from another compiler vendor?

The point is you have no way of knowing that your suggestion answers the
OPs question. It also happens that if the OP asks in the *right* place
he may get a much more portable answer, such as a library that is
available for multiple OSs and environments that will do the required
job.
Your objective is what?

To help the people that post questions or to post "off topic"
messages?

My objective is to discus and learn about the C language not about your
compiler.

BTW, because of your attitude here were the question to come up I would
recommend not using your product. Now, my company is only small, but I
am *the* person who would be asked.
I explicitly mentioned that GetHttpUrl is not part of ISO C, so there
is no possible misunderstanding of my post.

It also shows you know it is off topic here. You could have redirected
the OP to an appropriate group and discuss the issue there.
 
K

Keith Thompson

jacob navia said:
I answered the OP question with a solution that fits exactly what he is
asking for.

Your objective is what?

To help the people that post questions or to post "off topic" messages?

I explicitly mentioned that GetHttpUrl is not part of ISO C, so there
is no possible misunderstanding of my post.

I'm having problems viewing certain web pages with my browser. If I
ask about it in comp.lang.c, are you going to answer my question here,
or are you going to tell me that this isn't the place for it? What if
I'm having car trouble? What if I'm trying to track down the author
of a science fiction story I read years ago?
 
M

Mark McIntyre

I answered the OP question with a solution that fits exactly what he is
asking for.

And if he'd asked for the price of herring in Havnafjord, or the name of
the metro station nearest to Place de Vendome, would you also have told him
that?
Your objective is what?

To ask you politely to stop answering questions with offtopic answers,
which cannot be peer-reviewed here, and which encourage the original poster
to ask offtopic questions in the expectation of getting more answers.

Next time, someone will give him an erroneous answer and nobody will
realise because we're not experts in this offtopic field. So you're doing
the OP a disservice and increasing the SN ratio in the group, all at once.
 
M

Mark McIntyre

I didn't make it in lcc until now, so that might not have been the right for
me...

And whatever compiler you /are/ using probably offers a similar service.
But to find out, you need to ask in the right group. Please do that !
 
D

Dik T. Winter

> On Tue, 30 Nov 2004 21:53:00 +0100, in comp.lang.c , jacob navia

>
> And if he'd asked for the price of herring in Havnafjord, or the name of
> the metro station nearest to Place de Vendome, would you also have told him
> that?

A good start for the first (it is Hafnafjord) would probably be the herring
era museum in Siglofjörur. For the second, I would suggest "Stalingrad".
And as there are no knowledgables here... (It is Opéra of course.)
 
M

Merrill & Michele

Dik T. Winter said:
A good start for the first (it is Hafnafjord) would probably be the herring
era museum in Siglofjörur. For the second, I would suggest "Stalingrad".
And as there are no knowledgables here... (It is Opéra of course.)
(OT)
Stalingrad was #defined by Krushchev as something other than the namesake of
the greatest butcher of all time. What with progress and all, they've
probably regressed. MPJ
(/OT)
 
D

dandelion

BTW, because of your attitude here were the question to come up I would
recommend not using your product. Now, my company is only small, but I
am *the* person who would be asked.

Which is an *utterly* unprofessional attitude IMNSHO. Childish, too.
 
M

Mark L Pappin

[defense of off-topic response to off-topic questions]

Mark McIntyre said:
So you're [...] increasing the SN ratio in the group

You did mean _de_creasing, didn't you?

mlp
 
C

CBFalconer

dandelion said:
Which is an *utterly* unprofessional attitude IMNSHO. Childish, too.

On the contrary, it seems sound to me. Once the disdain for
standard practices is revealed, he would always have doubts and
worries about using the product for anything other than its own
specialized field. The prevalence of simple omissions and bugs
also becomes apparent, together with the lack of any regression
tests, when monitoring the lcc newsgroup. This is unfortunate,
because a properly controlled open-source system would be a useful
compact alternative to gcc, and M. Navias IDE system has shown
promise for years. Unfortunately it is neither open-source nor
advancing to standards compliance.
 
R

Richard Bos

dandelion said:
Which is an *utterly* unprofessional attitude IMNSHO. Childish, too.

It's a very professional attitude, and not childish at all.

Mr. Navia has shown here, repeatedly, that he does not care a jot about
Standards conformance. Why should I trust a compiler suite marketed by
someone who refuses to even try to make it conform to the Standards? I
would run a great risk of some day having one of my programs break
because he had used an identifier which belongs in my namespace, for
example.
He's also shown himself to be less than ideally competent. Even I, who
am hardly an expert C programmer, have been able to poke holes in
several of his assumptions in the past. Why should I trust code by
someone who doesn't even realise, to name but one example, that not all
computers follow the M$ object file model?
Finally, he's shown that he doesn't give a damn about being a social
person. If he cares so little about the very people he seeks help from
that he will spam the newsgroup about "his" compiler, why should I trust
him to treat his customers any better?

In short, _he_ has behaved unprofessionally, and this makes him
unsuitable as a business associate.

Richard
 

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
474,156
Messages
2,570,878
Members
47,404
Latest member
PerryRutt

Latest Threads

Top