LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-07-2010, 11:02 AM   #46
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453

Quote:
Originally Posted by Wim Sturkenboom View Post
... What the meaning is of what is in there depends on the code that you write. ...
And on the CPU architecture.
 
Old 07-07-2010, 12:04 PM   #47
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by Sergei Steshenko View Post
And on the CPU architecture.
At the CPU level, both instructions and data are all just bytes in memory. A certain value can be interpreted as a signed integer, integer, character, floating point number, CPU instruction, etc. only depending on how it's used.
 
Old 07-07-2010, 12:07 PM   #48
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Okay, my code finally compiles, but when I post to the binary file from an html form saved to the same folder there's a popup that says, "You have chosen to open "schedule_payment" (the name of my binary) which is a: Binary File from: /home/barth/cppexperiments
Would you like to save this file?"

When I save I get another popup indicating schedule_payment was downloaded. (NO OUTPUT) My only other option is cancel. Either way, my code doesn't output html as I expect it to.

Does the program have to be a cgi-script in order to output a webpage? Otherwise, why won't my program generate the one specified?

Here's the HTML & code:

Code:
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

</head><body><form action="schedule_payment" method="post">

<basefont size="3">

Payee: <input name="payee" type="text"><br>

Description: <input name="description" type="text"><br><br>

Frequency:<br>
<input name="frequency" value="weekly" type="radio"> Weekly <br>

<input name="frequency" value="bi-weekly" type="radio"> Bi-weekly <br>
<input name="frequency" value="semi-monthly" type="radio"> Semi-monthly<br>
<input name="frequency" value="monthly" type="radio"> Monthly<br>
<input name="frequency" value="quarterly" type="radio"> Quarterly<br>
<input name="frequency" value="semi-annually" type="radio"> Semi-annually<br>
<input name="frequency" value="annual" type="radio"> Annually<br><br>

Type Payment:<br>
<input name="flux" value="fixed" type="radio"> Fixed <br>
<input name="flux" value="variable" type="radio"> variable <br><br>

Amount of payment: (leave blank if "variable" is selected above) <input name="amount" type="text"><br>
<pre><font face="Times New Roman" size="3">Date of first scheduled payment: <input name="firstpayment" type="text">  (mm/dd/yyyy)</font><br></pre>

<input value="Submit" type="submit">



</form> </body></html>
Code:
#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <cstdio>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stddef.h>

using namespace std;

int main()
{
  char* billschedContentLength = getenv("CONTENT_LENGTH");
  char* billschedBuffer;
  int nContentLength = atoi(billschedContentLength);
  

  billschedBuffer = (char*) malloc(nContentLength+1);  // allocate a buffer
  memset(billschedBuffer, 0, nContentLength+1);  // zero it out

  fread(billschedBuffer,1,nContentLength,stdin);  // get data

   cout << "Content-type: text/html" << endl << endl
   << "<html>" << endl
   << "<body>" << endl
   << "<p>" << endl
   
   <<billschedBuffer<<""<<endl

   << endl
   << "" << endl
   << "" << endl
   << "" ;


  free(billschedBuffer);

  return 0;

}
 
Old 07-07-2010, 12:46 PM   #49
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by MTK358 View Post
At the CPU level, both instructions and data are all just bytes in memory. A certain value can be interpreted as a signed integer, integer, character, floating point number, CPU instruction, etc. only depending on how it's used.
My point is that there exist CPU architectures that natively deal with BCDs. I.e. the architectures have machine commands that perform operations on BCDs.
 
Old 07-07-2010, 12:48 PM   #50
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by Sergei Steshenko View Post
My point is that there exist CPU architectures that natively deal with BCDs. I.e. the architectures have machine commands that perform operations on BCDs.
I don't understand, what I said wasn't meant to counter your argument that some CPUs use BCD.
 
Old 07-07-2010, 12:50 PM   #51
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by bluegospel View Post
...
Does the program have to be a cgi-script in order to output a webpage? Otherwise, why won't my program generate the one specified?
...

