예제 #1
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 */
예제 #2
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 */
예제 #3
0
void
SessionImpl::CloseFile (/*[in]*/ FILE * pFile)
{
    MIKTEX_ASSERT_BUFFER (pFile, sizeof(*pFile));
    trace_files->WriteFormattedLine ("core", "CloseFile(%p)", pFile);
    map<const FILE *, OpenFileInfo>::iterator it = openFilesMap.find(pFile);
    bool isCommand = false;
    if (it != openFilesMap.end())
    {
        isCommand = (it->second.mode == FileMode::Command);
        openFilesMap.erase (it);
    }
    if (isCommand)
    {
        PClose (pFile);
    }
    else if (fclose(pFile) != 0)
    {
        FATAL_CRT_ERROR ("fclose", 0);
    }
}
예제 #4
0
/////////////////////////////////////////////////////////////////////////////
//
// Constructor
// Closes Porttalk access if required
//
PortW32::~PortW32()
{
	PClose();
}
예제 #5
0
/////////////////////////////////////////////////////////////////////////////
//
// Constructor
// Closes Porttalk access if required
//
PortUX::~PortUX()
{
   PClose();
}