コード例 #1
0
ファイル: register_cgi.cpp プロジェクト: weiweikaikai/myhttpd
int main()
{
	int content_length = -1;
	char method[1024];
	char query_string[1024];
	char post_data[4096];
	memset(method, '\0', sizeof(method));
	memset(query_string, '\0', sizeof(query_string));
	memset(post_data, '\0', sizeof(post_data));

	printf("<html>\n");
        std::cout<<"<html>"<<std::endl;
	std::cout<<"<head>insert success</head>"<<std::endl;
	strcpy(method, getenv("REQUEST_METHOD"));
	if( strcasecmp("GET", method) == 0 ){
		strcpy(query_string, getenv("QUERY_STRING"));
		insert_message(query_string);//data1=XXX&data2=YYY;
	}else if( strcasecmp("POST", method) == 0 ){
		content_length = atoi(getenv("CONTENT_LENGTH"));
		int i = 0; 
		for(; i < content_length; i++ ){
			read(0, &post_data[i], 1);
		}
		post_data[i] = '\0';
	std::cout<<"<p>post_data"<<post_data<<"</p>\n";
		insert_message(post_data);//data1=XXX&data2=YYY;
	}else{
		//DO NOTHING
		return 1;
	}


    std::cout<<"</body>"<<std::endl;
	std::cout<<"</html>"<<std::endl;
}
コード例 #2
0
ファイル: x_window.cpp プロジェクト: KarlHegbloom/texmacs
static list<message>
insert_message (list<message> l, widget wid, string s, time_t cur, time_t t) {
  if (is_nil (l)) return list<message> (message (wid, s, t));
  time_t ref= l->item->t;
  if ((t-cur) <= (ref-cur)) return list<message> (message (wid, s, t), l);
  return list<message> (l->item, insert_message (l->next, wid, s, cur, t));
}
コード例 #3
0
ファイル: listener.c プロジェクト: swhatelse/URB_Final
void handle_normal(message_t* msg, node_t* sender) {
    if(!is_already_in(delivered, msg)) {
        // Message have not received yet
        if(!is_already_in(already_received, msg)) {
            GList* element = get_msg_from_list(not_received_yet, msg);
            // Check is the message is already referenced in the not_received yet
            if(element) {
                message_element_t* msg_elmnt = (message_element_t*)element->data;
                not_received_yet = g_list_remove(not_received_yet, msg_elmnt);
                already_received = g_list_append(already_received, msg_elmnt);
                add_ack(msg_elmnt, &my_id);
            }
            else {
                // Completely new message
                insert_message(msg, &already_received);
            }
            /* DEBUG_RECV("[%d][%d] Message received from [%s:%d][%d]\n", msg->node_id, msg->id, inet_ntoa(sender->inbox->infos.sin_addr), ntohs(sender->inbox->infos.sin_port), sender->inbox->fd); */
            DEBUG_RECV("[%d][%d] Message received from [%d]\n", msg->node_id, msg->id, sender->id);
            acknowledge(*msg);
            multicast(msg, sizeof(message_t));
            DEBUG_SEND("[%d][%d] Retransmited\n", msg->node_id, msg->id);
        }
        else {
            // Message already received, we can drop it
            free(msg);
            msg = NULL;
        }
    }
    else {
        free(msg);
        msg = NULL;
    }
}
コード例 #4
0
//
// handle_messages
//
void CUTS_Testing_LoggingServerListener_i::
handle_messages (const char * hostname,
                 const ::CUTS::UUID & test,
                 const ::CUTS::LogMessages & msgs)
{
  try
  {
    ACE_WRITE_GUARD (ACE_RW_Thread_Mutex, guard, this->mutex_);

    if (0 == this->database_)
      return;

    // Create a new query object.
    ADBC::Query * query = this->database_->create_query ();
    CUTS_Auto_Functor_T <ADBC::Query> auto_clean (query, &ADBC::Query::destroy);

    // Start a new transaction.
    query->execute_no_record ("BEGIN TRANSACTION");

    // Prepare the statement for inserting messages.
    CUTS_Log_Message_Table msg_table (*this->database_);

    CUTS_Log_Message_Table::INSERT_STMT insert_stmt (*query);
    insert_stmt.prepare ();

    insert_stmt.bind_hostname (hostname);

    // Insert each message into the database.
    std::for_each (msgs.get_buffer (),
                   msgs.get_buffer () + msgs.length (),
                   insert_message (insert_stmt));

    // End the current transaction.
    query->execute_no_record ("COMMIT");

  }
  catch (const ADBC::Exception & ex)
  {
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("%T (%t) - %M - %s (%N:%l)\n"),
                ex.message ().c_str ()));

  }
  catch (...)
  {
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("%T (%t) - %M - caught unknown exception (%N:%l)\n")));
  }

  ++this->messages_received_;
}
コード例 #5
0
ファイル: listener.c プロジェクト: swhatelse/URB_Final
/** Manage the received acks
 * @param ack The received acknowledgment.
 * @param sender The node which sent ack.
 */
