#include <openssl/asn1.h>
#include <openssl/sha.h>
#include <openssl/rsa.h>
#include <openssl/x509.h>

BIO *mem = BIO_new( BIO_s_mem() );
 if ( !ASN1_parse(mem, (unsigned char*) strData.c_str(), strData.length(), 3) )
  return -1;

 BUF_MEM *bptr;
 BIO_get_mem_ptr ( mem, &bptr );
 BIO_set_close ( mem, BIO_NOCLOSE ); /* So BIO_free() leaves BUF_MEM alone */

 string strParseRtn = "";
 strParseRtn.append( bptr->data );

 BUF_MEM_free( bptr );
 BIO_free(mem);

 strParseRtn 파싱된 값이 일정한 형식대로 파싱됨...그걸 스트링 구분해서 값을 가져오면 됨

AND

/*Base64.h*/
#ifndef __BASE64_H
#define __BASE64_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>

class CBase64
{
public:
 CBase64(void);
 ~CBase64(void);
 
 static std::string Decode( const std::string& data );
 static std::string Encode( const std::string& data );
};
#endif // __BASE64_H


============================================================================


/*Base64.cpp*/
#include "Base64.h"
#include <stdio.h>

using namespace std;

static const char           fillchar = '=';
static const string::size_type  np = string::npos;
static const string   Base64Table("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");         
 // Decode Table gives the index of any valid base64 character in the Base64 table]
 // 65 == A, 97 == a, 48 == 0, 43 == +, 47 == /

                                                // 0  1  2  3  4  5  6  7  8  9
const string::size_type DecodeTable[] =       {np,np,np,np,np,np,np,np,np,np,  // 0 - 9
                                               np,np,np,np,np,np,np,np,np,np,  //10 -19
                                               np,np,np,np,np,np,np,np,np,np,  //20 -29
                                               np,np,np,np,np,np,np,np,np,np,  //30 -39
                                               np,np,np,62,np,np,np,63,52,53,  //40 -49
                                               54,55,56,57,58,59,60,61,np,np,  //50 -59
                                               np,np,np,np,np, 0, 1, 2, 3, 4,  //60 -69
                                               5, 6, 7, 8, 9,10,11,12,13,14,  //70 -79
                                               15,16,17,18,19,20,21,22,23,24,  //80 -89
                                               25,np,np,np,np,np,np,26,27,28,  //90 -99
                                               29,30,31,32,33,34,35,36,37,38,  //100 -109
                                               39,40,41,42,43,44,45,46,47,48,  //110 -119
                                               49,50,51,np,np,np,np,np,np,np,  //120 -129
                                               np,np,np,np,np,np,np,np,np,np,  //130 -139
                                               np,np,np,np,np,np,np,np,np,np,  //140 -149
                                               np,np,np,np,np,np,np,np,np,np,  //150 -159
                                               np,np,np,np,np,np,np,np,np,np,  //160 -169
                                               np,np,np,np,np,np,np,np,np,np,  //170 -179
                                               np,np,np,np,np,np,np,np,np,np,  //180 -189
                                               np,np,np,np,np,np,np,np,np,np,  //190 -199
                                               np,np,np,np,np,np,np,np,np,np,  //200 -209
                                               np,np,np,np,np,np,np,np,np,np,  //210 -219
                                               np,np,np,np,np,np,np,np,np,np,  //220 -229
                                               np,np,np,np,np,np,np,np,np,np,  //230 -239
                                               np,np,np,np,np,np,np,np,np,np,  //240 -249
                                               np,np,np,np,np,np};             //250 -256

CBase64::CBase64(void)
{
}

CBase64::~CBase64(void)
{
}

string CBase64::Encode(const string& data)
{
 string::size_type  i;
 char               c;
 string::size_type  len = data.length();
 string             ret;
 
 ret.reserve(len * 2);
 
 for (i = 0; i < len; ++i)
 {
   c = (data[i] >> 2) & 0x3f;
   ret.append(1, Base64Table[c]);
   c = (data[i] << 4) & 0x3f;
   if (++i < len)
       c |= (data[i] >> 4) & 0x0f;
  
   ret.append(1, Base64Table[c]);
   if (i < len)
   {
       c = (data[i] << 2) & 0x3f;
       if (++i < len)
           c |= (data[i] >> 6) & 0x03;
  
       ret.append(1, Base64Table[c]);
   }
   else
   {
       ++i;
       ret.append(1, fillchar);
   }
  
   if (i < len)
   {
       c = data[i] & 0x3f;
       ret.append(1, Base64Table[c]);
   }
   else
   {
       ret.append(1, fillchar);
   }
 }
 
 return(ret);
}

