Exemple #1
0
 std::string TransmitRequest::ToHexString(HexFormat spacing) const {
   std::stringstream tmp;
   // TODO: Implement HexString function without third argument
     bool even_space = false;
     bool data_space = false;
     switch (spacing) {
       case HexFormat::BYTE_SPACING:
         even_space = true;
       case HexFormat::DATA_SPACING:
         data_space = true;
       case HexFormat::NO_SPACING:
         tmp << HexString(start, even_space, data_space);
         tmp << HexString(length, even_space, data_space);
         tmp << HexString(frame_type, even_space, data_space);
         tmp << HexString(frame_id, even_space, data_space);
         tmp << HexString(target_mac_64, even_space, data_space);
         tmp << HexString(target_mac_16, even_space, data_space);
         tmp << HexString(broadcast_radius, even_space, data_space);
         tmp << HexString(options, even_space, data_space);
         for (auto itr = data.begin(); itr != data.end(); ++itr)
           if (*itr != 0x00)
             tmp << HexString(*itr, even_space, even_space);
         
         // TODO: Figure out how to avoid if statement
         // checksum wont be spaced for DATA_SPACING case
         // if a ' ' is thrown in, checksum wont be not spaced for NO_SPACING case
         if (spacing == HexFormat::DATA_SPACING) tmp << ' ';
         tmp << HexString(checksum, even_space, false);
     }
     return tmp.str();
 }
		void Launcher::Colors::Save(Configuration& cfg) const
		{
			Configuration::Section color( cfg["launcher"]["view"]["colors"] );

			color[ "foreground" ].Str() = HexString( 32, foreground.color );
			color[ "background" ].Str() = HexString( 32, background.color );
		}