You are doing it wrong methodologically. You first need to call your program stand-alone providing it with the needed inputs and verifying that it produces the required outputs.

There is absolutely no place for any kind of pop-up windows in the suggested verification scenario.
 
Old 07-07-2010, 12:54 PM   #52
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
When you refer to "cpu architecture" do you mean the processor by itself (its on-board cache & registers included), or also the processor's platform to some extent (the machine's rom, busses, etc.)? Does the physical processor have built in instructions, or are they mostly or in part external?
 
Old 07-07-2010, 12:58 PM   #53
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
So I should edit the program such that it doesn't depend on input from a webpage, providing all the input directly, or via a shell prompt.
 
Old 07-07-2010, 01:05 PM   #54
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by bluegospel View Post
When you refer to "cpu architecture" do you mean the processor by itself (its on-board cache & registers included), or also the processor's platform to some extent (the machine's rom, busses, etc.)? Does the physical processor have built in instructions, or are they mostly or in part external?
All the instructions are internal to the CPU.
 
Old 07-07-2010, 01:09 PM   #55
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by bluegospel View Post
When you refer to "cpu architecture" do you mean the processor by itself (its on-board cache & registers included), or also the processor's platform to some extent (the machine's rom, busses, etc.)? Does the physical processor have built in instructions, or are they mostly or in part external?
No machine ROM/buses.

Physical processor does have built-in instructions, but look up on the WEB "CPU microcode".
 
Old 07-07-2010, 01:12 PM   #56
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by bluegospel View Post
So I should edit the program such that it doesn't depend on input from a webpage, providing all the input directly, or via a shell prompt.
You shouldn't edit the program. You should create test environment which imitates real world. E.g. if inputs are given to the program through 'argc', 'argv', give them on command line; if through environment variables, set environment variables first, etc.

I.e. you first need to understand how the program is connected to the real world - regardless of the language your program is written in.
 
Old 07-07-2010, 01:16 PM   #57
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Are they burned somewhere? Approximately how many instructions? I presume these all either send information to, or get information from, a peripheral or registers, and, or else, they perform some kind of operation on information in its registers, based on its instruction set & corresponding instructions from various programs.
 
Old 07-07-2010, 01:18 PM   #58
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by bluegospel View Post
Are they burned somewhere? Approximately how many instructions? I presume these all either send information to, or get information from, a peripheral or registers, and, or else, they perform some kind of operation on information in its registers, based on its instruction set & corresponding instructions from various programs.
http://en.wikipedia.org/wiki/Central_processing_unit .
 
Old 07-07-2010, 01:44 PM   #59
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Again, pardon my illiteracy. Are you saying there's always some way to execute your program, passing input to it in a way other than the way executed in run-time reality? So that, if input comes from an environment variable, I can set the environment variable manually and execute the program that way, or if from a call w/ arguments, I can somehow bypass executing the program its ordinary way, in such a way as to test it?
 
Old 07-07-2010, 01:52 PM   #60
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by bluegospel View Post
Again, pardon my illiteracy. Are you saying there's always some way to execute your program, passing input to it in a way other than the way executed in run-time reality? ...
For your kind of domain/activity - yes. Luckily, your program is single-threaded and non-real-time.
 
  


Reply

Tags
c++, executable, execute, form, program


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors, Errors, and more Errors (KDE 3.4.x GUI Errors) Dralnu Linux - Software 2 05-13-2006 08:30 AM
Qt errors devit Programming 1 02-09-2004 03:45 PM
Errors during filesystem check with one kernel while no errors with other kernel Potentials Linux - General 11 12-30-2003 04:24 AM
QMAIL errors errors.. YourForum Linux - Software 0 11-27-2003 12:30 PM
2 many errors wesley Linux - Newbie 1 08-02-2001 11:42 PM


All times are GMT -5. The time now is 07:06 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration