Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Move INSTALL, LICENSE, README, THANKS and TODO into root directory
[xestiaab/.git] / source / common / uuid.cpp
1 // uuid.cpp - UUID subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <wx/wx.h>
21 wxString GenerateUUID()
22 {
24 #if defined(__WIN32__)
25         
26 #include <rpc.h>
27         
28         UUID UUIDData;
29         UuidCreate(&UUIDData);
30         wchar_t* UUIDStr = 0;
31         UuidToString(&UUIDData, (RPC_WSTR*)&UUIDStr);
32         wxString Result(UUIDStr);
33         
34 #elif defined(__HAIKU__)
35     
36 #else
37     
38 #include <stdio.h>
39     
40         wxString Result;
41     
42         FILE *uuid_hdl = popen("uuidgen", "r");
43     
44         if (uuid_hdl == NULL) {
45                 return Result;
46         }
47     
48         char strdata[64];
49         std::string uuidout;
50     
51         while (fgets(strdata, sizeof(strdata), uuid_hdl) != NULL){
52                 uuidout.append(strdata);
53         }
54     
55         pclose(uuid_hdl);
56     
57         Result = wxString::Format(wxT("%s"), uuidout);
58         Result.Trim();
59     
60 #endif
61     
62         return Result;
63         
64 }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy