#include #include #include struct camdata { char host[80]; int port; char filename[80]; }; struct camtype { struct camdata cd[2]; char name[40]; int type; // 0 - normal. 1 - always default (slideshow, etc) }cams[15]; print_cam(int type, int browser, char *host, int port, char *filename, int cam) { if((browser == 0 || type == 1) && cam != 9) { printf("\n"); printf("\n"); } else if(cam != 9) { printf("\n",host,port,filename); } else { printf("\n",host,port,filename); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); } } print_popup(int cam) { printf("Popup this cam
\n",cam,cam,cam); } print_message(int cam) { print_popup(cam); if(cam == 1) { printf("\"ListenListen Live to the office.
\n"); printf("Click on the picture to center the camera on that spot.
\n"); printf("\n"); printf("Capture this Pic.\n"); printf("\n"); printf("
\n"); printf("\n"); printf("\n"); printf("
\n"); } if(cam == 3) { printf("\n"); printf("Capture this Pic.\n"); } if(cam == 4) { printf("\n"); printf("Capture this Pic.\n"); } if(cam == 5) { printf("\n"); printf("Capture this Pic.\n"); } if(cam == 8) { printf("\n"); printf("Capture this Pic.\n"); } if(cam == 2) { printf("\n"); printf("Capture this Pic.\n"); printf("Driving Instructions. Lock
\n"); printf("If you see static, the car is broken. Don't ask when it will be fixed.
\n"); printf("\n"); printf("\n"); printf("\n"); printf("
\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("
\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("
\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("
\n"); printf("\n"); printf("\n"); printf("\n"); } if(cam == 7) { printf("This slideshow is NOT live. It shows events recorded on a previous day.\n"); } if(cam == 9) { printf("Large Image. \n"); printf("Hover the mouse over different rooms to change the cam pic.\n"); } } print_hidden(int value) { printf("%d",value); } parse_string(char *buf, int *cam, int *browser) { int x,y,z; int size; if(strcmp(buf,"") == 0) return(0); x = 0; y = 0; z = 0; size=strlen(buf); while(x < size) { if(buf[x] == 'a') { *browser = atoi(&buf[x+2]); } if(buf[x] == 'b') { *cam = atoi(&buf[x+2]); } if(buf[x] == 'c') { *cam = atoi(&buf[x+1]); break; } if(buf[x] == 's') { *browser = atoi(&buf[x+1]); break; } x++; } } config_cams() { strcpy(cams[1].name,"Office"); cams[1].type = 0; strcpy(cams[1].cd[0].host,"206.54.177.102"); cams[1].cd[0].port = 80; strcpy(cams[1].cd[0].filename,""); strcpy(cams[1].cd[1].host,"206.54.177.102"); cams[1].cd[1].port = 81; strcpy(cams[1].cd[1].filename,""); strcpy(cams[2].name,"RC"); cams[2].type = 0; strcpy(cams[2].cd[0].host,"206.54.177.110"); cams[2].cd[0].port = 82; strcpy(cams[2].cd[0].filename,"/singleframe.jpg"); strcpy(cams[2].cd[1].host,"206.54.177.110"); cams[2].cd[1].port = 82; strcpy(cams[2].cd[1].filename,""); strcpy(cams[3].name,"FD"); cams[3].type = 0; strcpy(cams[3].cd[0].host,"206.54.177.100"); cams[3].cd[0].port = 80; strcpy(cams[3].cd[0].filename,""); strcpy(cams[3].cd[1].host,"206.54.177.100"); cams[3].cd[1].port = 81; strcpy(cams[3].cd[1].filename,""); strcpy(cams[4].name,"LR"); cams[4].type = 0; strcpy(cams[4].cd[0].host,"206.54.177.104"); cams[4].cd[0].port = 80; strcpy(cams[4].cd[0].filename,"/singleframe.jpg"); strcpy(cams[4].cd[1].host,"206.54.177.104"); cams[4].cd[1].port = 80; strcpy(cams[4].cd[1].filename,""); strcpy(cams[5].name,"Den"); cams[5].type = 0; strcpy(cams[5].cd[0].host,"206.54.177.103"); cams[5].cd[0].port = 80; strcpy(cams[5].cd[0].filename,""); strcpy(cams[5].cd[1].host,"206.54.177.103"); cams[5].cd[1].port = 81; strcpy(cams[5].cd[1].filename,""); strcpy(cams[7].name,"Slideshow"); cams[7].type = 1; strcpy(cams[7].cd[0].host,"206.54.177.105"); cams[7].cd[0].port = 80; strcpy(cams[7].cd[0].filename,"/slideshow.jpg"); strcpy(cams[7].cd[1].host,"206.54.177.102"); cams[7].cd[1].port = 81; strcpy(cams[7].cd[1].filename,""); strcpy(cams[8].name,"Lab"); cams[8].type = 0; strcpy(cams[8].cd[0].host,"206.54.177.110"); cams[8].cd[0].port = 81; strcpy(cams[8].cd[0].filename,"/singleframe.jpg"); strcpy(cams[8].cd[1].host,"206.54.177.110"); cams[8].cd[1].port = 81; strcpy(cams[8].cd[1].filename,""); strcpy(cams[10].name,"Map"); cams[10].type = 0; strcpy(cams[10].cd[0].host,"206.54.177.102"); cams[10].cd[0].port = 80; strcpy(cams[10].cd[0].filename,""); strcpy(cams[10].cd[1].host,"206.54.177.102"); cams[10].cd[1].port = 81; strcpy(cams[10].cd[1].filename,""); } print_newiconcell(int browser, int cam, int currentcam) { printf("\n"); if(currentcam == cam) printf("\n"); else printf("\n"); printf(" \n",browser,cam,cam); printf(" \n",cam,cam,cam,cam); printf(" \n"); printf("\n"); } print_mapcell(int browser, int cam) { printf("\n"); printf(" \n",browser,cam,cam); printf(" \n",cam); printf(" \n"); printf("\n"); } print_iconcell(int browser, int cam) { printf("\n"); printf(" \n",browser,cam,cam); printf(" \n",cam); printf(" \n"); printf("\n"); } print_icons(int browser,int cam) { printf("\n"); printf("OfficeRC CARFront DoorLiving Room\n"); printf(" \n"); printf("\n"); print_newiconcell(browser,1,cam); print_newiconcell(browser,2,cam); print_newiconcell(browser,3,cam); print_newiconcell(browser,4,cam); printf("\n"); printf("\n"); printf("DenLabSlideshowMap\n"); printf(" \n"); printf("\n"); print_newiconcell(browser,5,cam); print_newiconcell(browser,8,cam); print_newiconcell(browser,7,cam); print_mapcell(browser,9); printf("\n"); } print_ms(int number, char *alttag) { int x; char name[30]; sprintf(name,"ms%d",number); printf("\n"); printf(" \"%s\"\n",alttag,name); printf("\n"); } print_mlamp(int number,char *alttag) { char onscript[30],offscript[30],name[30]; int x; if(number < 0) x = -number; else x = number; if(number == 0) { sprintf(onscript,"lampon.cgi"); sprintf(offscript,"lampoff.cgi"); sprintf(name,"lamp%d",x); } else { sprintf(onscript,"X10lampon%d.cgi",number); sprintf(offscript,"X10lampoff%d.cgi",number); sprintf(name,"lamp%d",x); } printf(" \n"); printf(" \"%s\"\n",alttag,name); printf(" \n"); } print_nlamp(int number,char *alttag,int cam1, int cam2,int currentcam) { char onscript[30],offscript[30],name[30]; int x; if(number < 0) x = -number; else x = number; if(number == 0) { sprintf(onscript,"lampon.cgi"); sprintf(offscript,"lampoff.cgi"); sprintf(name,"lamp%d",x); } else { sprintf(onscript,"X10lampon%d.cgi",number); sprintf(offscript,"X10lampoff%d.cgi",number); sprintf(name,"lamp%d",x); } if(currentcam == cam1 || currentcam == cam2) printf(" \n"); else printf(" \n"); printf(" \"%s\"\n",alttag,name); if(number >= 0) { printf(" ON\n",onscript); printf("
\n"); printf(" OFF\n",offscript); } else printf("ON
OFF
\n"); printf(" \n"); } print_normal_lamps(int cam) { printf(" \n"); printf(" \n"); printf(" \n"); printf("\n"); printf("\n"); print_nlamp(0,"Observe from the office",1,0,cam); print_nlamp(4,"Observe from the Living Room",4,0,cam); print_nlamp(5,"Observe from the Lab",8,1,cam); print_nlamp(2,"Observe from the Living Room",4,0,cam); printf("\n"); printf(" \n"); printf(" \n"); printf("\n"); printf("\n"); print_nlamp(13,"Observe from the Den",5,0,cam); print_nlamp(14,"Observe from the Den",5,0,cam); print_nlamp(8,"Observe from the Living Room. You can't see it directly, but you can see the light",4,0,cam); print_nlamp(3,"Observe from the Living Room. You can't see it directly, but you can see the light",4,0,cam); printf("\n"); printf(" \n"); printf(" \n"); printf("\n"); printf("\n"); print_nlamp(-7,"Observe from the Den",0,0,cam); print_nlamp(-6,"Observe from the Den",3,0,cam); print_ms(1,"Turns on the porch lamp and adds an entry to the motion sensor logs."); print_ms(2,"Turns on the second living room lamp"); printf("\n"); printf("
LAMPS
Office LampXmas Tree LightsLab LampFibre Optic Flower
Plasma BallLava LampLiving Room Lamp #1Living Room Lamp #2
Xmas TreePorch LampPorch SensorLiving Room Sensor
\n"); } print_minimal_lamps() { printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf(" \n"); printf("\n"); printf("\n"); print_mlamp(0,"Observe from the office"); print_mlamp(4,"Observe from the Living Room"); print_mlamp(5,"Observe from the Lab"); print_mlamp(2,"Observe from the Living Room"); print_mlamp(13,"Observe from the Den"); print_mlamp(14,"Observe from the Den"); print_mlamp(8,"Observe from the Living Room. You can't see it directly, but you can see the light"); print_mlamp(3,"Observe from the Living Room. You can't see it directly, but you can see the light"); print_mlamp(-7,"Observe from the Den"); print_mlamp(-6,"Observe from the Den"); print_ms(1,"Turns on the porch lamp and adds an entry to the motion sensor logs."); print_ms(2,"Turns on the second living room lamp"); printf("\n"); printf("
LAMPS
OfficeXTLLabFlowerBallLavaLR1LR2XTPorchPorchLR
\n"); } main(int argc, char **argv) { int x,y,z; int mode; int cam; int browser; char s[2000]; char input_string[2000]; config_cams(); mode = atoi(argv[1]); cam = 1; browser=0; strcpy(input_string,getenv("QUERY_STRING")); parse_string(input_string, &cam, &browser); if(mode == 0) { // printf("Query: .%s.\n",input_string); print_cam(cams[cam].type, browser,cams[cam].cd[browser].host,cams[cam].cd[browser].port,cams[cam].cd[browser].filename,cam); } if(mode == 1) { print_hidden(browser); } if(mode == 2) { print_hidden(cam); } if(mode == 3) { print_message(cam); } if(mode == 4) { print_icons(browser,cam); } if(mode == 5) { if(cam != 9) { print_normal_lamps(cam); } else { print_cam(cams[10].type, browser,cams[10].cd[browser].host,cams[10].cd[browser].port,cams[10].cd[browser].filename,10); print_minimal_lamps(); } } if(mode == 6) { printf("%s",cams[cam].name); } }