Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d02f901
Adding initial files
bboll Sep 6, 2013
50bf992
Merge branch 'bboll' of https://github.com/Capstone-F13/CS-1-Web into…
bboll Sep 6, 2013
6912a85
Adding initial files
ofan Sep 11, 2013
d61811a
Changed databaseConnect.php to work locally
bboll Sep 14, 2013
0908850
Implemented max submit check
bboll Sep 18, 2013
87b4159
Fixed to work with infinite attempts
bboll Sep 18, 2013
3f3a17a
Fixed to show max submits if not null (infinite)
bboll Sep 18, 2013
238eab8
Added infinite submissions option when creating assignment
bboll Sep 18, 2013
13029dd
F
bboll Sep 20, 2013
965cfd2
Merge pull request #2 from Capstone-F13/tshanks
bboll Sep 23, 2013
9ca44a4
Reverted database connection credentials
bboll Sep 23, 2013
2b7870b
Merge remote-tracking branch 'origin/master' into zfeng
ofan Sep 27, 2013
30ea29f
Remove binaries
ofan Sep 27, 2013
44fb05f
Add makefile for debugger interface etc
ofan Sep 27, 2013
9f2fa65
Remove binaries
ofan Sep 27, 2013
7d86d98
Remove binaries
ofan Sep 27, 2013
4966988
Clean dSYM folders
ofan Sep 27, 2013
5a1f784
Remove temp files
ofan Sep 27, 2013
d23a56b
Auto-clean all dSYM folders
ofan Sep 27, 2013
b3f44fa
Fix paths
ofan Sep 27, 2013
e6879fd
Added updated debugger/pipe/interface files
bboll Oct 6, 2013
30a7db5
Merge pull request #6 from Capstone-F13/zfeng
bboll Oct 7, 2013
d622f19
Merging
bboll Oct 7, 2013
f764d58
Removed ER diagrams and examples
bboll Oct 7, 2013
a29ee96
Removed log files
bboll Oct 7, 2013
86e7663
Added files
Oct 16, 2013
32f7825
Create Course needs to be added
Oct 16, 2013
f7d9d74
Finished up add course page
Oct 21, 2013
7fc5f11
Updated from master
bboll Oct 24, 2013
a8b94ba
blah blah blah
Oct 28, 2013
9f5bdca
adding unit-test
Nov 5, 2013
8bb26ae
Latest update
Nov 18, 2013
348ebe9
Merge branch 'courseadmin' of https://github.com/Capstone-F13/CS-1-We…
Nov 18, 2013
027abba
Adding Instructor UnitTest REVISED
Nov 20, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed debugger/interface
Binary file not shown.
36 changes: 26 additions & 10 deletions debugger/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <string.h>
#define BUFFSIZE 8192
#define MaxPipeName 100
#define logdir "/home/ruttan/classes/capstone/debugger/"
#define numDbgArgs 5
#define logdir "/var/www/html/Web/debugger"#define numDbgArgs 5
#define ArgSize 30

#define prompt ">>>"
//#define prompt "(gdb)"
pid_t child_pid;
char buf[BUFFSIZE],work_file[MaxPipeName];
FILE * fdtoFILE;
Expand All @@ -29,7 +29,7 @@ void catch_sigint(int sig_num)
/* re-set the signal handler again to catch_int, for next time */
signal(SIGINT, catch_sigint);
kill(child_pid,1);
fprintf(fdtoFILE,"got a sigint signal\n");
fprintf(fdtoFILE,"Interface:got a sigint signal\n");
fflush(fdtoFILE);
sleep(1);
exit(1);
Expand Down Expand Up @@ -80,11 +80,17 @@ pid_t launch_debugger(char * argv[],int pipefd[2]){
}

void make_args(char * id,char * argv[]){
argv[0]="/usr/bin/python3";

//pthon flags
argv[0]="/usr/bin/python";
argv[1]="-i";
argv[2]="-m";
argv[3]=work_file;
argv[4]=0;
argv[2]=0; //"-m";
argv[3]=0; //work_file;argv[4]=0;
/*
//gdb flags
argv[0]="/usr/bin/gdb";
argv[1]=0;
*/
}

