Exemple #1
0
void MenuBarHit (DWORD wParam)
{
   if (wParam == MENUCLOSING)
      {
      StatusLineReady (hWndStatus) ;
      dwCurrentMenuID = 0 ;
      }
   else if (HIWORD(wParam) & MF_SYSMENU)
      {
      WORD   SystemMenuItem = 0 ;
      switch (LOWORD (wParam))
         {
         case SC_RESTORE:
            SystemMenuItem = IDM_SYSTEMRESTORE ;
            break ;

         case SC_SIZE:
            SystemMenuItem = IDM_SYSTEMSIZE ;
            break ;

         case SC_MOVE:
            SystemMenuItem = IDM_SYSTEMMOVE ;
            break ;

         case SC_MINIMIZE:
            SystemMenuItem = IDM_SYSTEMMINIMIZE ;
            break ;

         case SC_MAXIMIZE:
            SystemMenuItem = IDM_SYSTEMMAXIMIZE ;
            break ;

         case SC_CLOSE:
            SystemMenuItem = IDM_SYSTEMCLOSE ;
            break ;

         case SC_TASKLIST:
            SystemMenuItem = IDM_SYSTEMSWITCHTO ;
            break ;
         }

      if (SystemMenuItem)
         {
         StatusLine (hWndStatus, SystemMenuItem) ;
         dwCurrentMenuID = MenuIDToHelpID (SystemMenuItem) ;
         }
      }
   else
      {
      StatusLine (hWndStatus, LOWORD (wParam)) ;
      }
}
Exemple #2
0
StatusLine	FileReader::read_file(const std::string& full_path,Entity& saver )
{
    if(get_from_cache(full_path,saver)) {
        return StatusLine(http_200,"");
    }

    boost::uintmax_t file_bytes=boost::filesystem::file_size(full_path) ;
    if(file_bytes > m_max_file_size) {
        return StatusLine(http_403,"file too large");
    }

    std::string ext=boost::filesystem::path(full_path).extension().generic_string();
    if(!g_supported_file_types.exists(ext)) {
        return StatusLine(http_415,"not support this file type "+ext);
    }
    saver.head().get_container()[HeadFields::EntityFields::ent_content_type]=g_supported_file_types.get_type_name(ext);
	
	return get_from_file(full_path,saver);

}
Exemple #3
0
StatusLine		FileReader::get_from_file(const std::string& full_path,Entity& saver )
{

    std::ifstream file_stream(full_path.c_str(),std::ios::in | std::ios::binary);
    if (! file_stream.is_open()) {
		return  StatusLine(http_500,"fail to open file");
    }
    while (!file_stream.eof() ) {
		saver.data().ensure_write_space(m_read_block_size);
        file_stream.read(saver.data().wt_ptr(),m_read_block_size) ; 
		saver.data().has_written(file_stream.gcount());
	}
	saver.head().get_container()[HeadFields::EntityFields::ent_content_length]=
		StringHelper::integer_to_string<size_t>((size_t)saver.data().readable_bytes());

	save_to_cache(full_path,saver);
	return StatusLine(http_200,"");
	

}
Exemple #4
0
void TurnLogic() {
  Short kept;
  Short x;
  // Update


  DrawCurrScore();

  /* 
   * Player lost turn
   */
  if ( ( stor.scorethisroll == 0 &&
		 !stor.flash ) || 
	   StayBit ) {
	
	if ( StayBit ) {
	  stor.player[stor.currplayer].score += stor.scorethisturn;
	}

	NextPlayer();
	return;
  }


  stor.YMNWTBYM = false;

  DrawCurrScore();
  for( x = 0 ; x < NumCubes ; x++ )
	DrawKeepBit(x);


  kept = 0;
  for ( x = 0 ; x < NumCubes ; x++ ) {
	if ( stor.cube[x].keep ) {
	  kept++;
	}
  }

  if ( kept == 5 ) {
	// You May Not Want To But You Must
	stor.YMNWTBYM = true;
	for ( x = 0 ; x < NumCubes ; x++ ) {
	  stor.cube[x].keep = false;
	}
  }

  DrawStayButton();
  StatusLine();
}
Exemple #5
0
void  DisplayField(void)
{
   struct   y_list   *ScanY;
   struct   x_list   *ScanX;
   static   Cell     cell={0,'*'};
   static   Cell     blank={0,' '};
   int      x,y;
   long     i;

   OwUse(Root);

   ScanY=Field;
   for(y=0; y<I_ScreenHeight; y++)
   {
      while(ScanY!=NULL && ScanY->y<y+ShiftY)
         ScanY=ScanY->next;
      if(ScanY!=NULL && ScanY->y==y+ShiftY)
      {
         ScanX=ScanY->line;
         i=ScanY->x_cnt;
         for(x=0; x<I_ScreenWidth; x++)
         {
            while(i>0 && ScanX->x<x+ShiftX)
            {
               ScanX++;
               i--;
            }
            if(i>0 && ScanX->x==x+ShiftX)
            {
               OwSetCell(x,y,&cell);
            }
            else
            {
               OwSetCell(x,y,&blank);
            }
         }
      }
      else
      {
         for(x=0; x<I_ScreenWidth; x++)
         {
            OwSetCell(x,y,&blank);
         }
      }
   }
   StatusLine();
   Sync();
}
Exemple #6
0
char SerialPort::ReceiveBuffer(char *buffer, const unsigned short length) {
	if(!mConnected) return 1;
	unsigned long bytesRead = 0, totalRead = 0;
	char counter = 0;

	while(totalRead < length && counter < 50) {
		if(!ReadFile(mHandle, buffer + totalRead, length - totalRead, &bytesRead, NULL) || !bytesRead)
			counter++;
		totalRead += bytesRead;
	}

	if(totalRead < length) {
		StatusLine("size mismatch");
		return 2;
	}
	return 0;
}
Exemple #7
0
void SayGoodbye(void)
{
  struct viewporttype viewinfo; 	/* Structure to read viewport	*/
  int h, w;

  MainWindow( "== Finale ==" );

  getviewsettings( &viewinfo ); 	/* Read viewport settings	*/
  changetextstyle( TRIPLEX_FONT, HORIZ_DIR, 4 );
  settextjustify( CENTER_TEXT, CENTER_TEXT );

  h = viewinfo.bottom - viewinfo.top;
  w = viewinfo.right  - viewinfo.left;
  outtextxy( w/2, h/2, "That's all, folks!" );

  StatusLine( "Press any key to EXIT" );
  getch();

  cleardevice();			/* Clear the graphics screen	*/

}
Exemple #8
0
/*
 * UpdateStatusWindow - update the status window
 */
