CMPS-3350 Software Engineering Lab-3

The components of this lab are:

Step 1:

Get the program for this lab.

Log on to Odin server
cd 3350
./lab-start.sh
cd 3
cp -p /home/fac/gordon/p/3350/code/3/lab3-ssl.c .

All of your work will be viewed and collected at lab end.
Programs must compile and files must be in-place.


Step 2:
Copy your C program to a C++ program of the same name.

cp lab3-ssl.c lab3-ssl.cpp

No changes or fixes should be applied to the C program.
Leave it in original condition.


Step 3:
Create a Makefile to build your C and C++ programs.

Look in the lab3-ssl.c program to see how to compile it.


Step 4:
In your C++ program,
Please fix all compile warnings and errors.

Enter a comment above the code related to each error or warning that you fix.
Include the original code that was fixed, in the comment.
Make the comment stand out a little.

For example:
//--------------------------------------------------------------------- //Fixed warning: deprecated conversion from string constant to 'char*' //Previous code was: // void getHost(char *hostname) //--------------------------------------------------------------------- void getHost(const char *hostname) { ... ... ...
Step 4a: . Style this program using the Linux Kernel Style Guide. Main features... . Apply perfect K&R bracing, spacing, and indenting. . No lines will wrap on an 80-character window. . Choose hard-tabs or spaces for indenting, but don't mix them. . One command per line-of-code. . Fix all compile warnings and errors.
Step 4 note: It is acceptable to fix a compile warning by using type-casting. Such as casting a function call argument. You may use C++ or C type casting for this.

Step 5:
Run your program with the following parameters...

example:
./lab3 www.google.com robots.txt

What you should see is a list of restrictions posted by the owner of the website you are accessing.

As you can see, accessing a website using automated means is restricted. When using your HTTPS program, always check the robots.txt file, and follow the instructions for that site. If your program looks in the wrong place, you will be banned.

Step 6:
Run lab3 with the following parameters...

You will see a small file containing restricted directories.

Run your program like this to see the CS Department page...

./a.out odin.cs.csub.edu . > x.html; firefox x.html

If you get this working, show it to Gordon or Monique.


Step 7:
Create a PHP program in your Odin public_html directory...
It will have this URL:

	https://cs.csub.edu/~username/3350/lab3.php

where username is your own Odin account name.

If you have any questions about the path to your lab3.php, please ask
about it during lab.


Here is a sample PHP program example...
<?php
echo "This is output from my php file.";
?>

Step 8:
Run your lab3 program and contact your PHP file.

like this... except insert your own username

    ./lab3 odin.cs.csub.edu  /~username/3350/lab3.php

Step 9:

Use a web browser to look at your php file

    like this...

    https://www.cs.csub.edu/~username/3350/lab3.php

Also try this command to see your own page in a browser...

./lab3 odin.cs.csub.edu /~username/3350/lab3.php > x.html; firefox x.html


Step 10:

Make some minor changes to your lab3.php program...

Allow the program to accept input:
	$param = $_GET['param'];

Process the $param variable in the PHP file.

Your new PHP program will look like this...
<?php
$param 
$_GET['param'];
echo 
"param is: " $param "<br>";
if (
$param == "hello") {
    echo 
"Hello student!<br>";
} else {
    
$num $param*3+4;
    echo 
"number:" $num "<br>";
}
echo 
"<br>";
echo 
"<img src=\"mydiagram3.gif\"/>";
?>

Required:
 1. Create a file named mydiagram3.gif for your diagram below.

    For image file conversion...

       You may use GIMP for file conversion.

       You may also use convert from the Odin command-prompt.

           example: $ convert image.jpg mydiagram3.gif

       Inside your <img> tag, apply a style element that will
       size your diagram to an appropriate size.

		   example: style="width:600px;height:auto;"

       The <img> tag is in your php file.


Step 11:

Run your lab3.cpp program and contact your PHP file like this...

./lab3 odin.cs.csub.edu /~username/3350/lab3.php?param=hello

Then try this...

./lab3 odin.cs.csub.edu /~myname/3350/lab3.php?param=456

You should see the appropriate data returned.


Step 12:

Draw a Diagram!
Draw a Diagram!
Draw a Diagram!

Draw a Diagram to show the components of the system that you programmed. Think about the flow of data through the system. How would a user interact with the system?

. Create an original diagram.
. Create a nice diagram.

Free online drawing tools: draw.io Gliffy

Note, this diagram will be viewed by your instructor and by the class.
Also, contacting your php file will display your diagram.
Your diagram may be a
   flow-chart
   data-flow-diagram
   use-case diagram
   etc.
Note:
Do not draw a diagram of the lab-3 assignment steps. That's not a system.
It's an assignment.

The program you wrote accepts input, contacts a server, gets data from a page
on the server, and returns that data to you. Show that on your diagram.

Files to be collected from Odin server at 9:50am
3350/3/lab3-ssl.c
3350/3/lab3-ssl.cpp
3350/3/Makefile
public_html/3350/lab3.php
public_html/3350/mydiagram3.gif

Copy your diagram image file to your web directory, so it will be displayed
when your web page (lab3.php) is viewed.