18 #pragma warning( disable : 4996 )
26 std::vector<std::string> result;
33 char *next, *tmp1, *tmp2;
34 for ( LPTSTR cmd = ::GetCommandLine(); *cmd; cmd = next ) {
35 ::memset( exe, 0,
sizeof( exe ) );
36 while ( *cmd ==
' ' ) cmd++;
37 next = ::strchr( cmd,
' ' );
38 if ( !next ) next = cmd + ::strlen( cmd );
39 if ( ( tmp1 = ::strchr( cmd,
'\"' ) ) > 0 && tmp1 < next ) {
40 tmp2 = ::strchr( ++tmp1,
'\"' );
43 if ( cmd < tmp1 ) ::strncpy( exe, cmd, tmp1 - cmd - 1 );
44 ::strncpy( &exe[strlen( exe )], tmp1, tmp2 - tmp1 - 1 );
46 std::cout <<
"Mismatched \" in command line arguments" << std::endl;
47 return std::vector<std::string>();
50 ::strncpy( exe, cmd, next - cmd );
52 result.push_back( exe );
64 if ( ::strncmp( class_name,
"class ", 6 ) == 0 ) {
68 if ( ::strncmp( class_name,
"struct ", 7 ) == 0 ) {
73 std::string tmp = class_name + off;
75 while ( ( loc = tmp.find(
"class " ) ) > 0 ) { tmp.erase( loc, 6 ); }
77 while ( ( loc = tmp.find(
"struct " ) ) > 0 ) { tmp.erase( loc, 7 ); }
83 while ( ( off = result.find(
" *" ) ) != std::string::npos ) { result.replace( off, 2,
"*" ); }
85 while ( ( off = result.find(
" &" ) ) != std::string::npos ) { result.replace( off, 2,
"&" ); }
92 static const size_t STRING_SIZE = 512;
93 char hname[STRING_SIZE];
94 size_t strlen = STRING_SIZE;
95 if ( !::GetComputerName( hname, &strlen ) ) {
return "UNKNOWN"; }
96 return std::string( hname );
99 std::string
osName() {
return "Windows"; }
104 ut.dwOSVersionInfoSize =
sizeof( OSVERSIONINFO );
105 if ( !::GetVersionEx( &ut ) ) {
return "UNKNOWN"; }
106 std::ostringstream ver;
107 ver << ut.dwMajorVersion <<
'.' << ut.dwMinorVersion;
114 ::GetSystemInfo( &ut );
115 std::ostringstream arch;
116 arch << ut.wProcessorArchitecture;
122 static const size_t STRING_SIZE = 512;
123 char uname[STRING_SIZE];
124 size_t strlen = STRING_SIZE;
125 if ( !::GetUserName( uname, &strlen ) ) {
return "UNKNOWN"; }
126 return std::string( uname );