string CBase64::Decode(const string& data)
{
 string::size_type  i;
 char               c;
 char                c1;
 string::size_type  len = data.length();
 string             ret;
 
 ret.reserve(len);
 
 for (i = 0; i < len; ++i)
 {
   c = (char) DecodeTable[(unsigned char)data[i]];
   ++i;
   c1 = (char) DecodeTable[(unsigned char)data[i]];
   c = (c << 2) | ((c1 >> 4) & 0x3);
   ret.append(1, c);
   if (++i < len)
   {
       c = data[i];
       if (fillchar == c)
           break;
  
       c = (char) DecodeTable[(unsigned char)data[i]];
       c1 = ((c1 << 4) & 0xf0) | ((c >> 2) & 0xf);
       ret.append(1, c1);
   }
  
   if (++i < len)
   {
       c1 = data[i];
       if (fillchar == c1)
           break;
  
       c1 = (char) DecodeTable[(unsigned char)data[i]];
       c = ((c << 6) & 0xc0) | c1;
       ret.append(1, c);
   }
 }
 
 return(ret);
}

AND

...

struct thread_func_args
{
 CTCPComm_Process pThis;
 unsigned int arg;
 
 thread_func_args (CTCPComm_Process t,unsigned int p)
  : pThis(t),arg(p){}
};

unsigned int socket_array[MAX_SOCKET];

...

 ....
 
 CTCPComm_Process tcp_proc;
 tcp_proc.m_nLsnSocketHandle=&m_nLsnSocketHandle;

 #ifndef WIN32
   pthread_mutex_lock(&mutex);
   socket_array[nConnection_Count++]=client_sockfd; //client_sockfd는 소켓통신시  accept로 받은 소켓 핸들 값 이게 뒤에 인자로 전달...

   thread_func_args pthread_args(tcp_proc,socket_array[nConnection_Count-1]);
   LOG4CPLUS_INFO(logger,"Current Thread Cnt " << socket_array[nConnection_Count-1]);
   pthread_mutex_unlock(&mutex);
 #endif
 

 LOG4CPLUS_INFO(logger,"Current Thread Cnt " << pthread_args.arg);
 status = pthread_create(&hThread,
                NULL,
      &CTCPComm::ValidateData_Client,
                &pthread_args);
                   
 if (status!=0){
     LOG4CPLUS_ERROR(logger, "CTCPComm::Client pthread_create 실패 nRtnValue = " << status);
     close(client_sockfd);  
     client_sockfd=-1;
 }
 pthread_detach( hThread ); //이걸 안하면 메모리 릭이 발생함
 
   ...




/*ValidateData_Client ==> static이어야 한다.*/
void* CTCPComm::ValidateData_Client(void* Parameter)
#endif
{

  thread_func_args* tf_args=static_cast<thread_func_args*>(Parameter);
  CTCPComm_Process pLocalThis=tf_args->pThis;
    
   pLocalThis.ValidateCall(tf_args->arg);

  delete tf_args;
  pthread_exit((void *)NULL);
  
}

AND

Problem(Abstract)
Users will see an "ORA-00988: missing or invalid password(s)" error from Oracle if any of their passwords for WebSphere Partner Gateway begin with a number.
 
Cause
Oracle limitation
 
Resolving the problem
Any password that begins with a number for an Oracle database must be entered as a double quoted string (ie "123456ABC") in the WebSphere Partner Gateway installation panels.
 
AND


* oracle Character set을 변경하려면 sysdba로 접속해야 한다.

command>SQLPLUS "/AS SYSDBA"

SQL>SHUTDOWN IMMEDIATE;

SQL>STARTUP MOUNT;

SQL>ALTER SYSTEM ENABLE RESTRICTED SESSION;

SQL>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;

SQL>ALTER SYSTEM SET AQ_TM_PROCESSES=0;

SQL>ALTER DATABASE OPEN;

SQL>ALTER DATABASE CHARACTER SET INTERNAL_USE KO16KSC5601;

SQL>SHUTDOWN IMMEDIATE;

SQL>STARTUP;

AND