We help IT Professionals succeed at work.

Check out this week's podcast, "Dairy Farms to Databases: Community's Hand in Technology"Listen Now

x

Translate code from PERL to C - image files

neis
neis asked
on
343 Views
Last Modified: 2010-04-15
I have the following PERL script that works fine. It sends a
picture to a browser as a response to a
<img src="http://www.***.com/cgi-bin/sendpic.pl?pic_no">
tag with the picture number is passed as shown.

Can you please show me how can one do the same thing using a
CGI script in C that can be compiled. Just in case you need,
here is info about the server:

server software is Apache/1.2b10
Perl version is 5.003
server protocol is HTTP/1.0
Common Gateway Interface (CGI) version is CGI/1.1.

Also, how do I go about compiling?

Thank you for your help.
Sincerely yours,
Laurentiu Traineanu

------------------------------------------------
#!/usr/bin/perl

$pic_path='/usr/local/etc/httpd/cgi-bin/';

  $picno=$ARGV[0];
  $pic=$picno.".gif";

&DisplayPicture;

exit;

sub DisplayPicture
{
    print "Content-type: image/gif\r\n";
    print "\r\n";

    open(GIF,"$pic_path$pic");
        select(GIF);$|=1;binmode(GIF);
        select(STDOUT);$|=1;binmode(STDOUT);
        while(<GIF>){
           print;
        }
    close(GIF);
}
------------------------------------------------
Comment
Watch Question

Author

Commented:
Edited text of question
Yes I will code it for you, but that's more worth than 100 points...

Author

Commented:
Ok, how much?
250 incl. the source - because you have to compile it on your system. I think it's a UNIX-box (Apache)?!?
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Give him the points, learn C and you will not have to give points away for such easy problems. To julio: I only wanted to clear this section from complete-program-searchers. This is for special C-problems.
Hello beckers,

i may agree with you, this forum is mainly intended for advice, not for ready products.

Anyway, there's not such a strong rule about this, so, to show my position:

i never ask homeworks;
i sometimes give complete programs, because - say - Mr.neis doesn't care about becoming a programmer: he's just 'paying' for some help.

BTW, you would have answered this for 250 points, so what's indeed your point? ;)

Cheers, julio

Author

Commented:
Thank you julio for your help. It is exactly what I was looking for. You are right, I don't care to become a C programmer, I just need to replace the PERL program with a C one.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.