int ClusterMapLink::Save(string directory) { char uuid_s[36]; char uuid_src[36], uuid_dest[36]; UuidToString(&SourceClusterMapUUID,(RPC_CSTR*)uuid_src); UuidToString(&DestinationClusterMapUUID,(RPC_CSTR*)uuid_dest); UuidToString(&UUID_inst,(RPC_CSTR*)uuid_s); string uuid_ss = string(uuid_s); string _ClusterMapLinkDir = directory + "/" + uuid_ss; LPSECURITY_ATTRIBUTES attr = NULL; //create a directory with the ClusterMap UUID number CreateDirectory(_ClusterMapLinkDir.c_str(),attr); //mkdir(_ClusterMapLinkDir.c_str(),S_IFDIR | S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if(errno == EEXIST) return 2; //ClusterMapLink already saved.... SaveLoadCNN::SaveAxonData(join_axons,_ClusterMapLinkDir+"/axons.xml"); SaveLinkData(uuid_src,uuid_dest,_ClusterMapLinkDir+"/header.lnk"); return 0; }
std::wstring Directory::CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot) { UUID uuid; RPC_WSTR str_uuid; UuidCreate (&uuid); UuidToString (&uuid, &str_uuid); std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR; pcTemplate += (TCHAR *) str_uuid; RpcStringFree (&str_uuid); int attemps = 10; while (!CreateDirectory(pcTemplate)) { UuidCreate (&uuid); UuidToString (&uuid, &str_uuid); pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR; pcTemplate += (TCHAR *) str_uuid; RpcStringFree (&str_uuid); attemps--; if (0 == attemps) { pcTemplate = _T(""); } } return pcTemplate; }
// update string representation of new UUID void Uuid::Set(const UUID &uuid) { m_uuid = uuid; // get string representation #ifdef _UNICODE UuidToString(&m_uuid, (unsigned short **)&m_pszUuid); #else UuidToString(&m_uuid, &m_pszUuid); #endif // cache UUID in C format UuidToCForm(); }
LRESULT FilterOnInfoTip( IN HWND hWnd, IN HWND hWndTree, IN LPNMTVGETINFOTIP lp ) { HTREEITEM Parent; PBTR_FILTER Filter; PFILTER_NODE Node; RPC_WSTR Uuid = NULL; Parent = TreeView_GetParent(hWndTree, lp->hItem); if (!Parent) { Node = (PFILTER_NODE)lp->lParam; Filter = Node->Filter; UuidToString(&Filter->FilterGuid, &Uuid); StringCchPrintf(lp->pszText, lp->cchTextMax, FILTER_INFOTIP_FORMAT, Filter->FilterName, Filter->Description, Uuid, Filter->MajorVersion, Filter->MinorVersion, Filter->Author ); RpcStringFree(&Uuid); } return 0; }
BOOL InstallGUIDKey(GUID& guidKey, HKEY hkey, LPCTSTR strSubKey) { HKEY hkeyNew, hKeySub; DWORD dwDisposition; LONG nReturn; BOOL b = FALSE; nReturn = RegCreateKeyEx(hkey,strSubKey,0,0,REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,0,&hKeySub,&dwDisposition); if (ERROR_SUCCESS == nReturn) { UCHAR* wcs; char buf[1024]; UuidToString(&guidKey,&wcs); sprintf(buf,"{%s}",wcs); strupr(buf); RpcStringFree(&wcs); nReturn = RegCreateKeyEx(hKeySub,buf,0,0,REG_OPTION_NON_VOLATILE, KEY_READ,0,&hkeyNew,&dwDisposition); if (ERROR_SUCCESS == nReturn) { RegCloseKey(hkeyNew); b = TRUE; } RegCloseKey(hKeySub); } return b; }
COMError::COMError(HRESULT hr) { _com_error e(hr); IErrorInfo *pIErrorInfo = NULL; GetErrorInfo(0, &pIErrorInfo); if (pIErrorInfo == NULL) { e = _com_error(hr); message = e.ErrorMessage(); } else { e = _com_error(hr, pIErrorInfo); message = e.ErrorMessage(); IErrorInfo *ptrIErrorInfo = e.ErrorInfo(); if (ptrIErrorInfo != NULL) { // IErrorInfo Interface located description = (WCHAR *)e.Description(); source = (WCHAR *)e.Source(); GUID tmpGuid = e.GUID(); RPC_WSTR guidStr = NULL; // must link in Rpcrt4.lib for UuidToString UuidToString(&tmpGuid, &guidStr); uuid = (WCHAR*)guidStr; RpcStringFree(&guidStr); ptrIErrorInfo->Release(); } } }
RPC_STATUS GuidToString( UUID *Uuid, LPTSTR StringGuid ) { RPC_STATUS Status; LPTSTR pTempStringGuid; Status = UuidToString(Uuid, &pTempStringGuid); if (Status == RPC_S_OK) { // // the form we want is all uppercase and with curly brackets around, // like what OLE does // lstrcpy(StringGuid, TEXT("{")); lstrcat(StringGuid, pTempStringGuid); lstrcat(StringGuid, TEXT("}")); CharUpper(StringGuid); RpcStringFree(&pTempStringGuid); } return Status; } // GuidToString
static int PrintInterfaces(struct rx_connection *aconn) { Capabilities caps; struct interfaceAddr addr; #ifdef AFS_NT40_ENV char * p; #else char uuidstr[128]; #endif int i, code; char hoststr[16]; caps.Capabilities_val = NULL; caps.Capabilities_len = 0; code = RXAFSCB_TellMeAboutYourself(aconn, &addr, &caps); if (code == RXGEN_OPCODE) code = RXAFSCB_WhoAreYou(aconn, &addr); if (code) { printf("cmdebug: error checking interfaces: %s\n", afs_error_message(code)); return 0; } #ifdef AFS_NT40_ENV UuidToString((UUID *)&addr.uuid, &p); printf("UUID: %s\n",p); RpcStringFree(&p); #else afsUUID_to_string(&addr.uuid, uuidstr, sizeof(uuidstr)); printf("UUID: %s\n",uuidstr); #endif printf("Host interfaces:\n"); for (i = 0; i < addr.numberOfInterfaces; i++) { printf("%s", afs_inet_ntoa_r(htonl(addr.addr_in[i]), hoststr)); if (addr.subnetmask[i]) printf(", netmask %s", afs_inet_ntoa_r(htonl(addr.subnetmask[i]), hoststr)); if (addr.mtu[i]) printf(", MTU %d", addr.mtu[i]); printf("\n"); } if (caps.Capabilities_val) { printf("Capabilities:\n"); if (caps.Capabilities_val[0] & CAPABILITY_ERRORTRANS) { printf("Error Translation\n"); } printf("\n"); } if (caps.Capabilities_val) free(caps.Capabilities_val); caps.Capabilities_val = NULL; caps.Capabilities_len = 0; return 0; }
void UnregisterBluetoothSignalHandler(const BluetoothUuid& aUuid, BluetoothSignalObserver* aHandler) { nsAutoString path; UuidToString(aUuid, path); UnregisterBluetoothSignalHandler(path, aHandler); }
zmq::uuid_t::uuid_t () { RPC_STATUS ret = UuidCreate (&uuid); zmq_assert (ret == RPC_S_OK); ret = UuidToString (&uuid, &string_buf); zmq_assert (ret == RPC_S_OK); create_blob (); }
// copy ctor Uuid::Uuid(const Uuid& uuid) { // bitwise copy Ok for UUIDs m_uuid = uuid.m_uuid; // force the string to be allocated by RPC // (we free it later with RpcStringFree) #ifdef _UNICODE UuidToString(&m_uuid, (unsigned short **)&m_pszUuid); #else UuidToString(&m_uuid, &m_pszUuid); #endif // allocate new buffer m_pszCForm = new wxChar[UUID_CSTRLEN]; // and fill it memcpy(m_pszCForm, uuid.m_pszCForm, UUID_CSTRLEN*sizeof(wxChar)); }
char* pn_i_genuuid(void) { unsigned char *generated; UUID uuid; UuidCreate(&uuid); UuidToString(&uuid, &generated); char* r = pn_strdup((const char*)generated); RpcStringFree(&generated); return r; }
BOOL UuidCreateToString(TCHAR ** StringUuid) { UUID Uuid; RPC_STATUS Status = UuidCreate(&Uuid); if (Status == RPC_S_OK) { Status = UuidToString(&Uuid, StringUuid); } return Status == RPC_S_OK; }
void gen_uuid_inplace (char *buf) { unsigned char *str = NULL; UUID uuid; UuidCreate(&uuid); UuidToString(&uuid, &str); memcpy(buf, str, 37); RpcStringFree(&str); }
static void uuid_to_string(uuid_t *uuid, char *uuid_str) { #ifdef __MINGW32__ RPC_CSTR tmp; UuidToString(uuid, &tmp); strcpy(uuid_str, tmp); RpcStringFree(&tmp); #elif __linux__ uuid_unparse_lower(*uuid, uuid_str); #endif }
void ReversedUuidToString(const BluetoothUuid& aUuid, nsAString& aString) { BluetoothUuid uuid; for (uint8_t i = 0; i < 16; i++) { uuid.mUuid[i] = aUuid.mUuid[15 - i]; } UuidToString(uuid, aString); }
SWITCH_DECLARE(void) switch_uuid_format(char *buffer, const switch_uuid_t *uuid) { #ifndef WIN32 apr_uuid_format(buffer, (const apr_uuid_t *) uuid); #else RPC_CSTR buf; UuidToString((const UUID *) uuid, &buf); strcpy(buffer, (const char *) buf); RpcStringFree(&buf); #endif }
void uuuid_to_string(struct uuuid_t* uuuid, char** out, int* status) { RPC_STATUS st; st = UuidToString(&uuuid->uuid, (unsigned char**) out); if (st == RPC_S_OK) *status = UUUID_OK; else *status = UUUID_ERR; }
void GeneratePathFromGattId(const BluetoothGattId& aId, nsAString& aPath) { nsString uuidStr; UuidToString(aId.mUuid, uuidStr); aPath.Assign(uuidStr); aPath.AppendLiteral("_"); aPath.AppendInt(aId.mInstanceId); }
void uuid_unparse (const uuid_t uu, char *out) { unsigned char *formatted; if (UuidToString((UUID*)uu, &formatted) == RPC_S_OK) { #ifdef _MSC_VER strncpy_s (out, 36+1, (char*)formatted, _TRUNCATE); #else strncpy (out, (char*)formatted, 36+1); #endif RpcStringFree(&formatted); } }
// assignment operator Uuid& Uuid::operator=(const Uuid& uuid) { m_uuid = uuid.m_uuid; // force the string to be allocated by RPC // (we free it later with RpcStringFree) #ifdef _UNICODE UuidToString(&m_uuid, (unsigned short **)&m_pszUuid); #else UuidToString(&m_uuid, &m_pszUuid); #endif // allocate new buffer if not done yet if ( !m_pszCForm ) m_pszCForm = new wxChar[UUID_CSTRLEN]; // and fill it memcpy(m_pszCForm, uuid.m_pszCForm, UUID_CSTRLEN*sizeof(wxChar)); return *this; }
char* gen_uuid () { char *uuid_str = g_malloc (37); unsigned char *str = NULL; UUID uuid; UuidCreate(&uuid); UuidToString(&uuid, &str); memcpy(uuid_str, str, 37); RpcStringFree(&str); return uuid_str; }
void Guid::_generate() { GUID guid; RPC_WSTR pszUuid = 0; if (UuidCreate(&guid) == RPC_S_OK) { UuidToString(&guid, &pszUuid); m_guid = (wchar_t*) pszUuid; RpcStringFree(&pszUuid); } g_log.Log(L"Guid::_generate. Guid: '%s'", (wchar_t *) m_guid.c_str()); }
void GenerateUUID(LPTSTR szUUID, int size) { UUID bUuid; #ifdef UNICODE RPC_WSTR rstrUUID; #else RPC_CSTR rstrUUID; #endif UuidCreate(&bUuid); UuidToString(&bUuid, &rstrUUID); lstrcpyn(szUUID, (LPCTSTR) rstrUUID, size); RpcStringFree(&rstrUUID); }
void CedExporter::FillGuidString(CString& s) const { // See http://forums.codeguru.com/showthread.php?t=379736 GUID Guid; CoCreateGuid(&Guid); //RPC_WSTR str; unsigned char* str; UuidToString((UUID*)&Guid, &str); s = (LPTSTR)str; s.MakeUpper(); RpcStringFree(&str); }
static void guid_to_string(REFCLSID rclsid,std::wstring& v) { HRESULT hr; RPC_WSTR lpolestr; if((hr=UuidToString(&rclsid,&lpolestr ))==S_OK) { v=(LPCWSTR)lpolestr; RpcStringFree (&lpolestr); } else { if(hr!=S_OK) throw _com_error(hr); } }
void UUID_ToString(GUID *uuid,PSTR szUUID) { #ifdef WIN32 PBYTE StringUuid; UuidToString(uuid,&StringUuid); strcpy(szUUID,StringUuid); RpcStringFree(&StringUuid); #endif //WIN32 #ifdef HAVE_UUID_UNPARSE uuid_unparse(*uuid,szUUID); #endif //HAVE_UUID_UNPARSE strupr(szUUID); }
// set the value bool Uuid::Set(const wxChar *pc) { // get UUID from string #ifdef _UNICODE if ( UuidFromString((unsigned short *)pc, &m_uuid) != RPC_S_OK) #else if ( UuidFromString((wxUChar *)pc, &m_uuid) != RPC_S_OK) #endif // failed: probably invalid string return false; // transform it back to string to normalize it #ifdef _UNICODE UuidToString(&m_uuid, (unsigned short **)&m_pszUuid); #else UuidToString(&m_uuid, &m_pszUuid); #endif // update m_pszCForm UuidToCForm(); return true; }
zmq::uuid_t::uuid_t () { RPC_STATUS ret = UuidCreate (&uuid); zmq_assert (ret == RPC_S_OK); ret = UuidToString (&uuid, &uuid_str); zmq_assert (ret == RPC_S_OK); /* HRESULT hr = CoCreateGUID (&uuid); zmq_assert (hr == S_OK); int rc = StringFromGUID2 (uuid, uuid_str, 40); zmq_assert (rc != 0); */ }
int main() { unsigned char *uuid_string; UUID my_uuid; RPC_STATUS status; status = UuidCreate(&my_uuid); status = UuidToString(&my_uuid, &uuid_string); printf("%s", uuid_string); status = RpcStringFree(&uuid_string); }