void handle_ack(message_t* ack, node_t* sender) {
    // First check if we already received the corresponding message.
    // If not create an entry in the already_received list and add the ack.
    // The message will be filled later when received.
    GList* element_list = get_msg_from_list(delivered, ack);

    // If already delivered skip it
    if(!element_list) {
        element_list = get_msg_from_list(already_received, ack);
        message_element_t* element_msg;
        if(!element_list) {
            // Received an ack for a message we didn't received yet
            GList* element_list = get_msg_from_list(not_received_yet, ack);
            if(!element_list) {
                // Message not received yet and received the first ack for it
                // Create an empty message to register the ack and register them
                // for the futur message.
                message_t* msg = malloc(sizeof(message_t));
                msg->node_id = ack->node_id;
                msg->id = ack->id;
                msg->content = NULL;
                insert_message(msg, &not_received_yet);
            }
            else {
                element_msg = (message_element_t*)element_list->data;
                add_ack(element_msg, &sender->id);
            }
        }
        else {
            element_msg = (message_element_t*)element_list->data;
            add_ack(element_msg, &sender->id);
            if(is_replicated(element_msg)) {
                deliver(element_msg);
            }
        }
    }
    else {

    }
}
コード例 #6
0
ファイル: msgfmt.c プロジェクト: stormos-next/illumos-stormos
/*
 * Finds the head of the current domain linked list and
 * call insert_message() to insert msgid and msgstr pair
 * to the linked list.
 */
