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

📄 doconsole.cpp

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	{	    int n = atoi(&str[5]);	    if ((n < 1) || (n > 16384))	    {		printf("invalid number of hosts requested\n");fflush(stdout);		continue;	    }	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		Translate_Error(error, str);		printf("writing 'next' command failed, %d\n%s\n", error, str);fflush(stdout);		break;	    }	    for (int i=0; i<n; i++)	    {		if (!ReadString(sock, str))		{		    printf("Error reading host name\n");		    break;		}		printf("%s\n", str);	    }	    fflush(stdout);	}	else if (strnicmp(str, "getexitcodewaitmultiple ", 24) == 0)	{	    int n = 0;	    char str2[100];	    char *token = strtok(&str[24], ",");	    while (token != NULL)	    {		_snprintf(str2, 100, "getexitcodewait %s", token);		if (WriteString(sock, str2) == SOCKET_ERROR)		{		    error = WSAGetLastError();		    Translate_Error(error, str);		    printf("writing 'getexitcodewaitmultiple' failed, %d\n%s\n", error, str);fflush(stdout);		    n = 0;		    break;		}		n++;		token = strtok(NULL, ",");	    }	    for (int i=0; i<n; i++)	    {		if (!ReadString(sock, str))		{		    error = WSAGetLastError();		    Translate_Error(error, str);		    printf("reading exitcode failed, %d\n%s\n", error, str);fflush(stdout);		    break;		}		printf("%s\n", str);	    }	}	else if ((stricmp(str, "extract") == 0) ||	    (strnicmp(str, "insert ", 7) == 0) ||	    (strnicmp(str, "set ", 4) == 0) ||	    (strnicmp(str, "lset ", 5) == 0) ||	    (strnicmp(str, "ldelete ", 8) == 0) ||	    (strnicmp(str, "update ", 7) == 0) ||	    (strnicmp(str, "stopforwarder ", 14) == 0) ||	    (stricmp(str, "killforwarders") == 0))	{	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing '%s' request failed, %d\n", str, error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);		break;	    }	}	else if ((stricmp(str, "exit") == 0) || 	    (stricmp(str, "quit") == 0) || 	    (stricmp(str, "done") == 0))	{	    break;	}	else if (stricmp(str, "shutdown") == 0)	{	    if (WriteString(sock, "shutdown") == SOCKET_ERROR)	    {		error = WSAGetLastError();		Translate_Error(error, str);		printf("writing shutdown request failed, %d\n%s", error, str);fflush(stdout);	    }	    break;	}	else if ((stricmp(str, "exitall") == 0) || (stricmp(str, "shutdownall") == 0))	{	    if (WriteString(sock, "exitall") == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing %s request failed, %d\n", str, error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);	    }	    break;	}	else if ((strnicmp(str, "kill ", 5) == 0) || (stricmp(str, "killall") == 0))	{	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing '%s' request failed, %d\n", str, error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);	    }	}	else if (strnicmp(str, "fileinit ", 9) == 0)	{	    char pszPassword[100], *pszEncoded;	    if (!GetStringOpt(str, "password", pszPassword))	    {		char pszAccount[100];		if (!GetStringOpt(str, "account", pszAccount))		{		    printf("no account and password specified\n");		    fflush(stdout);		    break;		}		GetPassword(NULL, pszAccount, pszPassword);		pszEncoded = EncodePassword(pszPassword);		_snprintf(str, CONSOLE_STR_LENGTH, "fileinit account=%s password=%s", pszAccount, pszEncoded);		if (pszEncoded != NULL) free(pszEncoded);	    }	    else	    {		char pszAccount[100];		if (!GetStringOpt(str, "account", pszAccount))		{		    printf("password but no account specified\n");		    fflush(stdout);		    break;		}		pszEncoded = EncodePassword(pszPassword);		_snprintf(str, CONSOLE_STR_LENGTH, "fileinit account=%s password=%s", pszAccount, pszEncoded);		if (pszEncoded != NULL) free(pszEncoded);	    }	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing '%s' request failed, %d\n", str, error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);		break;	    }	}	else if (strnicmp(str, "map ", 4) == 0)	{	    char pszPassword[100];	    char pszAccount[100];	    char pszStrTemp[300];	    char *pszEncoded, *pStr;	    unsigned int i;	    if (!GetStringOpt(str, "password", pszPassword))	    {		if (!GetStringOpt(str, "account", pszAccount))		{		    printf("no account and password specified\n");		    fflush(stdout);		    break;		}		GetPassword(NULL, pszAccount, pszPassword);		pszEncoded = EncodePassword(pszPassword);		if (pszEncoded != NULL)		{		    _snprintf(pszStrTemp, 300, " account=%s password=%s", pszAccount, pszEncoded);		    free(pszEncoded);		    strcat(str, pszStrTemp);		}	    }	    else	    {		if (!GetStringOpt(str, "account", pszAccount))		{		    printf("password but no account specified\n");		    fflush(stdout);		    break;		}		pszEncoded = EncodePassword(pszPassword);		if (pszEncoded != NULL)		{		    _snprintf(pszStrTemp, 300, " password=%s", pszEncoded);		    free(pszEncoded);		}		else		    pszStrTemp[0] = '\0';		/* erase the original password */		pStr = strstr(str, "password");		while (*pStr != '=')		{		    *pStr = ' ';		    pStr++;		}		*pStr = ' ';		pStr = strstr(pStr, pszPassword);		for (i=0; i<strlen(pszPassword); i++)		    pStr[i] = ' ';		/* append the encoded password */		strcat(str, pszStrTemp);	    }	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing map command failed, %d\n", error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);		break;	    }	    if (ReadStringTimeout(sock, str, MPD_DEFAULT_TIMEOUT*2)) // logon requests can take a long time	    {		printf("%s\n", str);fflush(stdout);	    }	    else	    {		printf("timeout waiting for result to return.\n");fflush(stdout);	    }	}	else if (strnicmp(str, "unmap ", 6) == 0)	{	    char pszDrive[10];	    if (!GetStringOpt(str, "drive", pszDrive))	    {		char pszStrTemp[40];		_snprintf(pszStrTemp, 40, "unmap drive=%s", &str[6]);		pszStrTemp[39] = '\0';		strcpy(str, pszStrTemp);	    }	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing unmap command failed, %d\n", error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);		break;	    }	    if (ReadStringTimeout(sock, str, MPD_DEFAULT_TIMEOUT))	    {		printf("%s\n", str);fflush(stdout);	    }	    else	    {		printf("timeout waiting for result to return.\n");fflush(stdout);	    }	}	else if (strnicmp(str, "putfile ", 8) == 0)	{	    if (PutFile(sock, &str[8]))	    {		printf("SUCCESS\n");fflush(stdout);	    }	}	else if (strnicmp(str, "getfile ", 8) == 0)	{	    GetFile(sock, &str[8]);	}	else if (strnicmp(str, "getdir ", 7) == 0)	{	    GetDirectoryContents(sock, str);	}	else if (stricmp(str, "restart") == 0)	{	    //dbg_printf("writing 'restart'\n");fflush(stdout);	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing '%s' failed, %d\n", str, error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);		break;	    }	    //dbg_printf("waiting for result\n");fflush(stdout);	    if (ReadStringTimeout(sock, str, MPD_DEFAULT_TIMEOUT))	    {		printf("%s\n", str);fflush(stdout);	    }	    break;	}	else if (stricmp(str, "print") == 0)	{	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing '%s' failed, %d\n", str, error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);		break;	    }	    if (ReadStringMax(sock, str, CONSOLE_STR_LENGTH))	    {		printf("%s", str);fflush(stdout);	    }	    else	    {		printf("reading result failed\n");fflush(stdout);		break;	    }	}	else if (stricmp(str, "stat") == 0)	{	    strcpy(str, "stat param=help");	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing '%s' failed, %d\n", str, error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);		break;	    }	    if (ReadStringMax(sock, str, CONSOLE_STR_LENGTH))	    {		printf("%s", str);fflush(stdout);	    }	    else	    {		printf("reading result failed\n");fflush(stdout);		break;	    }	}	else if (strnicmp(str, "stat ", 5) == 0)	{	    char pszParam[100];	    if (!GetStringOpt(str, "param", pszParam))	    {		char pszStrTemp[100];		_snprintf(pszStrTemp, 100, "stat param=%s", &str[5]);		pszStrTemp[99] = '\0';		strcpy(str, pszStrTemp);	    }	    if (WriteString(sock, str) == SOCKET_ERROR)	    {		error = WSAGetLastError();		printf("writing '%s' failed, %d\n", str, error);		Translate_Error(error, str);		printf("%s\n", str);		fflush(stdout);		break;	    }	    if (ReadStringMax(sock, str, CONSOLE_STR_LENGTH))	    {		printf("%s", str);fflush(stdout);	    }	    else	    {		printf("reading result failed\n");fflush(stdout);		break;	    }	}	else	{	    printf("unknown command\n");fflush(stdout);	}    }    if (WriteString(sock, "done") == SOCKET_ERROR)    {	error = WSAGetLastError();	Translate_Error(error, str);	printf("WriteString failed: %d\n%s\n", error, str);	fflush(stdout);    }    easy_closesocket(sock);}

⌨️ 快捷键说明

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