Example #1
0
 SideBar::SideBar(SideBar* toClone) {
   SideBar(1, toClone->previousSBItem, 0);
   debugState= toClone->debugState;
   previousSBItem= toClone->previousSBItem;
   nextSBItem = toClone->nextSBItem;
 }
Example #2
0
int main(int argc, char *argv[])
{		
	// Variables	
	// Default CSS
	char CSSFILE[12]="style.css";

	// Pointers to filenames
	char *infofilename = INFO;
	char *logfilename = LOG;
	
	// Handle arguments
	int opt;
	while ((opt=getopt_long(argc, argv, "dvhm", main_options, NULL)) != EOF)
	{
		switch (opt)
		{
		case 'h':
			help();
			exit(0);
		case 'd':
			debug();
			exit(0);
		case 'v':
			printf("%s (v%s) by MS3FGX\n", APPNAME, VERSION);
			exit(0);
			break;
		case 'm':
			strcpy(CSSFILE, "mobile.css");
			mobile = 1;
			break;
		default:
			printf("Unknown option.\n");
			exit(0);
		}
	}
	
	// Bail out if we are root, except on WRT
	#ifndef OPENWRT
	if(getuid() == 0)
	{
		syslog(LOG_ERR,"CGI module refusing to run as root!");
		printf("Server attempting to run CGI module as root, bailing out!\n");
		printf("Check your web server configuration and try again.\n");
		exit(1);
	}
	#endif

	// Read in environment variable
	// Comment this to fix compiler warning until ready to implement
	//char* env_string;
	//env_string=getenv("QUERY_STRING");

	// Print HTML head
	print_header(CSSFILE);
	//print_html(CSSFILE);
	
	// Start container div
	if (!mobile)
		puts("<div id=\"container\">\n");

	// Open files
	if ((infofile = fopen(infofilename, "r")) == NULL)
	{
		syslog(LOG_ERR,"Error while opening %s!",infofilename);
		puts("<div id=\"content\">");
		printf("Error while opening %s!\n",infofilename);
		puts("</body></html>");
		exit(1);
	}
	
	if ((logfile = fopen(logfilename, "r")) == NULL)
	{
		syslog(LOG_ERR,"Error while opening %s!",logfilename);
		puts("<div id=\"content\">");
		printf("Error while opening %s!\n",logfilename);
		puts("</body></html>");
		exit(1);
	}
	
	// Draw sidebar\topbar
	read_log();
	if (!mobile)
		SideBar();
	else
		TopBar();
	
	// Content window
	puts("<div id=\"content\">");
	
	if (device_index > 0)
	{
		// Print results
		setup_table();
		print_devices();
		puts("</table>\n");
	}
	
	// Close content, body, and HTML
	puts("</div></body></html>");
	
	// Close files and exit
	shut_down();
	return 0;
}