static void
sortit(char *msgid, char *msgstr)
{
	struct domain_struct	*dom;

#ifdef DEBUG
	(void) fprintf(stderr,
		"==> sortit(), domain=<%s> msgid=<%s> msgstr=<%s>\n",
		gcurrent_domain, msgid, msgstr);
#endif

	/*
	 * If "-o filename" is specified, then all "domain" directive
	 * are ignored and, all messages will be stored in domain
	 * whose name is filename.
	 */
	if (oflag) {
		dom = find_domain_node(outfile);
	} else {
		dom = find_domain_node(gcurrent_domain);
	}

	insert_message(dom, msgid, msgstr);
}
コード例 #7
0
ファイル: x_window.cpp プロジェクト: KarlHegbloom/texmacs
void
x_window_rep::delayed_message (widget wid, string s, time_t delay) {
  time_t ct= texmacs_time ();
  the_gui->messages= insert_message (the_gui->messages, wid, s, ct, ct+ delay);
}
コード例 #8
0
static void
  process_input_file(FILE *in, kd_message * &messages, const char *fname,
                     bool quiet)
{
  int num_errors = 0;
  int num_warnings = 0;
  int num_dev_errors = 0;
  int num_dev_warnings = 0;

  kd_string error_context;
  kd_string warning_context;
  kd_string error_lead_in;
  kd_string warning_lead_in;

  kd_message msg; // Temporary resource for building messages
  kd_string txt; // Temporary resource for assembling contents of KDU_TXT()
  kd_line line;
  int unmatched_braces = 0;
  bool in_txt = false; // If inside the `KDU_TXT' macro
  bool in_comment = false;
  while (line.read(in))
    {
      const char *cp;
      if (error_context.is_empty() &&
          ((cp=strstr(line.get(),"kdu_error _name(\"")) != NULL))
        error_context.add(strchr(cp,'\"'));
      else if (error_lead_in.is_empty() &&
               ((cp=strstr(line.get(),"kdu_error _name(\"")) != NULL))
        error_lead_in.add(strchr(cp,'\"'));
      else if (warning_context.is_empty() &&
               ((cp=strstr(line.get(),"kdu_warning _name(\"")) != NULL))
        warning_context.add(strchr(cp,'\"'));
      else if (warning_lead_in.is_empty() &&
               ((cp=strstr(line.get(),"kdu_warning _name(\"")) != NULL))
        warning_lead_in.add(strchr(cp,'\"'));

     cp = line.get();
     if (*cp == '#')
       continue;

     for (; *cp != '\0'; cp++)
       {
         if ((cp[0] == '/') && (cp[1] == '/'))
           break; // Rest of line is a comment
         if (in_comment)
           {
             if ((cp[0] == '*') && (cp[1] == '/'))
               { in_comment = false; cp++; }
             continue;
           }
         if ((cp[0] == '/') && (cp[1] == '*'))
           { in_comment = true; cp++; continue; }
         if (!msg.started())
           {
             kdu_uint32 id;
             if (check_prefix(cp,"KDU_ERROR("))
               {
                 cp += strlen("KDU_ERROR(");
                 if (read_id(cp,id) &&
                     !(error_context.is_empty() ||
                       error_lead_in.is_empty()))
                   {
                     msg.start(error_context,id,error_lead_in,false);
                     num_errors++;
                   }
               }
             else if (check_prefix(cp,"KDU_ERROR_DEV("))
               {
                 cp += strlen("KDU_ERROR_DEV(");
                 if (read_id(cp,id) &&
                     !(error_context.is_empty() ||
                       error_lead_in.is_empty()))
                   {
                     msg.start(error_context,id,error_lead_in,true);
                     num_errors++;  num_dev_errors++;
                   }
               }
             else if (check_prefix(cp,"KDU_WARNING("))
               {
                 cp += strlen("KDU_WARNING(");
                 if (read_id(cp,id) &&
                     !(warning_context.is_empty() ||
                       warning_lead_in.is_empty()))
                   {
                     msg.start(warning_context,id,warning_lead_in,false);
                     num_warnings++;
                   }
               }
             else if (check_prefix(cp,"KDU_WARNING_DEV("))
               {
                 cp += strlen("KDU_WARNING_DEV(");
                 if (read_id(cp,id) &&
                     !(warning_context.is_empty() ||
                       warning_lead_in.is_empty()))
                   {
                     msg.start(warning_context,id,warning_lead_in,true);
                     num_warnings++;  num_dev_warnings++;
                   }
               }
             assert((unmatched_braces == 0) && !in_txt);
             continue;
           }

         // If we get here, a message has been started
         if (!in_txt)
           {
             if (check_prefix(cp,"KDU_TXT("))
               {
                 cp += strlen("KDU_TXT");
                 in_txt = true;
               }
             else if (*cp == '{')
               unmatched_braces++;
             else if (*cp == '}')
               {
                 if (unmatched_braces > 0)
                   unmatched_braces--;
                 else
                   {
                     kd_message *new_msg = new kd_message;
                     msg.donate(new_msg);
                     assert(!msg.started());
                     insert_message(messages,new_msg,fname);
                   }
               }
             continue;
           }

         // If we get here, we are inside a `KDU_TXT' macro
         if (*cp == '\"')
           cp = txt.add(cp);
         else if (*cp == ')')
           {
             msg.add_text(txt);
             txt.clear();
             in_txt = false;
           }
       }
    }

  if (msg.started())
    { kdu_error e; e << "Encountered incomplete \"KDU_ERROR\", "
      "\"KDU_ERROR_DEV\", \"KDU_WARNING\" or \"KDU_WARNING_DEV\" environment "
      "while parsing source file \"" << fname << "\"."; }

  if (!quiet)
    {
      pretty_cout << ">> Parsed " << num_errors << " KDU_ERROR messages ("
                  << num_dev_errors << " for developers only)\n\tand "
                  << num_warnings << " KDU_WARNING messages ("
                  << num_dev_warnings << " for developers only)\n\tfrom \""
                  << fname << "\".\n";
      pretty_cout.flush();
    }
}
コード例 #9
0
ファイル: notmuch-insert.c プロジェクト: bgamari/notmuch
int
notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
{
    notmuch_database_t *notmuch;
    struct sigaction action;
    const char *db_path;
    const char **new_tags;
    size_t new_tags_length;
    tag_op_list_t *tag_ops;
    char *query_string = NULL;
    const char *folder = NULL;
    notmuch_bool_t create_folder = FALSE;
    const char *maildir;
    int opt_index;
    unsigned int i;
    notmuch_bool_t ret;

    notmuch_opt_desc_t options[] = {
	{ NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 },
	{ NOTMUCH_OPT_BOOLEAN, &create_folder, "create-folder", 0, 0 },
	{ NOTMUCH_OPT_END, 0, 0, 0, 0 }
    };

    opt_index = parse_arguments (argc, argv, options, 1);

    if (opt_index < 0) {
	/* diagnostics already printed */
	return 1;
    }

    db_path = notmuch_config_get_database_path (config);
    new_tags = notmuch_config_get_new_tags (config, &new_tags_length);

    tag_ops = tag_op_list_create (config);
    if (tag_ops == NULL) {
	fprintf (stderr, "Out of memory.\n");
	return 1;
    }
    for (i = 0; i < new_tags_length; i++) {
	if (tag_op_list_append (tag_ops, new_tags[i], FALSE))
	    return 1;
    }

    if (parse_tag_command_line (config, argc - opt_index, argv + opt_index,
				&query_string, tag_ops))
	return 1;

    if (*query_string != '\0') {
	fprintf (stderr, "Error: unexpected query string: %s\n", query_string);
	return 1;
    }

    if (folder == NULL) {
	maildir = db_path;
    } else {
	if (! check_folder_name (folder)) {
	    fprintf (stderr, "Error: bad folder name: %s\n", folder);
	    return 1;
	}
	maildir = talloc_asprintf (config, "%s/%s", db_path, folder);
	if (! maildir) {
	    fprintf (stderr, "Out of memory\n");
	    return 1;
	}
	if (create_folder && ! maildir_create_folder (config, maildir)) {
	    fprintf (stderr, "Error: creating maildir %s: %s\n",
		     maildir, strerror (errno));
	    return 1;
	}
    }

    /* Setup our handler for SIGINT. We do not set SA_RESTART so that copying
     * from standard input may be interrupted. */
    memset (&action, 0, sizeof (struct sigaction));
    action.sa_handler = handle_sigint;
    sigemptyset (&action.sa_mask);
    action.sa_flags = 0;
    sigaction (SIGINT, &action, NULL);

    if (notmuch_database_open (notmuch_config_get_database_path (config),
			       NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))
	return 1;

    ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops);

    notmuch_database_destroy (notmuch);

    return (ret) ? 0 : 1;
}
コード例 #10
0
ファイル: DRIFT.C プロジェクト: OS2World/GAMES-ACTION-drift
void game (HDC hdc)
{
int zoom, count;
POINTL at;
if (game_duration != 0)           // zooming intro of the game
	 {
	 zoom = game_duration / 2;
	 if (zoom == 0)
			zoom = 1;
	 process_list_zoom(hdc,zoom);
	 game_duration--;
	 }
else
		{
	 process_list(hdc);
		if (random(2500) == 0 && !game_over && nbr_asteroids>5)  // yep the mystery ship arrives
			 {
				add_list(init_objekt(OT_MYSTSHIP,edge(),edge(),random(360),random(8)+4,DT_POLY,0,CLR_BROWN,mysterydata,8),enemies);
				nbr_asteroids++;
			 }
		if (random(1000) < game_level && !game_over && nbr_asteroids > 5) // enemy1 has arrived
			 {
			 add_list(init_objekt(OT_ENEMY1,random(2000),edge(),0,4,DT_POLY,0,CLR_BLUE,enemy1data,5),enemies);
			 nbr_asteroids++;
			 }
		if (random(1500) == 0 && !game_over && nbr_asteroids > 5) // enemy2 has arrived
			 {
			 add_list(init_objekt(OT_ENEMY2,edge(),random(2000),0,4,DT_POLY,0,CLR_CYAN,enemy2data,7),enemies);
			 nbr_asteroids++;
		 }
		if (game_shieldduration > 0)
			 game_shieldduration--;
		if (game_shieldduration < 0)
			 game_shieldduration = 0;
		if (game_over)
			 {
			 input_enabled = FALSE;
			 // game over... the end
			 if (end_count == 150)
					{
					insert_message (1200,0, "game over");
					insert_message (800,0, "score %05d",game_score);
					WinPostMsg(hwndClient,DM_CHECKSCORE,(MPARAM)game_score,(MPARAM)0); // check for hiscore
					}
		 if (end_count == 0)
			 {
					//terminate all
					free_all();
					game_status = GAME_INTRO;
					game_duration = 200;
					WinInvalidateRect(hwndClient, NULL, TRUE);
					return;
					}
			 end_count--;
			 }
		if (nbr_asteroids == 0) // end of game
			 {
			 // do some end stuff
			 if (input_enabled)
			 {
					for (count = 0; count < 10; count++)
						 {
						 at.x = random(2000);
						 at.y = random(2000);
						 insert_explosion(at,10);
						 }
					insert_message (1200,0, "level %02d clear", game_level);
					insert_message (800,0, "score %05d",game_score);
					}
			 input_enabled = FALSE;
			 if ((llist_items == 1) || (llist_items == 2 && game_shieldduration != 0))       // real end of game
					{
					delete_list(ship,&start);
					if (llist_items != 0)
					free_all();       // frees the shield
					ship->current.x = 1000;
					ship->current.y = 1000;
					ship->thrust_speed = 0;
					game_level++;
					init_game();
					game_duration = 25;
					WinInvalidateRect(hwndClient, NULL, TRUE);
					}
			 }
		}
}
コード例 #11
0
ファイル: DRIFT.C プロジェクト: OS2World/GAMES-ACTION-drift
void init_game (void)
{
int count,tmprnd,special_rand;
game_over = FALSE;
game_blackhole = FALSE;
game_bigspace = FALSE;
end_count = 150;
nbr_asteroids = 0;
randomize();
input_enabled = TRUE;
randomize();
special_rand = random(20);
add_list(ship,&start);
if (game_shieldduration > 3)
	 add_list(init_objekt(OT_SHIPSHIELD,ship->current.x,ship->current.y,ship->angle,0,DT_POLY,game_shieldduration, CLR_WHITE,shielddata,4),effekts);
// insert sats
if (special_rand == 0)  // sattelite madness
		{
		tmprnd = 10;
		insert_message (1600,0,"sattelite madness");
	 }
else
	 {
		tmprnd = game_level-5+random(7);  // number of sats
		if (tmprnd > 4)
			tmprnd = 4;
		}
if (tmprnd > 0)
	 for (count = 0; count < tmprnd; count++)
		{
		add_list(init_objekt(OT_SAT,random(2000),random(1200)-600,random(360),3,DT_POLY,0,CLR_CYAN,satdata,8),enemies);
		nbr_asteroids++;
		}
if (special_rand == 2)
	 {
	 insert_message (1600,0,"Go Polygunzz");
	 for (count = 0; count < 4; count++)
		 add_list(init_objekt(OT_ENEMY1,edge(),random(2000),0,3,DT_POLY,0,CLR_BLUE,enemy1data,5),enemies);
	 for (count = 0; count < 4; count++)
			 add_list(init_objekt(OT_ENEMY2,random(2000),edge(),0,4,DT_POLY,0,CLR_CYAN,enemy2data,7),enemies);
	 nbr_asteroids+=8;
	 }
if (special_rand == 3)
	 {
	 insert_message (1600,0,"Asteroid factory");
	 for (count=0; count < 4; count++)
			add_list(init_objekt(OT_MYSTSHIP,edge(),random(2000),random(360),random(8)+2,DT_POLY,0,CLR_BROWN,mysterydata,8),enemies);
	 nbr_asteroids+=4;
	 }
if (special_rand > 4 || special_rand == 1 || special_rand == 4) // no special level except black hole zone
	 {
	// inserts level+1 number of asteroids in llist
	for (count = 0; count < game_level+1; count++)
		{
		randomize_asteroids (asteroiddata , 10, 100);
		add_list(init_objekt(OT_BIGASTER,random(1200)-600,random(1200)-600,random(360),random(8)+2,DT_POLY,0,CLR_GREEN,asteroiddata,10),asteroids);
		nbr_asteroids++;
		}
	 }
if (special_rand == 1)
	 {
	 game_blackhole = TRUE;
	 insert_message (1600,0,"black hole zone");
	 }
if (special_rand == 4)
  {
  game_bigspace = TRUE;
  insert_message (1600,0,"wow bigspace");
  }
// insert start message
insert_message (800,0, "level %02d",game_level);
}
コード例 #12
0
ファイル: DRIFT.C プロジェクト: OS2World/GAMES-ACTION-drift
// exported extern windows callback routine (doet alle belangrijke stuff)
MRESULT EXPENTRY ClientWndProc(HWND hwnd,ULONG messg,MPARAM mp1,MPARAM mp2)
{
HPS         hps;
static HWND hMenu;
RECTL       rc;
static INT xView, yView;
int count,zoom,tel;
float tmpangle;
BOOL stat;
SIZEL sizel;
POINTL ptl;
switch (messg)
			 {
			 case DM_CHECKSCORE:
					count = check_hiscores(mp1);
					if (count != 10)
						{
						WinDlgBox(HWND_DESKTOP,hwnd,EnterHiScore,NULLHANDLE,DRIFT_HISCORE,NULL);
						if (glb_name[0] == 0)
							strcpy(HiTable[count].name,"Cthulhu");
						else
							strcpy(HiTable[count].name,glb_name);
						}
						break;
		 case WM_SIZE:
						xView = SHORT1FROMMP(mp2);
						yView = SHORT2FROMMP(mp2);
						break;
		 case WM_CREATE:
						init_logo();
						load_hiscores();
						// initialize the settings
            //hMenu=WinQueryWindow(hwnd,QW_PARENT);
						hMenu=WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_MENU);
						// uncheck detaillevel
						stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
            // uncheck save on exit
            stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE);
						load_settings();
						// check to correct menu item detaillevel
						stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
            if (saveonexit)
            	stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE);
						switch (detaillevel)
							{
							case IDM_HIGHDET:
											game_bigex = 36;
											game_mediumex = 18;
											game_smallex = 9;
											maxthrustpixels = 9;
											break;
							case IDM_MEDIUMDET:
											game_bigex = 18;
											game_mediumex = 18;
											game_smallex = 9;
											maxthrustpixels = 5;
											break;
							case IDM_LOWDET:
											game_bigex = 9;
											game_mediumex = 9;
											game_smallex = 9;
											maxthrustpixels = 3;
											break;
							}
						if (saveonexit == TRUE)
								stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE);
						else
								stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE);
						break;
		 case WM_TIMER:
						hps = WinGetPS(hwnd) ;
            sizel.cx = 2000 ;
            sizel.cy = 2000 ;
            GpiSetPS (hps, &sizel, PU_PELS) ;

						GpiQueryPageViewport(hps,&rc);
						rc.xLeft   = 0;//xView / 2 ;
            rc.xRight  = xView ;
            rc.yBottom = 0;//yView / 2 ;
            rc.yTop    = yView;

            GpiSetPageViewport (hps, &rc) ;

						 switch (game_status)
							{
							case GAME_INTRO :
												stat = WinEnableMenuItem(hMenu,IDM_PLAY,TRUE);
												stat = WinEnableMenuItem(hMenu,IDM_QUIT,FALSE);
												stat = WinEnableMenuItem(hMenu,IDM_PAUZE,FALSE);
												zoom = (game_duration - 100)/3;
												if (zoom < 5)
													zoom = 5;
												D->angle += 10;
												D->zoom = zoom;
												R->angle += 10;
												R->zoom = zoom;
												I->angle += 10;
												I->zoom = zoom;
												F->angle += 10;
												F->zoom = zoom;
												T->angle += 10;
												T->zoom = zoom;
												game_duration --;
												if (game_duration == 0)
													{
                          game_status = GAME_HISCORE;
                          game_duration = 200;                          if (random(2) == 0)
                            {
                            // insert the hiscore table
													  insert_message(1800,0,"D R I F T  F O R  O S / 2  H I S C O R E S");
													  insert_message(1600,0,"Rank    Name          Score  Level");
													  for (tel = 0; tel < 10; tel++)
														  insert_message(1460-(tel*100),0,"%2d     %-12s %5d    %2d",tel+1,HiTable[tel].name,HiTable[tel].score,HiTable[tel].level);
                            }
                          else
                            {
                            // insert help message
                            insert_message(1800,0,"DRIFT WARPSPEED FOR OS/2 WARP");
                            insert_message(1600,0,"By Dirk Vandenheuvel /c/ 1995");
                            insert_message(1400,0,"Keys");
                            insert_message(1200,0,"UP                     Thrust");
                            insert_message(1100,0,"LEFT                Turn left");
                            insert_message(1000,0,"RIGHT              Turn right");
                            insert_message(900,0, "SPACE            Fire missile");
                            }
                          WinInvalidateRect(hwnd,NULL,TRUE);
													}
												else
													intro(hps);
												break;
							case GAME_HISCORE:
												game_duration --;
												if (game_duration == 0)
													{
													// free the effekts list
													free_all();
													game_status = GAME_INTRO;
													game_duration = 200;
													WinInvalidateRect(hwnd,NULL,TRUE);
													}
												break;
							case GAME_PLAYING: // play
												check_keys();
												if (game_shooting)
													game_shooting--;
												game(hps);
												break;
							}
               WinReleasePS(hps);
               break;
		 case WM_SYSCOMMAND:
							/*switch(mp1)
								{
								case SC_MINIMIZE:
											if (!game_pauze)
												SendMessage(hwnd,WM_COMMAND,IDM_PAUZE,0);
											break;
											}
								return(DefWindowProc(hwnd,messg,mp1,mp2));*/
								break;
		 case WM_COMMAND:
								switch (COMMANDMSG(&messg)->cmd)
									{
									case IDM_SAVEONEXIT:
															if (saveonexit == TRUE) // already checked
																{
																stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE);
																saveonexit = FALSE;
																save_settings(); // save the "do not save on exit" setting
																}
															else
																{
																stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE);
																saveonexit = TRUE;
																}
															break;
									case IDM_HIGHDET : // set to high
															game_bigex = 36;
															game_mediumex = 18;
															game_smallex = 9;
															maxthrustpixels = 9;
															stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
															detaillevel=SHORT1FROMMP(mp1);
															stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
															break;
									case IDM_MEDIUMDET:
															game_bigex = 18;
															game_mediumex = 18;
															game_smallex = 9;
															maxthrustpixels = 5;
															stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
															detaillevel=SHORT1FROMMP(mp1);
															stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
															break;
									case IDM_LOWDET:
															game_bigex = 9;
															game_mediumex = 9;
															game_smallex = 9;
															maxthrustpixels = 3;
															stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
															detaillevel=SHORT1FROMMP(mp1);
															stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
															break;
									case IDM_ABOUT:
															WinDlgBox(HWND_DESKTOP,hwnd,AboutDiaProc,NULLHANDLE,IDD_ABOUT,NULL);
															break;
									case IDM_HELP :
															//WinHelp (hwnd,"drift.hlp",HELP_INDEX,0);
															break;
									case IDVK_ESCAPE: // escape key pressed
															//SendMessage (hwnd, WM_SYSCOMMAND,SC_MINIMIZE,0);
															break;
									case IDM_PAUZE:
															if (game_status != GAME_PLAYING)
																break;
															if (game_pauze != TRUE)
																{
                                WinStopTimer(hab,hwndClient,idTimer);
                                stat = WinCheckMenuItem(hMenu,IDM_PAUZE,TRUE);
																game_pauze = TRUE;
																}
															else
																{
																game_pauze = FALSE;
																// gets a timer
																idTimer = WinStartTimer(hab,hwndClient,ID_TIMER,30);
																stat = WinCheckMenuItem(hMenu,IDM_PAUZE,FALSE);
																WinInvalidateRect(hwnd, NULL, TRUE);
																}
															break;
									case IDM_QUIT:
															stat = WinEnableMenuItem(hMenu,IDM_PLAY,TRUE);
															stat = WinEnableMenuItem(hMenu,IDM_QUIT,FALSE);
															stat = WinEnableMenuItem(hMenu,IDM_PAUZE,FALSE);
															free_all();
															game_status = GAME_INTRO;
															if (game_pauze)
																{
																game_pauze = FALSE;
																//while (!SetTimer(hwnd,ID_TIMER,10,NULL))
																//if (IDCANCEL == MessageBox (hwnd, "Cannot get timer handle!", szProgName,MB_ICONEXCLAMATION | MB_RETRYCANCEL))
																//exit(0); // add a better shutdown here
																//CheckMenuItem(hmenu,IDM_PAUZE,MF_UNCHECKED);
																}
															game_duration = 200;
															WinInvalidateRect(hwnd, NULL, TRUE);
															break;
									case IDM_PLAY:
															free_all();
															stat = WinEnableMenuItem(hMenu,IDM_PLAY,FALSE);
															stat = WinEnableMenuItem(hMenu,IDM_QUIT,TRUE);
															stat = WinEnableMenuItem(hMenu,IDM_PAUZE,TRUE);
															init_objekts();
															game_level = 1;
															// init powerups to default
															game_pauze = FALSE;
															game_maxshots = MAXSHOT;
															game_shots = 1;
															game_turning = 10;
															game_shotlife = 20;
															game_rearshot = FALSE;
															game_shieldduration = 0;
															init_game();
															game_status = GAME_PLAYING;
															game_score = 0;
															game_duration = 25;
                              game_life = 3;
															WinInvalidateRect(hwnd, NULL, TRUE);
															break;
									default:    break;
									}
									break;
			 case WM_PAINT:
									hps = WinBeginPaint(hwnd,NULLHANDLE,&rc);
									WinQueryWindowRect(hps,&rc);
            			WinFillRect(hps,&rc,CLR_BLACK);
                  sizel.cx = 2000 ;
                  sizel.cy = 2000 ;
            			GpiSetPS (hps, &sizel, PU_PELS) ;

									GpiQueryPageViewport(hps,&rc);
									rc.xLeft   = 0;//xView / 2 ;
            			rc.xRight  = xView ;
            			rc.yBottom = 0;//yView / 2 ;
            			rc.yTop    = yView;

            			GpiSetPageViewport (hps, &rc) ;
                  if (game_status == GAME_HISCORE)
                    hiscore(hps);
                  if (game_status == GAME_PLAYING && game_pauze)
										game(hps);
									WinEndPaint(hps);
									break;
        default:   return(WinDefWindowProc(hwnd,messg,mp1,mp2));
			 }
return(MRESULT)0L;
}