コード例 #1
0
ファイル: generate.c プロジェクト: AxlSckay/Ragnarok-OldTimes
void generate_page(char password[25], int sock_in, char *query, char *ip)
{
	char *page = get_param(query, 0);
	char *ppass = get_param(query, "password");


	if ( (ppass == 0) || (strcmp(password, ppass) != 0) )
	{
		web_send(sock_in, html_header("Enter your password"));
		web_send(sock_in, "<H1>NOT LOGGED IN!</H1><form action=\"/\" method=\"GET\">\n");
                web_send(sock_in, "Enter your password:<br>\n<input type=\"text\" name=\"password\">\n");
                web_send(sock_in, "<input type=\"submit\" value=\"Login\">\n");
	}
	else
	{


		//To make this simple, we will have a bunch of if statements
		//that then shoot out data off into functions.

	
		//The 'index'
		if ( strcmp(page, "/") == 0 )
			generate_notdone(sock_in, query, ip);


		//About page:
		if ( strcmp(page, "/about.html") == 0 )
			generate_about(sock_in, query, ip);

	
		//Test page:
		if ( strcmp(page, "/testing/") == 0 )
			generate_sample(sock_in, query, ip);

	}
}
コード例 #2
0
ファイル: about.c プロジェクト: AxlSckay/Ragnarok-OldTimes
void generate_about(int sock_in, char *query, char *ip)
{
//printf("%s", html_header("About"));
	web_send(sock_in, html_header("About"));
	web_send(sock_in, "<center>eAthena Web Server!</center>\n");	
}
コード例 #3
0
ファイル: server.c プロジェクト: KarolTx/MSP430-Emulator
int callback_emu ( struct lws *wsi,
		   enum lws_callback_reasons reason,
		   void *user, void *in, size_t len )
{
  static unsigned new_ws_port = 9001;
  char port_str[100] = {0};
  
  switch (reason) {
    case LWS_CALLBACK_PROTOCOL_INIT: {
      ws = wsi;
      break;
    };

    case LWS_CALLBACK_SERVER_WRITEABLE: {
      pid_t pid;
      sprintf(port_str, "%u", new_ws_port);
  
      // Child (pty)     
      if( !(pid = fork()) ) {     
	printf("Child: Got pid #%u\n", pid);

	char * const args[] = {
	  "nice", "-20", "./MSP430", port_str,
	  //"./MSP430", port_str,
	  //"gdb", "-ex", "run", "--args", "./MSP430", port_str,
	  NULL
	};

	setpgid(0, 0);     
	execvp(args[0], args);
	exit(1);                
      }

      // Parent 
      printf("Parent: Got pid #%u\n", pid);
      usleep(1000);
    
      web_send(port_str);
      ++new_ws_port;

      lws_close_reason(wsi, 0, NULL, 0);

      break;
    };

    case LWS_CALLBACK_ESTABLISHED: {
      puts("connection established");

      lws_callback_on_writable(wsi);
      break;
    }

    default: {
      printf("Some other thing: %d\n", reason); 
      break;
      
      ws = wsi;
    }
  }
  
  return 0;
}