CMPS-3350 Software Engineering Lab-4

The components of this lab are:

Step 1:

Do the coding of your C++ program for this lab on your local Desktop.

At the end of lab class, your program files must be on Odin.

xlab4.c
mylab4.cpp
Makefile

in your 3350/4/ directory on Odin.

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


Step 2:
Create a C++ program using the code sample at:

/home/fac/gordon/p/3350/code/lab4/xlab4.c

Important:
Save this program immediately to your Odin 3350/4/ folder please.

No changes or fixes should be applied to the C program.

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

Note:
You are refactoring a C program into the C++ language.

Copy the C program to a C++ program named 3350/4/mylab4.cpp

Complete the rest of the Makefile.
Build your programs with make.

Step 4:
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.

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. Not both. . 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.

Step 5:
Run lab4 with the following parameters...

example:
./lab4 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 HTTP program, always check the robots.txt file, and follow the instructions for that site.

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

You should see a run-time error.

This is a bug in the program.
Fix this bug.

There are several ways to fix the bug.
Try to fix the bug in the best way possible.

If you find help online, show the URL and other information in a comment
just above the code that contained the bug.


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

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

where username is your own Odin account name.

If you have any questions about the path to your lab4.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 lab4 program and contact your PHP file.

like this... except insert your own username

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

Step 9:

Use a web browser to look at your php file

    like this...

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


Step 10:

Make some minor changes to your lab4.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=\"mydiagram4.gif\"/>";
?>

Required:
 1. Create a file named mydiagram4.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 mydiagram4.gif

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

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

       The <img> tag is in your php file.


Step 11:

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

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

Then try this...

./lab4 odin.cs.csub.edu /~myname/3350/lab4.php?param=345

You should see the appropriate data returned.


Step 12:

Draw a Diagram!

Draw a Diagram to show the components of your system, and how they interact with each other. 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.

Files to be collected from Odin server at 9:50am
3350/4/xlab4.c
3350/4/mylab4.cpp
3350/4/Makefile
public_html/3350/lab4.php
public_html/3350/mydiagram4.gif


Your instructor will contact your PHP file, with various parameters.

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