Index: windows-NT/cvsdiag/cvsdiag.cpp =================================================================== RCS file: /cvs/cvsnt/windows-NT/cvsdiag/cvsdiag.cpp,v retrieving revision 1.1.2.8.8.43.2.54 diff -c -r1.1.2.8.8.43.2.54 cvsdiag.cpp *** windows-NT/cvsdiag/cvsdiag.cpp 12 Jun 2020 03:04:06 -0000 1.1.2.8.8.43.2.54 --- windows-NT/cvsdiag/cvsdiag.cpp 12 Jun 2020 05:49:57 -0000 *************** *** 29,34 **** --- 29,43 ---- #define SM_SERVERR2 89 #endif + typedef struct user_name_struct { + std::string fullname; + std::list allnames; + unsigned count; + user_name_struct() : count(0) + { + } + } user_name_t; + typedef std::map user_list_t; int win32_global_codepage = CP_ACP; /* Not all systems set the same error code on a non-existent-file *************** *** 135,140 **** --- 144,162 ---- TCHAR buf[MAX_PATH]; DWORD bufLen; DWORD dwType; + user_list_t list_of_users; + size_t comlen, namestart; + TCHAR comname[257]; + DWORD dwLenGCA; + dwLenGCA=sizeof(comname); + memset(comname,'\0',dwLenGCA); + GetComputerNameEx(ComputerNameNetBIOS, comname, &dwLenGCA); + if (comname[0]!='\0') + { + strcat(comname,"\\"); + comlen=strlen(comname); + } else + comlen=0; bufLen=sizeof(buf); *************** *** 152,162 **** if (_tcsncmp(myname,_T("user_"),5)!=0) continue; ! logged_in_users++; ! _ftprintf(output,_T("User %d: %s\n"),logged_in_users,myname+5); } RegCloseKey(g_hLicenseKey); return logged_in_users; } --- 174,205 ---- if (_tcsncmp(myname,_T("user_"),5)!=0) continue; ! if ((comlen>0) && (strncmp(comname,myname+5,comlen)==0)) ! namestart=5+comlen; ! else ! namestart=5; ! list_of_users[myname+namestart].fullname=myname+5; ! list_of_users[myname+namestart].allnames.push_back(myname+5); ! list_of_users[myname+namestart].allnames.sort(); ! list_of_users[myname+namestart].allnames.unique(); ! list_of_users[myname+namestart].count++; } RegCloseKey(g_hLicenseKey); + + for(user_list_t::const_iterator i = list_of_users.begin(); i!=list_of_users.end(); ++i) + { + logged_in_users++; + std::string allnames; + for (std::list::const_iterator it = i->second.allnames.begin(); it != i->second.allnames.end(); ++it){ + allnames+=*it; + allnames+=","; + } + // remove the trailing comma + if (allnames.length()>0) + allnames[allnames.length()-1]='\0'; + _ftprintf(output,_T("User %d: %s (count:%u; list: %s)\n"),logged_in_users,i->first.c_str(),i->second.count,allnames.c_str()); + } return logged_in_users; } Index: windows-NT/cvsdiag/stdafx.h =================================================================== RCS file: /cvs/cvsnt/windows-NT/cvsdiag/stdafx.h,v retrieving revision 1.1.2.2.8.2.2.2 diff -c -r1.1.2.2.8.2.2.2 stdafx.h *** windows-NT/cvsdiag/stdafx.h 15 Feb 2011 22:57:38 -0000 1.1.2.2.8.2.2.2 --- windows-NT/cvsdiag/stdafx.h 12 Jun 2020 03:50:01 -0000 *************** *** 12,17 **** --- 12,20 ---- #include #include #include + #include + #include + #include #include #include #include