void UpdateStatusWindow( void )
{
    char        *str, *ptr;
    char        result[5 * MAX_STR];
    char        *res;
    int         digits;
    long        num;
    bool        use_num;
    int         line;
    char        numstr[12];
    int         format;
    char        c;

    if( BAD_ID( status_window_id ) ||
        EditFlags.DisplayHold ||
        EditFlags.Quiet ||
        !EditFlags.StatusInfo ||
        EditVars.StatusString == NULL ) {
        return;
    }

    res = result;
    line = 1;
    format = FMT_LEFT;
    EditFlags.ModeInStatusLine = false;
    for( str = EditVars.StatusString; (c = *str) != '\0'; ++str ) {
        if( c == '$' ) {
            str++;
            ptr = str;
            while( isdigit( *str ) ) {
                str++;
            }
            if( ptr != str ) {
                digits = strtoul( ptr, NULL, 10 );
            } else {
                digits = 0;
            }
            use_num = false;
            num = 0;
            c = *str;
            if( c == '\0' )
                break;
            switch( c ) {
            case '$':
                *res++ = '$';
                break;
            case 'c':
                *res++ = ',';
                break;
            case 'n':
                *res = 0;
                StatusLine( line, result, format );
                res = result;
                line++;
                break;
            case 'L':
                num = CurrentPos.line;
                use_num = true;
                break;
            case 'C':
                num = VirtualColumnOnCurrentLine( CurrentPos.column );
                use_num = true;
                break;
            case 'D':
#ifdef __WIN__
                GetDateString( res );
#else
                GetDateTimeString( res );
#endif
                res += strlen( res );
                break;
            case 'T':
                GetTimeString( res );
                res += strlen( res );
                break;
            case 'M':
                /* print the desired mode */
                EditFlags.ModeInStatusLine = true;
                GetModeString( res );
                res += strlen( res );
                break;
#ifdef __WIN__
            case 'H':
                GetMenuHelpString( res );
                res += strlen( res );
                break;
            case '[':
                *res++ = STATUS_ESC_CHAR;
                *res++ = STATUS_NEXT_BLOCK;
                break;
            case '|':
                *res++ = STATUS_ESC_CHAR;
                *res++ = STATUS_FORMAT_CENTER;
                break;
            case '>':
                *res++ = STATUS_ESC_CHAR;
                *res++ = STATUS_FORMAT_RIGHT;
                break;
            case '<':
                *res++ = STATUS_ESC_CHAR;
                *res++ = STATUS_FORMAT_LEFT;
                break;
#else
            case '|':
                format = FMT_CENTRE;
                break;
            case '>':
                format = FMT_RIGHT;
                break;
            case '<':
                format = FMT_LEFT;
                break;
#endif
            }
            if( use_num ) {
                ltoa( num, numstr, 10 );
                digits -= strlen( numstr );
                while( digits > 0 ) {
                    *res++ = ' ';
                    digits--;
                }
                ptr = numstr;
                while( *ptr != '\0' ) {
                    *res++ = *ptr++;
                }
            }
        } else {
            *res++ = c;
        }
    }
    *res = 0;
    if( res != result ) {
        StatusLine( line, result, format );
    }

} /* UpdateStatusWindow */
Exemple #9
0
VOID
CheckStatus(
    IN LPSTR szCaller,
    IN DWORD status,
    IN INT cdrom
    )
/*++

Routine Description:


    Check return code for known bad codes and inform
    user how to correct (if possible) the problem.


Arguments:


    status - return code from opertaion


Return Value:


    none


--*/
{

    CHAR s[100];

    if (status==ERROR_SUCCESS)
        return;

    switch( status ) {

    case ERROR_GEN_FAILURE:
        sprintf( s, IdStr( STR_ERR_GEN ), gDevices[cdrom]->drive, szCaller );
        break;

    case ERROR_NO_MEDIA_IN_DRIVE:
        sprintf( s, IdStr( STR_ERR_NO_MEDIA ), gDevices[cdrom]->drive );
        NoMediaUpdate( cdrom );
        break;

    case ERROR_UNRECOGNIZED_MEDIA:
        sprintf( s, IdStr( STR_ERR_UNREC_MEDIA ), gDevices[cdrom]->drive );
        if (!(gDevices[cdrom]->State & DATA_CD_LOADED))
            NoMediaUpdate( cdrom );
        break;

    case ERROR_FILE_NOT_FOUND:
        sprintf( s, IdStr( STR_ERR_NO_DEVICE ), szCaller, gDevices[cdrom]->drive );
        NoMediaUpdate( cdrom );
        break;

    case ERROR_INVALID_FUNCTION:
        sprintf( s, IdStr( STR_ERR_INV_DEV_REQ ), gDevices[cdrom]->drive );
        break;

    case ERROR_NOT_READY:
        sprintf( s, IdStr( STR_ERR_NOT_READY ), gDevices[cdrom]->drive );
        NoMediaUpdate( cdrom );
        break;

    case ERROR_SECTOR_NOT_FOUND:
        sprintf( s, IdStr( STR_ERR_BAD_SEC ), gDevices[cdrom]->drive );
        break;

    case ERROR_IO_DEVICE:
        sprintf( s, IdStr( STR_ERR_IO_ERROR ), gDevices[cdrom]->drive );
        break;

    default:
        sprintf( s, IdStr( STR_ERR_DEFAULT ), gDevices[cdrom]->drive, szCaller, status );
        break;

    }

    StatusLine( SL_ERROR, s );

}
Exemple #10
0
VOID
CheckUnitCdrom(
    IN INT cdrom
    )

/*++

Routine Description:


    Queries the device state, checking to see if a cartridge has
    been ejected or inserted.


Arguments:


    cdrom - index into gDevices array, specifies which CDROM
            device to access



Return Value:


    none.


--*/

