void FileTabs::InsertFiles(int ix, const Vector<String> &files, const Vector<Image> &img, bool make_active) { if (!files.GetCount()) return; bool useimg = img.GetCount() == files.GetCount(); for (int i = files.GetCount() - 1; i > 0; i--) { TabBar::InsertKey0(ix, files[i].ToWString(), GetFileName(files[i]), useimg ? img[i] : NativePathIcon(files[i]), GetFileGroup(files[i])); } InsertFile(ix, files[0].ToWString(), useimg ? img[0] : NativePathIcon(files[0]), make_active); }
void FileTabs::InsertFile(int ix, const WString &file, Image img, bool make_active) { String s = file.ToString(); TabBar::InsertKey(ix, file, GetFileName(s), img, GetFileGroup(s), make_active); }
static int32_t loadRsaKeys( sslKeys_t *keys, LOGICAL client ) { uint32_t priv_key_len = 0; uint32_t cert_key_len = 0; unsigned char *CAstream = NULL; int32_t CAstreamLen = 0; int32_t rc; TEXTCHAR buf[256]; TEXTCHAR privkey_buf[256]; TEXTCHAR cert_buf[256]; unsigned char *priv_key = NULL; unsigned char *cert_key = NULL; FILE *file; size_t size; int fileGroup = GetFileGroup( "ssl certs", "certs" ); { /* In-memory based keys Build the CA list first for potential client auth usage */ int n; CAstreamLen = 0; for( n = 0; n < ( sizeof( default_certs ) / sizeof( default_certs[0] ) ); n++ ) { file = sack_fopen( fileGroup, default_certs[n], "rb" ); if( file ) { size = sack_fsize( file ); CAstreamLen += size; sack_fclose( file ); } } { /* In-memory based keys Build the CA list first for potential client auth usage */ priv_key_len = 0; SACK_GetProfileString( "SSL/Private Key", "filename", "myprivkey.pem", privkey_buf, 256 ); file = sack_fopen( fileGroup, privkey_buf, "rb" ); if( file ) { priv_key_len = sack_fsize( file ); priv_key = NewArray( uint8_t, priv_key_len ); sack_fread( priv_key, 1, priv_key_len, file ); sack_fclose( file ); } else priv_key = NULL; } SACK_GetProfileString( "SSL/Cert Authority Extra", "filename", "mycert.pem", cert_buf, 256 ); file = sack_fopen( fileGroup, cert_buf, "rb" ); if( file ) { CAstreamLen += sack_fsize( file ); sack_fclose( file ); } if( CAstreamLen ) CAstream = NewArray( uint8_t, CAstreamLen); CAstreamLen = 0; for( n = 0; n < ( sizeof( default_certs ) / sizeof( default_certs[0] ) ); n++ ) { file = sack_fopen( fileGroup, default_certs[n], "rb" ); if( file ) { size = sack_fsize( file ); CAstreamLen += sack_fread( CAstream + CAstreamLen, 1, size, file ); //rc = matrixSslLoadRsaKeysMem(keys, NULL, 0, NULL, 0, CAstream+ CAstreamLen, size ); //lprintf( "cert success : %d %s", rc, default_certs[n] ); //CAstream[CAstreamLen++] = '\n'; sack_fclose( file ); } } file = sack_fopen( fileGroup, cert_buf, "rb" ); if( file ) { size = sack_fsize( file ); CAstreamLen += sack_fread( CAstream + CAstreamLen, 1, size, file ); sack_fclose( file ); } } //if( 0 ) { /* In-memory based keys Build the CA list first for potential client auth usage */ cert_key_len = 0; SACK_GetProfileString( "SSL/Certificate", "filename", "mycert.pem", cert_buf, 256 ); file = sack_fopen( fileGroup, cert_buf, "rb" ); if( file ) { cert_key_len = sack_fsize( file ); cert_key = NewArray( uint8_t, cert_key_len ); sack_fread( cert_key, 1, cert_key_len, file ); sack_fclose( file ); } else cert_key = NULL; } if( cert_key_len || priv_key_len || CAstreamLen ) { rc = matrixSslLoadRsaKeysMem(keys , cert_key, cert_key_len , priv_key, priv_key_len , CAstream, CAstreamLen ); if (rc < 0) { lprintf("No certificate material loaded. Exiting"); //if (CAstream) { // Deallocate(uint8_t*, CAstream); //} matrixSslDeleteKeys(keys); matrixSslClose(); } if( cert_key_len ) Release( cert_key ); if( priv_key_len ) Release( priv_key ); if( CAstream ) Release( CAstream ); return rc; } return PS_SUCCESS; }