Thread: Including CSS in a web C program

  1. #1
    Registered User
    Join Date
    May 2019
    Posts
    3

    Including CSS in a web C program

    (on a fedora box)

    I'm running an test - can I convert a PHP web page to C. So far so good. Now I need to .. link stylesheet ... main.css

    I've tried:
    char answerbox[][64]= { "width: auto;", "height: auto;", "border....

    It compiles but doesn't produce the page I want. Can I get some pointers
    Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,484
    I'm sure you can, but the question is why?

    You can, because if you dig deep enough through the layers of whatever you're using, you're going to find C at the bottom of the hole.

    But if you're wanting to do all that yourself, you're looking at writing potentially 1000's of lines of code.
    Code which will inevitably have multiple security holes that PHP/CSS/Javascript/whatever have gone though the pain of finding and fixing.

    So, seriously, why?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2019
    Posts
    3
    "Why" - Well, 'Just because you can doesn't mean your should' - but then again ... Because you can ... - will it run faster? will it be more secure? can I do????

    Let me state: My page is written in PHP and is working fine. Think layout of a flea market - Google image as background, booth spaces ar 40px X 40px. CSS and wz_tooltip.js using a mysql db. Two tables: booth and cust. booth: bid, cid, x, y, cost, content, rotate. cust: cid, bid, name, em, pptid, comment. Page is table with background the Google image if the area. The wz_tooltip allows me to place a booth at any x/y position at any rotation. Each booth image contains booth number (clickable to paypal) and a mouseover "Info" which pops up a box [bid, cost, contents]. Booth avail = green bg, sold = pink.

    So - wild hair - can I convert to pure C? and here we are. I've been able to get it to compile without errors or warnings as a cgi and index.php runs it. A couple of problems: background not. booths all piled up at 9 oclock.


    Anyhow it's an exercise - will I get it to work? Eh..

    Including CSS in a web C program-booths-png

  4. #4
    Registered User catacombs's Avatar
    Join Date
    May 2019
    Location
    /home/
    Posts
    72
    I'm curious to see how this will play out.

    My rule of thumb: If it needs to be on the web, stick with HTML/CSS/JavaScript. Anything else seems like way too much work.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,484
    > will it run faster?
    It has that potential.
    But unless your server is serving 1000's of requests a second, you're not going to be noticing an awful lot of change in your overall system load.

    > will it be more secure?
    No.
    Sorry, but anyone here asking questions about how to do this just won't have the necessary skills to write secure internet facing code in C.

    If it's a toy for your own amusement, then fine.
    If this is an actual commercial endeavour (you mentioned paypal), you'd better have your lawyer on speed-dial.

    > can I do????
    I'm sure you're going to try.

    > A couple of problems: background not. booths all piled up at 9 oclock.
    So you have bugs in your code - so what?

    Since you've neither shown us the original PHP, nor your C code which claims to replicate it's functionality, it's hard to say how you messed it up.

    Does your C code use the same mysql db that your PHP used?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,148
    I uh, don't see the problem. Your PHP script, and therefore your C program written for CGI, would have just processed serverside logic to result in clientside code that can include CSS. It's the responsibility of the HTTP agent to parse and render the CSS, not your serverside code, not the web server. So what's the problem? This has nothing to do with C and CGI. Fix your CSS and it'll work with both your PHP script and your C CGI program.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    May 2019
    Posts
    3
    > server is serving 1000's...
    Well I'm on a shared server, so, ya

    > secure
    My thought process - that's a side issue - I have had my php scripts hacked - they added a base64 line as line one - (aside - I run a 'whats changed on all of my pages every day - sum filex today doesn't match sum filex yesterday)

    > toy?
    Eh, asking the question, learning. Why do ID 10 Ts climb Mt Everest?

    > bugs in code
    Had this discussion long ago - what's the largest program you ever wrote that ran the first time error free - we agreed ... eh, 10 lines...

    > booths piled up
    not any more -

    > orig php & C
    well it's 200 line +/- in both - I'd list it here but it would just start a flame war - because I've found there are 7 different ways to code the same output and every 3d person takes offense on how the other person codes ...

    > same mysql db
    yup. both are as much 1:1 as possible. Given PHP is not C and C is not PHP.

    Basic flow:
    Code:
    mysql_real_connect ()
    select b.*, c.* from booth, cust where b.id = c.id
    while (fetch)
    {
    display_booth (args...)
    }
    display_special_items ()
    ==============================
    So in the image above is the booth was green the booth# would be clickable to a page 
    asking for contents of your booth then taking you to PP. PP returns to a purchasereturn 
    page which updates the DB
    
    void display_booths()
    {
    if (sold) class=answerboxpink else answerboxgreen (include href-> purchase.php?boothnumber&price
    "<a href='' onmouseover=Tip)
    table border=1
    tr/tdBooth: bid
    tr/tdPrice: price
    tr/td contents
    /table
    onmouseout=UnTip
    ==================
    
    void spec(ial)box (x, y, h, w, text, rotate)
    div class=answerbox ...
    table 
    text
    /table
    =====================

    If you'd like the php/c - PM me
    Last edited by liderbug; 05-26-2019 at 09:44 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Should I consider including my .DLL source code in my program?
    By HelpfulPerson in forum C Programming
    Replies: 2
    Last Post: 12-17-2013, 07:37 PM
  2. Problem with including a class in my program
    By TheYeIIowDucK in forum C++ Programming
    Replies: 1
    Last Post: 09-16-2010, 02:23 PM
  3. including a table in my program
    By kingjames in forum C++ Programming
    Replies: 2
    Last Post: 07-08-2007, 02:38 AM
  4. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  5. Replies: 4
    Last Post: 12-14-2005, 02:21 PM

Tags for this Thread