{

    DWORD status;
    CHAR    s[50];


    status = TestUnitReadyCdrom( gDevices[cdrom]->hCd );

    if (gDevices[cdrom]->State & NO_CD) {

        if (status==ERROR_SUCCESS) {

            //
            // a new disc has been inserted.  Scan it now.
            //

            sprintf( s, IdStr( STR_DISC_INSERT ), cdrom );
            StatusLine( SL_INFO, s );
            RescanDevice( cdrom );

        }

    } else {

        if (status!=ERROR_SUCCESS) {

            //
            // a disc has been ejected
            //

            sprintf( s, IdStr( STR_DISC_EJECT ), cdrom );
            StatusLine( SL_INFO, s );
            NoMediaUpdate( cdrom );

        }

    }

}
Exemple #11
0
void  Life(void)
{
   int   Running=0;
   int   ViewStep=10;
   unsigned key;

   OwDisplay(Root);
   OwDisplay(StatusWin);

   Center();
   DisplayField();
   do
   {
      MoveCursor((unsigned)(PosX-ShiftX),(unsigned)(PosY-ShiftY));
      CursorType(C_NORMAL);
      if(Running)
      {
         if(KeyPressed())
            key=ReadKey();
         else
            key=' ';
      }
      else
         key=ReadKey();
      switch(key)
      {
      case('!'):
         SuspendInterface();
#ifndef MSDOS
/*       system("exec $SHELL");*/
#else
         system(getenv("COMSPEC"));
#endif
         ResumeInterface();
         continue;
      case(K_F2):
         SaveField();
         continue;
      case('c'):
      case('C'):     /* clear field */
         Running=0;
         FreeField();
         Center();
         break;
      case(' '):
         Step();
         break;
      case('\t'):
         ChangeCell(PosX,PosY,REV);
         break;
      case(M_BUTTON):
         switch(I_LastButton)
         {
         case(LEFT_BUTTON):
            ChangeCell(ShiftX+I_MouseX,ShiftY+I_MouseY,REV);
            break;
         case(RIGHT_BUTTON):
            ShiftX+=I_MouseX-(int)(I_ScreenWidth>>1);
            ShiftY+=I_MouseY-(int)(I_ScreenHeight>>1);
            break;
         default:
            continue;
         }
         break;
      case(M_MOVE):
         if(I_Buttons&LEFT_BUTTON)
            ChangeCell(ShiftX+I_MouseX,ShiftY+I_MouseY,REV);
         else
            continue;
         break;
      case('4'):
         ShiftX-=ViewStep;
         break;
      case(K_LEFT):
         PosX--;
         if(PosX<ShiftX)
            ShiftX-=ViewStep;
         else
         {
            StatusLine();
            continue;
         }
         break;
      case('8'):
         ShiftY-=ViewStep;
         break;
      case(K_UP):
         PosY--;
         if(PosY<ShiftY)
            ShiftY-=ViewStep;
         else
         {
            StatusLine();
            continue;
         }
         break;
      case('6'):
         ShiftX+=ViewStep;
         break;
      case(K_RIGHT):
         PosX++;
         if(PosX>=ShiftX+(int)I_ScreenWidth)
            ShiftX+=ViewStep;
         else
         {
            StatusLine();
            continue;
         }
         break;
      case('2'):
         ShiftY+=ViewStep;
         break;
      case(K_DOWN):
         PosY++;
         if(PosY>=ShiftY+(int)I_ScreenHeight)
            ShiftY+=ViewStep;
         else
         {
            StatusLine();
            continue;
         }
         break;
      case('5'):
         Center();
         break;
      case('3'):
         ShiftY+=ViewStep;
         ShiftX+=ViewStep;
         break;
      case('1'):
         ShiftY+=ViewStep;
         ShiftX-=ViewStep;
         break;
      case('7'):
         ShiftY-=ViewStep;
         ShiftX-=ViewStep;
         break;
      case('9'):
         ShiftY-=ViewStep;
         ShiftX+=ViewStep;
         break;
      case('\r'):
         Running=!Running;
         break;
      case('q'):
      case('Q'):
      case(27):
         return;
      default:
         continue;
      }
      if(PosY<ShiftY)
         PosY+=(ShiftY-PosY+ViewStep-1)/ViewStep*ViewStep;
      if(PosX<ShiftX)
         PosX+=(ShiftX-PosX+ViewStep-1)/ViewStep*ViewStep;
      if(PosY>=ShiftY+(int)I_ScreenHeight)
         PosY-=(PosY-ShiftY-(int)I_ScreenHeight+ViewStep)/ViewStep*ViewStep;
      if(PosX>=ShiftX+(int)I_ScreenWidth)
         PosX-=(PosX-ShiftX-(int)I_ScreenWidth+ViewStep)/ViewStep*ViewStep;;
      DisplayField();
   }
   while(1);
}