static ::testing::AssertionResult AssertEqualHex(const char *mExpr,
        const char *nExpr,
        T m,
        T n) {
    if (m == n) {
        return ::testing::AssertionSuccess();
    }

    return ::testing::AssertionFailure()
        << mExpr << " and " << nExpr << " (expected: " << HexString(m) <<
        ", actual: " << HexString(n) << ") are not equal";
}
Exemple #4
0
APIRET netbios_FindName(void)
{
  NCB   ncb;
  UCHAR rc;
  char  szBuffer[ 512 ]; // NETBIOS crashes if that's too large
  PSZ   pszNameStatus;
  struct ncb_find_name_info*   pFindHeader;
  struct ncb_lan_header_entry* pFindBuffer;
  char  szMACDestination[64];
  char  szMACSource[64];
  char  szRouteInfo[64];
  int   i;
  
  
  // setup the network control block
  // @@@PH LANA number
  init_NCB( &ncb, NB_FIND_NAMEWAIT, 0);
  ncb.ncb_buffer  = szBuffer;
  ncb.ncb_length  = sizeof( szBuffer );
  
  // build netbios name
  buildNetbiosName(ncb.ncb_callname, Options.pszName, Options.ucNameType);
  
  // send NCB
  rc = i_NetBios32Submit( &ncb );
  
  printf("netbios returned %d\n",
         rc);
  
  // display found information
  pFindHeader = (struct ncb_find_name_info *)ncb.ncb_buffer;
  switch (pFindHeader->name_status)
  {
    case 0: pszNameStatus = "unique"; break;
    case 1: pszNameStatus = "group"; break;
    default: pszNameStatus = "unknown"; break;
  }
  
  printf("Find Name:\n"
         "  nodes responding        = %d\n"
         "  reserved                = %d\n"
         "  name status             = %02xh (%s)\n",
         pFindHeader->nodes_responding,
         pFindHeader->reserved,
         pFindHeader->name_status,
         pszNameStatus);
  
  pFindBuffer = (struct ncb_lan_header_entry*) 
                  (ncb.ncb_buffer + sizeof(struct ncb_find_name_info) );
  
  for (i = 0;
       i < pFindHeader->nodes_responding;
       i++)
  {
    HexString(szMACDestination, pFindBuffer->lan_destination_addr, 6);
    HexString(szMACSource,      pFindBuffer->lan_source_addr,      6);
    HexString(szRouteInfo,      pFindBuffer->lan_destination_addr, 18);

    printf("  Name entry %d:\n"
           "    length                = %d\n"
           "    access control        = %02xh\n"
           "    frame  control        = %02xh\n",
           i,
           pFindBuffer->lan_entry_length,
           pFindBuffer->lan_pcf0,
           pFindBuffer->lan_pcf1);
    
    if (pFindBuffer->lan_entry_length >= 8)
      printf("    destination MAC       = %s\n",
             szMACDestination);
                  
    if (pFindBuffer->lan_entry_length >= 14)
      printf("    source MAC            = %s\n",
           szMACSource);
             
    if (pFindBuffer->lan_entry_length >= 32)
      printf("    routing info          = %s\n",
             szRouteInfo);
  }

  return NO_ERROR;
}
Exemple #5
0
String Sha1Stream::FinishStringS()
{
	byte hash[20];
	Finish(hash);
	return HexString(hash, 20, 4);
}
		void Preferences::Save(Configuration& cfg) const
		{
			Configuration::Section preferences( cfg["preferences"] );

			{
				Configuration::Section application( preferences["application"] );

				application[ "autostart"                ].YesNo() = settings[ AUTOSTART_EMULATION      ];
				application[ "run-background"           ].YesNo() = settings[ RUN_IN_BACKGROUND        ];
				application[ "start-fullscreen"         ].YesNo() = settings[ START_IN_FULLSCREEN      ];
				application[ "suppress-warnings"        ].YesNo() = settings[ SUPPRESS_WARNINGS        ];
				application[ "exit-power-off"           ].YesNo() = settings[ FIRST_UNLOAD_ON_EXIT     ];
				application[ "confirm-exit"             ].YesNo() = settings[ CONFIRM_EXIT             ];
				application[ "confirm-reset"            ].YesNo() = settings[ CONFIRM_RESET            ];
				application[ "allow-multiple-instances" ].YesNo() = settings[ ALLOW_MULTIPLE_INSTANCES ];

				application[ "priority" ].Str() =
				(
					settings.priority == PRIORITY_HIGH         ? "high"         :
					settings.priority == PRIORITY_ABOVE_NORMAL ? "above normal" :
                                                                 "normal"
				);

				application[ "favored-system" ].Str() =
				(
					settings.favoredSystem == Nes::Machine::FAVORED_NES_PAL ? "nes-pal"    :
					settings.favoredSystem == Nes::Machine::FAVORED_FAMICOM ? "famicom"    :
					settings.favoredSystem == Nes::Machine::FAVORED_DENDY   ? "dendy"      :
                                                                              "nes-ntsc"
				);

				application[ "favored-system-always-ask" ].YesNo() = settings.alwaysAskSystem;
			}

			{
				Configuration::Section save( preferences["save"] );

				save[ "logfile"         ].YesNo() = settings[ SAVE_LOGFILE          ];
				save[ "settings"        ].YesNo() = settings[ SAVE_SETTINGS         ];
				save[ "launcher"        ].YesNo() = settings[ SAVE_LAUNCHER         ];
				save[ "cheats"          ].YesNo() = settings[ SAVE_CHEATS           ];
				save[ "netplay-list"    ].YesNo() = settings[ SAVE_NETPLAY_GAMELIST ];
				save[ "window-main"     ].YesNo() = settings[ SAVE_WINDOWPOS        ];
				save[ "window-launcher" ].YesNo() = settings[ SAVE_LAUNCHERSIZE     ];
			}

			{
				Configuration::Section appearance( preferences["appearance"] );

				appearance[ "icon-style" ].Str() =
				(
					Application::Instance::GetIconStyle() == Application::Instance::ICONSTYLE_NES ? "nes" :
																									"famicom"
				);

				appearance[ "menu-desktop"    ][ "use-custom-color" ].YesNo() = settings.menuLookDesktop.enabled;
				appearance[ "menu-fullscreen" ][ "use-custom-color" ].YesNo() = settings.menuLookFullscreen.enabled;

				appearance[ "menu-desktop"    ][ "custom-color" ].Str() = HexString( 32, settings.menuLookDesktop.color );
				appearance[ "menu-fullscreen" ][ "custom-color" ].Str() = HexString( 32, settings.menuLookFullscreen.color );
			}
		}