Beispiel #1
0
 void NNTPServerHandler::Greet()
 {
   if(PostingAllowed()) 
     QueueLine("200 Posting allowed");
   else
     QueueLine("201 Posting not allowed");
 }
Beispiel #2
0
 void NNTPServerHandler::HandleCommand(const std::deque<std::string> & command)
 {
   auto cmd = command[0];
   std::transform(cmd.begin(), cmd.end(), cmd.begin(),
                  [](unsigned char ch) { return std::toupper(ch); });
   std::size_t cmdlen = command.size();
   std::cerr << "handle command [" << cmd << "] " << (int) cmdlen << std::endl;
   if (cmd == "QUIT") {
     Quit();
     return;
   } else if (cmd == "MODE" ) {
     if(cmdlen == 1) {
       // set mode
       SwitchMode(command[1]);
     } else if(cmdlen) {
       // too many arguments
     } else {
       // get mode
     }
     
   } else {
     // unknown command
     QueueLine("500 Unknown Command");
   }
 }
Beispiel #3
0
 void NNTPServerHandler::HandleLine(const std::string &line)
 {
   if(m_state == eStateReadCommand) {
     std::deque<std::string> command;
     std::istringstream s;
     s.str(line);
     for (std::string part; std::getline(s, part, ' '); ) {
         if(part.size()) command.push_back(std::string(part));
     }
     if(command.size())
       HandleCommand(command);
     else
       QueueLine("501 Syntax error");
   }
 }
Beispiel #4
0
 void NNTPServerHandler::Quit()
 {
   std::cerr << "quitting" << std::endl;
   m_state = eStateQuit;
   QueueLine("205 quitting");
 }
Beispiel #5
0
int Main(int argc, char *argv[]){

  LineArg *la = malloc(sizeof(LineArg));
  GLuint VBO = 0;
  GLsizei offsets = 0;
  SDL_Event event;
  SDL_Window *screen = NULL;
  int live = 1;

  SDL_Init(SDL_INIT_VIDEO);
  {
    void **view = MakeWindow(800, 450);
    #ifdef _WIN32
    LoadGLFunctions();
    #endif
    screen = view[0];
  }
  glEnableClientState(GL_COLOR_ARRAY);
  glEnableClientState(GL_VERTEX_ARRAY);
  glGenBuffers(1, &VBO);
  assert(VBO!=0);

  glBindBuffer(GL_ARRAY_BUFFER, VBO);
  {
    float zero = 0.0;
    GLubyte bufferData[] = {
    255, '\0', '\0', 255, //Color1
    255, '\0', '\0', 255, //Color2
    '\0', '\0', '\0', '\0', //X1
    '\0', '\0', '\0', '\0', //Y1
    '\0', '\0', '\0', '\0', //X2
    '\0', '\0', '\0', '\0', //Y2
    };

    memcpy(bufferData+8, &zero, 4);
    memcpy(bufferData+12, &zero, 4);
    memcpy(bufferData+16, &zero, 4);
    memcpy(bufferData+20, &zero, 4);

    glBufferData(GL_ARRAY_BUFFER, sizeof(bufferData), bufferData, GL_DYNAMIC_DRAW);
  }

  la->Buffer = VBO;

  glBindBuffer(GL_ARRAY_BUFFER, 0);

  SetCoordinateData(VBO, 8);

  glFinish();

  InitDrawQueue();

  while(live){

    /////
    // Be a nice program and handle events.
    //
    while(SDL_PollEvent(&event)){
      switch(event.type){
      case (SDL_QUIT):
        live = 0;
        break;
      case (SDL_MOUSEMOTION):
        QueueUpdateMousePosition(event.motion.x, event.motion.y);
        break;
      }

    }
    QueueLine(la);
    QueueFlipScreen(screen);

    IncEngineFrame();

    {
      int diff = GetEngineFrame()-GetRenderFrame();

      assert(diff>=0);

      if(GetEngineFrame()%32){
        sprintf(WindowTitle, "%s%-4i\t - %-8i\t / %-8i", WindowTitleBase, diff, GetRenderFrame(), GetEngineFrame());
      }

      SDL_SetWindowTitle(screen, WindowTitle);

      while(diff>FrameFloat){
        diff = GetEngineFrame()-GetRenderFrame();
        SDL_Delay(0x10);
      }
    }
  }

  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_VERTEX_ARRAY);
  CloseDrawQueue();

  return EXIT_SUCCESS;
}