ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSFinger/CCSFinger.cpp
(Generate patch)

Comparing CCSFinger/CCSFinger.cpp (file contents):
Revision 618 by douglas, 2005-12-13T02:23:55-08:00 vs.
Revision 640 by douglas, 2006-01-04T20:54:20-08:00

# Line 70 | Line 70 | inline std::string Utf8(const std::wstri
70          return string;
71   }
72  
73 + inline std::wstring Utf8(const std::string &string)
74 + {
75 +        std::wstring wstring(::MultiByteToWideChar(CP_UTF8, 0, string.data(), int(string.size()), NULL, 0), '\0');
76 +
77 +        ::MultiByteToWideChar(CP_UTF8, 0, string.data(), int(string.size()), const_cast<LPWSTR>(wstring.data()), int(wstring.size()));
78 +
79 +        return wstring;
80 + }
81 +
82   class Finger
83   {
84          class Login
# Line 146 | Line 155 | class Finger
155          {
156                  for (std::multimap<std::string, Login>::const_iterator login(logins.begin()); login != logins.end(); login = logins.upper_bound(login->first))
157                  {
158 +                        if (login != logins.begin())
159 +                                stream << "\r\n";
160 +
161                          std::string directory(login->second.GetDirectory());
162  
163                          stream << "Login: " << login->first << std::string(33 - login->first.size(), ' ') << "Name: " << login->second.GetName() << "\r\nDirectory: " << directory << "\r\n";
# Line 230 | Line 242 | public:
242                          Full();
243          }
244  
245 <        Finger(const std::string &name)
245 >        Finger(const std::string &name_)
246          {
247 <                //NetQueryDisplayInformation
248 <                //NetUserGetInfo
247 >                std::wstring name(Utf8(name_));
248 >
249 >                std::transform(name.begin(), name.end(), name.begin(), std::towlower);
250 >
251 >                DWORD size;
252 >                PNET_DISPLAY_USER users;
253 >
254 >                ::NetQueryDisplayInformation(NULL, 1, 0, 100, MAX_PREFERRED_LENGTH, &size, reinterpret_cast<PVOID *>(&users));
255 >
256 >                 for (PNET_DISPLAY_USER user = users; user != users + size; ++user)
257 >                 {
258 >                         std::wstring name_(user->usri1_name);
259 >
260 >                         std::transform(name_.begin(), name_.end(), name_.begin(), std::towlower);
261 >
262 >                         if (name_.find(name) != std::wstring::npos)
263 >                                 ;//logins.insert(std::make_pair(Utf8(name_),
264 >                         else
265 >                         {
266 >                                 std::wstring full(user->usri1_full_name);
267 >
268 >                                 std::transform(full.begin(), full.end(), full.begin(), std::towlower);
269 >
270 >                                 if (full.find(name) != std::wstring::npos)
271 >                                         ;//logins.insert(std::make_pair(Utf8(name_),
272 >                         }
273 >                 }
274 >
275 >                 ::NetApiBufferFree(users);
276 >                
277 >                 if (!logins.empty())
278 >                        Full();
279 >                 else
280 >                         stream << "finger: " << name_ << ": no such user\r\n";
281          }
282  
283          inline operator std::string()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines