⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prodinstlib.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: prodinstlib.cpp,v 1.2.2.4 2004/07/09 02:03:21 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** *//************************************************************************ * postinst.cpp - Post-install setup program. *//*********************************************************************** * includes */#include "hxtypes.h"#include "safestring.h"#include "hlxclib/ctype.h"// system includes#include <stdio.h>#include <stdlib.h>#include <string.h>#include <limits.h>#include <time.h>#include <sys/stat.h>#include <errno.h>#ifdef _UNIX#include <unistd.h>#include <pwd.h>#include <grp.h>#include <termios.h>#include <sys/ioctl.h>#include <sys/types.h>#include <signal.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#endif // _UNIX#if defined _AIX43#include <strings.h>#include "dllpath.h"ENABLE_MULTILOAD_DLLACCESS_PATHS(Postinst);#endif // _AIX43#ifdef _WIN32#include <windows.h>#include <direct.h>#endif // _WIN32#include <ctype.h>#include "md5.h"#ifdef _WIN32#include "hxstrutl.h"   // strcasecmp#endif // _WIN32#include "product_version.h"#include "package_info.h"#include "consoleui.h"#include "prodinstlib.h"#include "passwdtool.h"#ifdef _WIN32#include "wininstlib.h"#endif // _WIN32/************************************************************************//************************************************************************/ProductInstaller::ProductInstaller()    : m_pPorts(NULL)     , m_szAdminUser(0)    , m_szAdminPass(0)    , m_szAdminRealm(0)    , m_szEncUser(0)    , m_szEncPass(0)    , m_szEncRealm(0)    , m_szContentRealm(0)    , m_szMonPass(0)    , m_szOutputCfg(0)    , m_szBackupCfg(0)    , m_szInstallerConfigFile(0)    , m_szLoggingStyle(0)    , m_szHostname(0)    , m_szDestDir(0)    , m_bNonInteractive(FALSE)    , m_bSilent(FALSE)    , m_bBackupOldFiles(TRUE)    , m_bDebug(FALSE)    , m_szInstallLog(NULL)#ifdef _WIN32    , m_szArchDir(0)    , m_szServiceUser(NULL)    , m_szServiceName(NULL)    , m_szServicePass(NULL)    , m_bNTService(TRUE)    , m_bWSAStarted(FALSE)#endif // _WIN32    , m_pCUI(0){}ProductInstaller::~ProductInstaller(){    HX_DELETE(m_pCUI);    HX_VECTOR_DELETE(m_pPorts);    HX_VECTOR_DELETE(m_szOutputCfg);    HX_VECTOR_DELETE(m_szBackupCfg);    HX_VECTOR_DELETE(m_szInstallLog);#ifdef _WIN32    if(m_bWSAStarted)    {        WSACleanup();    }#endif // _WIN32}voidProductInstaller::Init(){    if (m_ulNumPorts)    {        m_pPorts = new InstPort[m_ulNumPorts];	if (m_pPorts)	{	    for(UINT32 i = 0; i < m_ulNumPorts; i++)	    {		m_pPorts[i].nPort = 0;		m_pPorts[i].bSet = FALSE;		m_pPorts[i].szName = NULL;	    }	    	    m_pPorts[MON_PORT].szName = "Monitor";	    m_pPorts[RTSP_PORT].szName = "RTSP";	    m_pPorts[PNA_PORT].szName = "PNA";	    m_pPorts[HTTP_PORT].szName = "HTTP";	    m_pPorts[ADMIN_PORT].szName = "Admin";	}    }#ifdef _CONSOLE    m_pCUI = new ConsoleUI();#endif    }/************************************************************************ * ProductInstaller::SetDefaults() */voidProductInstaller::SetDefaults(void){    if(GetLocalHostName(m_szHostname) && m_szHostname &&         m_szHostname[0] != '\0')    {        m_szBaseRealm = m_szHostname;    }    else    {        m_szBaseRealm = (char*)"HelixProduct";    }        SetDefaultDir(m_szDestDir);    if (m_pPorts)    {	m_pPorts[MON_PORT].nPort = 9090;	m_pPorts[RTSP_PORT].nPort = 554;	m_pPorts[PNA_PORT].nPort = 7070;	m_pPorts[HTTP_PORT].nPort = 80;	m_pPorts[ADMIN_PORT].nPort = RandomPort(10000, 30000);	m_pPorts[MON_PORT].bSet = TRUE;    }    m_szOutputCfg = new char[strlen(ProductVersion::ExecutableName()) + 5];    m_szBackupCfg = new char[12];    sprintf (m_szOutputCfg, "%s.cfg", ProductVersion::ExecutableName());    sprintf (m_szBackupCfg, "%s.cfg", "default");    m_szLoggingStyle   = (char*)"5";    m_szAdminRealm   = new char[strlen(m_szBaseRealm) + 20];    m_szEncRealm     = new char[strlen(m_szBaseRealm) + 20];    m_szContentRealm = new char[strlen(m_szBaseRealm) + 20];    sprintf (m_szAdminRealm,   "%s.AdminRealm",      m_szBaseRealm);    sprintf (m_szEncRealm,     "%s.EncoderRealm",    m_szBaseRealm);    sprintf (m_szContentRealm, "%s.ContentRealm",    m_szBaseRealm);#ifdef _WIN32    m_bNTService = TRUE;    m_szServiceUser = NULL;    m_szServicePass = NULL;    m_szServiceName = new char[128];    strcpy (m_szServiceName, ProductVersion::ProductName());#endif // _WIN32}/************************************************************************ * ProductInstaller::ParseCmdLine - Parse the command-line options */voidProductInstaller::ParseCmdLine(int argc, const char* argv[]){    int i=0;    const char** arg=0;    // First, scan all args for -v or -h; if there we want to exit now...    for (i = argc, arg = argv; i; arg++, i--)    {        if (!strcmp(*arg, "--version") ||            !strcmp(*arg, "-v"))        {            if(m_pCUI)                m_pCUI->ShowMessage(VersionBanner());            CleanUpAndExit(0, m_pCUI);        }        if (!strcmp(*arg, "--help") ||            !strcmp(*arg, "-h") ||            !strcmp(*arg, "/?")) // for win32-heads        {            if(m_pCUI)                m_pCUI->PrintUsage("installer", NULL);            CleanUpAndExit(0, m_pCUI);        }        else if (!strcmp(*arg, "--silent") ||                 !strcmp(*arg, "-s") ||                 !strcmp(*arg, "/s"))        {            m_bSilent = TRUE;            m_bNonInteractive = TRUE;        }    }    // now scan all args for --out so we can redirect stdout/stderr first thing    for (i = argc, arg = argv; i; arg++, i--)    {        if (arg == argv)        {            // this is the command name, so skip it        }        else if (!strcmp(*arg, "--progress-only") ||                 !strcmp(*arg, "-p"))        {            if(!m_bSilent && m_pCUI)                m_pCUI->ShowMessage ("Option: non-interactive install\n");            m_bNonInteractive = TRUE;        }        else if (!strcmp(*arg, "--destination") ||                 !strcmp(*arg, "--dest") ||                 !strcmp(*arg, "-dest") || //old installer compatabity cruft                 !strcmp(*arg, "-d"))        {            if (i && *(arg+1)[0] != '-')            {                i--;                arg++;                if(!m_bSilent && m_pCUI)                    m_pCUI->ShowMessage ("Option: install to directory %s\n", *arg);                m_szDestDir = new char[strlen(*arg) + 1];                strcpy (m_szDestDir, *arg);            }            else            {                if(!m_bSilent && m_pCUI)                    m_pCUI->ShowErrorMessage ("Option: %s must take a filename!\n", *arg);            }        }        else if (!strcmp(*arg, "-cfg"))        {            if (i && *(arg+1)[0] != '-')            {                i--;                arg++;                if(!m_bSilent && m_pCUI)                {                    m_pCUI->ShowMessage ("Option: read installer configuration "                             "from %s\n", *arg);                }                m_szInstallerConfigFile = new char[strlen(*arg) + 1];                strcpy (m_szInstallerConfigFile, *arg);                //                // Read external installer configuration file, setting                 // various defaults                //                char szCfg[1024];#ifdef _WIN32                char* pFile;                DWORD dwLen = GetFullPathName(*arg, 1024, szCfg, &pFile);                if(dwLen == 0 || dwLen >= 1024)                                {                    sprintf(szCfg, "%s", *arg);                }#else // _WIN32                if (**arg != '/')                {                    sprintf(szCfg, "../%s", *arg);                }                else                {                    sprintf(szCfg, "%s", *arg);                }#endif // _WIN32                if (ReadInstallerDefaults(szCfg) != 0)                {                    if(!m_bSilent && m_pCUI)                        m_pCUI->ShowErrorMessage("ERROR: Unable to read installer config "                                     "file %s (%s)\n", *arg, strerror(errno));                    CleanUpAndExit(-1, m_pCUI);                }            }            else            {                if(!m_bSilent && m_pCUI)                    m_pCUI->ShowErrorMessage ("Option: %s must take a filename!\n", *arg);            }        }        else if (!strcmp(*arg, "--no-backup") ||                 !strcmp(*arg, "--nb") ||                  !strcmp(*arg, "-nb"))        {            if(!m_bSilent && m_pCUI)                m_pCUI->ShowMessage ("Option: no-backup\n");            m_bBackupOldFiles = FALSE;        }        else if (!strcmp(*arg, "--debug"))        {            if(!m_bSilent && m_pCUI)                m_pCUI->ShowMessage ("Option: debug\n");            m_bDebug = TRUE;        }        else if (!strcmp(*arg, "--password"))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -