示例#1
0
FILE *
SessionImpl::InitiateProcessPipe (/*[in]*/ const char *		lpszCommand,
        /*[in]*/ FileAccess		access,
        /*[in,out]*/ FileMode &	mode)
{
    Argv argv;
    argv.Build ("", lpszCommand);
    int argc = argv.GetArgc();
    if (argc == 0)
    {
        FATAL_MIKTEX_ERROR ("SessionImpl::InitiateProcessPipe",
                            T_("Invalid command."),
                            lpszCommand);
    }
    string verb = argv[1];
    if (verb == "zcat"
            && argc == 3
            && access.Get() == FileAccess::Read)
    {
        mode = FileMode::Open;
        return (OpenGZipFile(argv[2]));
    }
    else if (verb == "bzcat"
             && argc == 3 &&
             access.Get() == FileAccess::Read)
    {
        mode = FileMode::Open;
        return (OpenBZip2File(argv[2]));
    }
    else
    {
        return (POpen(lpszCommand,
                      access.Get() == FileAccess::Read ? "r" : "w"));
    }
}
示例#2
0
文件: Glob.c 项目: aosm/ncftp
void LocalGlob(LineListPtr fileList, char *pattern)
{
	string pattern2;
	string cmd;
	longstring gfile;
	FILE *volatile fp;
	volatile Sig_t si, sp;

	STRNCPY(pattern2, pattern);	/* Don't nuke the original. */
	
	/* Pre-process for ~'s. */ 
	ExpandTilde(pattern2, sizeof(pattern2));
	
	/* Initialize the list. */
	fileList->first = fileList->last = NULL;
	
	if (GLOBCHARSINSTR(pattern2)) {
		/* Do it the easy way and have the shell do the dirty
		 * work for us.
		 */
		sprintf(cmd, "%s -d %s", LS, pattern2);

		fp = NULL;
		if (setjmp(gLocalGlobJmp) == 0) {			
			fp = POpen(cmd, "r", 0);
			if (fp == NULL) {
				DebugMsg("Could not lglob: %s\n", cmd);
				return;
			}
			sp = SIGNAL(SIGPIPE, LGlobHandler);
			si = SIGNAL(SIGINT, LGlobHandler);
			while (FGets(gfile, sizeof(gfile), (FILE *) fp) != NULL) {
				TraceMsg("Lglob [%s]\n", gfile);
				AddLine(fileList, gfile);
			}
		}
		(void) SIGNAL(SIGPIPE, SIG_IGN);
		if (fp != NULL)
			(void) PClose((FILE *) fp);
		(void) SIGNAL(SIGPIPE, sp);
		(void) SIGNAL(SIGINT, si);
	} else {
		/* Or, if there were no globbing characters in 'pattern', then the
		 * pattern is really just a single pathname.
		 */
		AddLine(fileList, pattern2);
	}
}	/* LocalGlob */
示例#3
0
文件: Get.c 项目: aosm/ncftp
/* View a remote file through your pager. */
int DoPage(char *remoteName)
{
	FILE *fp;
	int result;
	longstring pageCmd;
	int binaryPage;
	XferSpecPtr xp;

	binaryPage = MakePageCmdLine(pageCmd, sizeof(pageCmd), remoteName);
	DebugMsg("%s page: %s\n",
		binaryPage ? "Binary" : "Ascii",
		pageCmd
	);

	fp = POpen(pageCmd, "w", 1);
	if (fp == NULL) {
		Error(kDoPerror, "Could not run %s.\n", pageCmd);
		return -1;
	}

	xp = InitXferSpec();
	xp->netMode = kNetReading;
	xp->outStream = fileno(fp);
	
	/* This group is needed for the progress reporting and logging stuff.
	 * Otherwise, it isn't that important.
	 */
	xp->doReports = kNoReports;
	xp->localFileName = kLocalFileIsStdout;
	xp->remoteFileName = remoteName;

	if (!binaryPage) {
		/* Try to use text mode for paging, so newlines get converted. */
		result = AsciiGet(xp);
	} else {
		/* Must use binary, or else zcat will complain about corrupted
		 * input files, since we'd be converting carriage-returns.
		 */
		result = BinaryGet(xp);
	}
	DoneWithXferSpec(xp);
	(void) PClose(fp);
	RestoreScreen(1);
	return (result);
}	/* DoPage */
示例#4
0
typename T::clear MAC_Check_Base<T>::POpen(const T& secret, const Player& P)
{
  vector<typename T::clear> opened;
  POpen(opened, {secret}, P);
  return opened[0];
}