Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Web programming in C lang with TCC

Reply
Thread Tools

Web programming in C lang with TCC

 
 
lovecreatesbeauty
Guest
Posts: n/a
 
      06-16-2011
$ cat /usr/lib/cgi-bin/ex1.c
#!/usr/local/bin/tcc -run

#include <tcclib.h>

int main(void)
{
printf("Content-type: text/html\r\n\r\n");
printf("Hello <a href=\"http://bellard.org/tcc/\">TCC</a> cgi
\n");

return 0;
}
$

Screenshot:
https://gknszq.bay.livefilestore.com...cgi.JPG?psid=1
 
Reply With Quote
 
 
 
 
Mark Bluemel
Guest
Posts: n/a
 
      06-16-2011
On 06/16/2011 10:31 AM, lovecreatesbeauty wrote:
> $ cat /usr/lib/cgi-bin/ex1.c
> #!/usr/local/bin/tcc -run
>
> #include<tcclib.h>
>
> int main(void)
> {
> printf("Content-type: text/html\r\n\r\n");
> printf("Hello<a href=\"http://bellard.org/tcc/\">TCC</a> cgi
> \n");
>
> return 0;
> }
> $
>
> Screenshot:
> https://gknszq.bay.livefilestore.com...cgi.JPG?psid=1


Did you have a question or a point to make?
 
Reply With Quote
 
 
 
 
lovecreatesbeauty
Guest
Posts: n/a
 
      06-16-2011
On Jun 16, 5:54*pm, Mark Bluemel <(E-Mail Removed)> wrote:
> On 06/16/2011 10:31 AM, lovecreatesbeauty wrote:
>
>
>
>
>
>
>
>
>
> > $ cat /usr/lib/cgi-bin/ex1.c
> > #!/usr/local/bin/tcc -run

>
> > #include<tcclib.h>

>
> > int main(void)
> > {
> > * * * * *printf("Content-type: text/html\r\n\r\n");
> > * * * * *printf("Hello<a href=\"http://bellard.org/tcc/\">TCC</a> *cgi
> > \n");

>
> > * * * * *return 0;
> > }
> > $

>
> > Screenshot:
> >https://gknszq.bay.livefilestore.com...4YUSaOhLLDXSfq...

>
> Did you have a question or a point to make?


Thanks for posting.

I mean I posted this one "The end of C-like script languages - C
script with TCC" some days ago.

People seems don't believe the C can be directly used in web
programming

I wish C (with TCC) eat up PHP, Perl, ..
 
Reply With Quote
 
Angel
Guest
Posts: n/a
 
      06-16-2011
On 2011-06-16, lovecreatesbeauty <(E-Mail Removed)> wrote:
>
> People seems don't believe the C can be directly used in web
> programming


CGI programs written in C have been around longer than PHP and Perl
have, I think.


--
"C provides a programmer with more than enough rope to hang himself.
C++ provides a firing squad, blindfold and last cigarette."
- seen in comp.lang.c
 
Reply With Quote
 
Tom St Denis
Guest
Posts: n/a
 
      06-16-2011
On Jun 16, 10:56*am, "io_x" <(E-Mail Removed)> wrote:
> "lovecreatesbeauty" <(E-Mail Removed)> ha scritto nel messaggionews:(E-Mail Removed)...
>
> >$ cat /usr/lib/cgi-bin/ex1.c
> > #!/usr/local/bin/tcc -run

>
> > #include <tcclib.h>

>
> > int main(void)
> > {
> > * * * *printf("Content-type: text/html\r\n\r\n");

>
> i think in some pc, in some compiler, in some OS: "\n\n" could be sufficient
> but if above there is "\r\n" than below there is need of "\r\n" too;
> [and this is not here]


Not only is this ridiculously OT, but in HTTP you must send \r\n\r\n
to indicate two blank lines REGARDLESS of your platform hosting or
consuming content.

> so for me it should be the file as
> --------------
> // file name page.c
> #include <stdio.h>
>
> int main(void)
> {printf("Content-type: text/html \n\n");
> *printf("Hello <a href=\"http://bellard.org/tcc/\">TCC</a> cgi\n");
> *return 0;}


Except this won't work, and you'd know that if you tested it (any half
decent web server would reject the CGI output and issue an error).

Tom
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      06-16-2011
lovecreatesbeauty <(E-Mail Removed)> writes:
[...]
> I mean I posted this one "The end of C-like script languages - C
> script with TCC" some days ago.
>
> People seems don't believe the C can be directly used in web
> programming


I don't think anyone has ever suggested that it's not possible.
And for generating static content, as your program does, it probably
works as well as any other language -- though not as well as just
creating an html file in the right place.

For other purpose, scripting languages offer much easier string
handling, which is a considerable advantage in this context.

> I wish C (with TCC) eat up PHP, Perl, ..


By all means, wish away.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
lovecreatesbeauty
Guest
Posts: n/a
 
      06-16-2011
On Jun 17, 12:08*am, Keith Thompson <(E-Mail Removed)> wrote:
>
> I don't think anyone has ever suggested that it's not possible.
> And for generating static content, as your program does, it probably
> works as well as any other language -- though not as well as just
> creating an html file in the right place.


Thank you.

I tried some more examples with TCC just now tonight (01:25 dark and
silent morning like the night here.

You're right. TCC presents static pages easily but lacks of session
management. And PHP features like $_GET['x'], $_POST['x'] are missing
from TCC currently. Maybe someone will contribute on this area for
TCC. Can this guy be me

> For other purpose, scripting languages offer much easier string
> handling, which is a considerable advantage in this context.


TCC seems can use the whole C library as well as the stdio.h and
string.h. I think the string operation function are not a problem for
TCC to succeed on web.
 
Reply With Quote
 
lovecreatesbeauty
Guest
Posts: n/a
 
      06-16-2011
On Jun 16, 11:15*pm, Angel <(E-Mail Removed)> wrote:
> On 2011-06-16, lovecreatesbeauty <(E-Mail Removed)> wrote:
> CGI programs written in C have been around longer than PHP and Perl
> have, I think.


With TCC, the request points directly to the .c source file
http://192.168.122.199/cgi-bin/a.c
not something like
http://192.168.122.199/cgi-bin/a.out
or
http://192.168.122.199/cgi-bin/a.sh

I may be wrong.
 
Reply With Quote
 
lovecreatesbeauty
Guest
Posts: n/a
 
      06-16-2011
On Jun 17, 12:08*am, Keith Thompson <(E-Mail Removed)> wrote:
>
> For other purpose, scripting languages offer much easier string
> handling, which is a considerable advantage in this context.
>


I think by now C scripting with TCC can at least kick Perl out of
stage

>> I wish C (with TCC) eat up PHP, Perl, ..


> By all means, wish away.


What's your opinion on TCC's ability of making C a power script tool?
C is great and should be used everywhere.
 
Reply With Quote
 
lovecreatesbeauty
Guest
Posts: n/a
 
      06-16-2011
On Jun 17, 1:46*am, lovecreatesbeauty <(E-Mail Removed)>
wrote:
> On Jun 17, 12:08*am, Keith Thompson <(E-Mail Removed)> wrote:
>
> > For other purpose, scripting languages offer much easier string
> > handling, which is a considerable advantage in this context.

>


No more weird languages like Perl, Pythod, Ruby, PHP, ..blah..
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tcc won't link libraries. Malcolm McLean C Programming 3 06-19-2011 10:42 PM
The end of C-like script languages - C script with TCC lovecreatesbeauty C Programming 19 06-19-2011 04:05 PM
how can i compile c program on dos prompt using tcc and tc juned2285@gmail.com C++ 1 08-04-2008 10:13 AM
looking for compiled tcc for win32 gregory.petrosyan@gmail.com C Programming 3 04-19-2006 02:11 AM
What is .tcc? jsnX C++ 1 04-04-2005 11:51 PM



Advertisments