int main (int argc, char ** argv) {
Expand All @@ -105,6 +111,7 @@ int main (int argc, char ** argv) {
perror("usage: debugger idcode");
exit(1);
}

//create input pipe from webserver
sprintf(fromServer,"%s%s%s",logdir,"OUT",argv[1]);
unlink(fromServer);
Expand Down Expand Up @@ -137,18 +144,27 @@ int main (int argc, char ** argv) {

int i;
char c;
int sid;
sid=setsid();
if (sid < 0){
fprintf(fdtoFILE,"failed to change sid\n");
fflush(fdtoFILE);
}
make_args(argv[1],nargv);
child_pid=launch_debugger(nargv,pipefd);
fprintf(fdtoFILE,"session id=%d\n",sid);
fflush(fdtoFILE);
fprintf(fdtoFILE,"child_pid=%d\n",child_pid);
fflush(fdtoFILE);
setpgid(0, 0);

fprintf(fdtoFILE,"---starting---\n");
fflush(fdtoFILE);


while(1){
line[0]=0;
while (!strstr(line,">>>") && !strstr(line,"...")){
while (!strstr(line,prompt) && !strstr(line,"...")){
if ((n=read(pipefd[0],line,BUFFSIZE))){
if (!n) {
fprintf(fdtoFILE,"pipe fd[0] closed");
Expand All @@ -159,7 +175,7 @@ int main (int argc, char ** argv) {
line[n]=0;
//if n=BUFFSIZE...
}
fprintf(fdtoFILE,"p-%s",line);
fprintf(fdtoFILE,"; p->%s",line);
fflush(fdtoFILE);
if (write(fdtoWeb,line,n) != n) {
perror("fdtoWeb write error");
Expand Down
228 changes: 228 additions & 0 deletions debugger/interface.c.BACKUP.772.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
#include <stdio.h>
#include <sys/stat.h> /* for mkfifo */
#include <sys/types.h> /* for open */
#include <sys/stat.h> /* for open */
#include <fcntl.h> /* for open */
#include <unistd.h> /* for write */
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#define BUFFSIZE 8192
#define MaxPipeName 100
<<<<<<< HEAD
#define logdir "/var/www/html/Web/debugger/"
=======
#define logdir "log/"
>>>>>>> master
#define numDbgArgs 5
#define ArgSize 30
#define prompt ">>>"
//#define prompt "(gdb)"
pid_t child_pid;
char buf[BUFFSIZE],work_file[MaxPipeName];
FILE * fdtoFILE;

void catch_sigpipe(int sig_num)
{
/* re-set the signal handler again to catch_int, for next time */
signal(SIGPIPE, catch_sigpipe);
fprintf(fdtoFILE,"got a signal\n");
fflush(fdtoFILE);
}
void catch_sigint(int sig_num)
{
/* re-set the signal handler again to catch_int, for next time */
signal(SIGINT, catch_sigint);
kill(child_pid,1);
fprintf(fdtoFILE,"Interface:got a sigint signal\n");
fflush(fdtoFILE);
sleep(1);
exit(1);
}

pid_t launch_debugger(char * argv[],int pipefd[2]){
int stdio[3];
pid_t child_pid;
int pipefd0[2],pipefd1[2];
pipe(pipefd0);
if(pipe(pipefd0) == -1) {
perror("Pipe 0 creation failed");
exit(1);
}
pipe(pipefd1);
if(pipe(pipefd1) == -1) {
perror("Pipe 1 creation failed");
exit(1);
}
//create function to setup pipes fork and exec
pipefd[0]=pipefd0[0];
pipefd[1]=pipefd1[1];
stdio[0]=dup(STDIN_FILENO);
stdio[1]=dup(STDOUT_FILENO);
stdio[2]=dup(STDERR_FILENO);
dup2(pipefd1[0],STDIN_FILENO);
dup2(pipefd0[1],STDOUT_FILENO);
dup2(pipefd0[1],STDERR_FILENO);
switch (child_pid=fork()){
case -1:
perror("Could not fork debugger");
exit(1);
break;
case 0:
if (execvp(argv[0],argv)==-1){
perror("exec failed");
exit(1);
}
default:
//after fork in parent.
dup2(stdio[0],STDIN_FILENO);
dup2(stdio[1],STDOUT_FILENO);
dup2(stdio[2],STDERR_FILENO);
close(pipefd1[0]);
close(pipefd0[1]);
}
return(child_pid);
}

void make_args(char * id,char * argv[]){

//pthon flags
argv[0]="/usr/bin/python";
argv[1]="-i";
argv[2]=0; //"-m";
argv[3]=0; //work_file;argv[4]=0;
/*
//gdb flags
argv[0]="/usr/bin/gdb";
argv[1]=0;
*/
}

int main (int argc, char ** argv) {
int n;
char * nargv[numDbgArgs];
int fdtoWeb,fdfrmWeb,fdtoDbg,fdfrmDgb,pipefd[2];
char line[BUFFSIZE],toServer[MaxPipeName],fromServer[MaxPipeName];
sprintf(buf,"%s%s%s",logdir,"LOG",argv[1]);
unlink(buf);
fdtoFILE=fopen(buf,"w");
fprintf(fdtoFILE,"testing file output\n");
sprintf(work_file,"%s%s%s",logdir,"FILE",argv[1]);
unlink(work_file);

signal(SIGPIPE, catch_sigpipe);
signal(SIGINT, catch_sigint);
if ((argc < 2 )|| (argc >=3)){
perror("usage: debugger idcode");
exit(1);
}

//create input pipe from webserver
sprintf(fromServer,"%s%s%s",logdir,"OUT",argv[1]);
unlink(fromServer);

if (-1 == mkfifo(fromServer,S_IRWXU)) {
perror("Error, could not make fifo\n");
}

//create output pipe to webserver
sprintf(toServer,"%s%s%s",logdir,"IN",argv[1]);
unlink(toServer);

if (-1 == mkfifo(toServer,S_IRWXU)) {
perror("Error, could not make fifo\n");
}
if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) {
perror("cannot open fifo from server");
exit(1);
}
if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) {
perror("cannot open fifo to server");
exit(1);
}
//create pipes to debugger

if(pipe(pipefd) == -1) { //perhaps pipe(pipefd,O_NONBLOCK)
perror("Pipe 1 creation failed");
exit(1);
}

int i;
char c;
int sid;
sid=setsid();
if (sid < 0){
fprintf(fdtoFILE,"failed to change sid\n");
fflush(fdtoFILE);
}
make_args(argv[1],nargv);
child_pid=launch_debugger(nargv,pipefd);
fprintf(fdtoFILE,"session id=%d\n",sid);
fflush(fdtoFILE);
fprintf(fdtoFILE,"child_pid=%d\n",child_pid);
fflush(fdtoFILE);

fprintf(fdtoFILE,"---starting---\n");
fflush(fdtoFILE);


while(1){
line[0]=0;
while (!strstr(line,prompt) && !strstr(line,"...")){
if ((n=read(pipefd[0],line,BUFFSIZE))){
if (!n) {
fprintf(fdtoFILE,"pipe fd[0] closed");
fflush(fdtoFILE);
exit(1);
}
//line[n++]='@';
line[n]=0;
//if n=BUFFSIZE...
}
fprintf(fdtoFILE,"; p->%s",line);
fflush(fdtoFILE);
if (write(fdtoWeb,line,n) != n) {
perror("fdtoWeb write error");
fprintf(fdtoFILE,"fdtoWeb write error\n");
fflush(fdtoFILE);

}

}

if ((n=read(fdfrmWeb,line,BUFFSIZE))){
line[n]=0;
fprintf(fdtoFILE,"%d-%s%s",n,"w-",line);
fflush(fdtoFILE);
if (write(pipefd[1],line,n) != n) {
perror("pipefd[1] write error");
}

}
else{
printf("empty read\n");
close(fdtoWeb);
close(fdfrmWeb);
n=0;
if ((fdfrmWeb = open(fromServer,O_RDONLY)) == -1) {
perror("cannot open fifo from server");
exit(1);
}

if ((fdtoWeb = open(toServer,O_WRONLY)) == -1) {
perror("cannot open fifo to server");
exit(1);
}
line[0]='\n';
if (write(pipefd[1],line,1) != 1) {
perror("pipefd[1] write error");
}

}

}

exit(0);
}


Loading