#include #include #include #include #include #include "cgic.h" int startRobotArmDeviceDriverSession(); int cgiMain() { if (startRobotArmDeviceDriverSession() == 1) { cgiHeaderLocation("/cgi-bin/robarm_control.cgi"); } else { cgiHeaderLocation("/RobotArmFailedLogin.html"); } return 0; } /** * @return 1 if the session was successfully started, 0 otherwise */ int startRobotArmDeviceDriverSession() { int file = open("/dev/robarm0", O_RDWR); char* msg; int len = strlen("start session")+1; size_t ret; if (file < 0) { return 0; } msg = (char*) malloc(sizeof(char)*len); strcpy(msg, "start session"); ret = write(file, msg, len); close(file); free(msg); if ((int) ret == len) { return 1; } else { // error return 0; } }