void Path::FillPlatformSpecificPaths() { SetToken("?temp", boost::filesystem::temp_directory_path()); SetToken("?user", WinGetFolderPath(CSIDL_APPDATA)/"Aegisub"); SetToken("?local", WinGetFolderPath(CSIDL_LOCAL_APPDATA)/"Aegisub"); std::wstring filename(MAX_PATH + 1, L'\0'); while (static_cast<DWORD>(filename.size()) == GetModuleFileNameW(nullptr, &filename[0], filename.size())) filename.resize(filename.size() * 2); SetToken("?data", filename); SetToken("?dictionary", Decode("?data/dictionaries")); }
void Message::SetToken(uint8_t aTokenLength) { uint8_t token[kMaxTokenLength] = {0}; assert(aTokenLength <= sizeof(token)); Random::FillBuffer(token, aTokenLength); SetToken(token, aTokenLength); }
void Path::FillPlatformSpecificPaths() { #ifndef __APPLE__ agi::fs::path home = home_dir(); SetToken("?user", home/".aegisub"); SetToken("?local", home/".aegisub"); SetToken("?data", P_DATA); #else agi::fs::path app_support = agi::util::GetApplicationSupportDirectory(); SetToken("?user", app_support/"Aegisub"); SetToken("?local", app_support/"Aegisub"); SetToken("?data", agi::util::GetBundleSharedSupportDirectory()); #endif SetToken("?temp", boost::filesystem::temp_directory_path()); SetToken("?dictionary", "/usr/share/hunspell"); SetToken("?docs", P_DOC); }
void Header::SetToken(uint8_t aTokenLength) { assert(aTokenLength <= kMaxTokenLength); uint8_t token[kMaxTokenLength] = { 0 }; for (uint8_t i = 0; i < aTokenLength; i++) { token[i] = static_cast<uint8_t>(otPlatRandomGet()); } SetToken(token, aTokenLength); }
void Path::FillPlatformSpecificPaths() { agi::fs::path home = home_dir(); SetToken("?user", home/".aegisub"); SetToken("?local", home/".aegisub"); SetToken("?data", data_dir()); SetToken("?temp", boost::filesystem::temp_directory_path()); SetToken("?dictionary", "/usr/share/hunspell"); SetToken("?docs", P_DOC); }
int CNetConnection::Connect(NETADDR *pAddr) { if(State() != NET_CONNSTATE_OFFLINE) return -1; // init connection Reset(); m_PeerAddr = *pAddr; m_PeerToken = NET_TOKEN_NONE; SetToken(GenerateToken(pAddr)); mem_zero(m_ErrorString, sizeof(m_ErrorString)); m_State = NET_CONNSTATE_TOKEN; SendControlWithToken(NET_CTRLMSG_TOKEN); return 0; }
// nsPKCS12Blob::ImportFromFile // // Given a file handle, read a PKCS#12 blob from that file, decode it, // and import the results into the token. nsresult nsPKCS12Blob::ImportFromFile(nsILocalFile *file) { nsNSSShutDownPreventionLock locker; nsresult rv = NS_OK; if (!mToken) { if (!mTokenSet) { rv = SetToken(NULL); // Ask the user to pick a slot if (NS_FAILED(rv)) { handleError(PIP_PKCS12_USER_CANCELED); return rv; } } } if (!mToken) { handleError(PIP_PKCS12_RESTORE_FAILED); return NS_ERROR_NOT_AVAILABLE; } // init slot rv = mToken->Login(true); if (NS_FAILED(rv)) return rv; RetryReason wantRetry; do { rv = ImportFromFileHelper(file, im_standard_prompt, wantRetry); if (NS_SUCCEEDED(rv) && wantRetry == rr_auto_retry_empty_password_flavors) { rv = ImportFromFileHelper(file, im_try_zero_length_secitem, wantRetry); } } while (NS_SUCCEEDED(rv) && (wantRetry != rr_do_not_retry)); return rv; }
void Header::SetDefaultResponseHeader(const Header &aRequestHeader) { Init(OT_COAP_TYPE_ACKNOWLEDGMENT, OT_COAP_CODE_CHANGED); SetMessageId(aRequestHeader.GetMessageId()); SetToken(aRequestHeader.GetToken(), aRequestHeader.GetTokenLength()); }
static base_n addtotable( token_n *tokens, token_n *end_token, action_n *actions, token_n default_token, token_n parent_token ) { base_n start, i; token_n max; action_n default_action; token_n *r; a_table *t; a_table *tstart; action_n actval; token_n tokval; if( compactflag ) { start = used++; expand_table( used ); // Leave room for parent & default default_action = ACTION_NULL; for( r = tokens; r < end_token; ++r ) { tokval = *r; if( tokval == default_token ) { default_action = actions[tokval]; } else if( tokval != parent_token ) { actval = actions[tokval]; if( tokval > 0x0FFF ) { printf( "Error: token index 0x%X for item %d is higher then 0x0FFF !\n", tokval, start ); } if( actval > 0x0FFF ) { printf( "Error: token action 0x%X for item %d is higher then 0x0FFF !\n", actval, start ); } expand_table( used + 1 ); table[used].token = tokval; table[used].action = actval; ++used; } } actval = actions[parent_token]; if( actval > 0x0FFF ) { printf( "Error: parent action 0x%X for item %d is higher then 0x0FFF !\n", actval, start ); } if( default_action > 0x0FFF ) { printf( "Error: default action 0x%X for item %d is higher then 0x0FFF !\n", default_action, start ); } table[start].token = (token_n)actval; table[start].action = default_action; } else { max = *tokens; for( r = tokens + 1; r < end_token; ++r ) { if( *r > max ) { max = *r; } } for( start = 0; ; ++start ) { i = avail; expand_table( start + max + 1 ); while( i < avail ) { table[i].token = TOKEN_IMPOSSIBLE; table[i].action = ACTION_NULL; ++i; } tstart = table + start; if( !IsBase( tstart ) ) { for( r = tokens; r < end_token; ++r ) { if( IsUsed( tstart + *r ) ) { break; } } if( r >= end_token ) { break; } } } SetBase( tstart ); for( r = tokens; r < end_token; ++r ) { tokval = *r; t = tstart + tokval; if( ! bigflag ) { if( tokval >= UCHAR_MAX ) { msg( "too many tokens!\n" ); } } SetToken( t, tokval ); actval = actions[tokval]; if( (actval & ACTION_MASK) != actval ) { printf( "Error: token action 0x%X for token %d is higher then 0x3FFF !\n", actval, tokval ); } SetAction( t, actval ); } i = start + max + 1; if( i > used ) { used = i; } } return( start ); }