Return TypeFunction nameArguments
hzEcodehzLogger::OpenPublic(const char*,hzLogRotate,)

Declared in file: hzProcess.h
Defined in file : hzLogger.cpp

Function Logic:

0:START 1:m_pConnection 2:m_pConnection->ConnectStd(s_LocalHost,PORT_LOGSERVER)!=E_OK 3:Return E_HOSTFAIL 4:strlen nSize getpid nProcID geteuid nUsr getegid nGrp u u u u u u u u u u u u u u u u strncpy 5:m_pConnection->Send(m_cvData,nSize)!=E_OK 6:Return E_SENDFAIL 7:m_pConnection->Recv(m_cvData,nSize,64)!=E_OK 8:Return E_RECVFAIL 9:nSize==4&&m_cvData[0]==LS_OK 10:m_nSessID m_nSessID m_nSessID m_nSessID 11:Return E_OK 12:m_cvData[0]==LS_ERR_PERM 13:Return E_WRITEFAIL 14:m_pDataPtr 15:Return E_PROTOCOL

Function body:

hzEcode hzLogger::OpenPublic (const char* fpath, hzLogRotate eRotate)
{
   _hzfunc("hzLogger::OpenPublic") ;
   uint32_t    nSize ;
   uint32_t    nUsr ;
   uint32_t    nGrp ;
   uint32_t    nProcID ;
   uchar*      u ;
   m_pConnection = new hzTcpClient() ;
   if (m_pConnection->ConnectStd(s_LocalHost, PORT_LOGSERVER) != E_OK)
       return E_HOSTFAIL ;
   nSize = 16+strlen(fpath) ;
   nProcID = getpid() ;
   nUsr = geteuid() ;
   nGrp = getegid() ;
   u = (uchar*) m_cvData ;
   u[0]= LS_OPEN_PUB ;
   u[1]= (nSize & 0xff00)>>8;
   u[2]= (nSize & 0xff);
   u[3]= (nProcID & 0xff000000)>>24;
   u[4]= (nProcID & 0xff0000)>>16;
   u[5]= (nProcID & 0xff00)>>8;
   u[6]= (nProcID & 0xff);
   u[7]= (nUsr & 0xff000000)>>24;
   u[8]= (nUsr & 0xff0000)>>16;
   u[9]= (nUsr & 0xff00)>>8;
   u[10]=(nUsr & 0xff);
   u[11]=(nGrp & 0xff000000)>>24;
   u[12]=(nGrp & 0xff0000)>>16;
   u[13]=(nGrp & 0xff00)>>8;
   u[14]=(nGrp & 0xff);
   strncpy(m_cvData + 15,fpath,HZ_MAXPATHLEN) ;
   if (m_pConnection->Send(m_cvData, nSize) != E_OK)
       return E_SENDFAIL ;
   if (m_pConnection->Recv(m_cvData, nSize, 64)!=E_OK)
       return E_RECVFAIL ;
   if (nSize == 4&& m_cvData[0]== LS_OK)
   {
       m_nSessID = 0;
       m_nSessID |= (u[1]<< 16);
       m_nSessID |= (u[2]<< 8);
       m_nSessID |= u[3];
       return E_OK ;
   }
   if (m_cvData[0]== LS_ERR_PERM)
       return E_WRITEFAIL ;
   m_pDataPtr = m_cvData + 10;
   return E_PROTOCOL ;
}