示例#1
0
文件: Get.c 项目: aosm/ncftp
int DoGetWithGlobbingAndRecursion(GetOptionsPtr gopt)
{
	int err;
	LineList globFiles;
	LinePtr globFile;
	char *cp;
	int fType;
	int result;
	longstring rcwd;
		
	err = 0;
	InitLineList(&globFiles);
	RemoteGlob(&globFiles, gopt->rName, kListNoFlags);
	
	for (globFile = globFiles.first; globFile != NULL;
		globFile = globFile->next)
	{
		if (gXferAbortFlag == SIGINT)
			break;	/* Don't get rest of files if you interrupted. */
		if (gopt->recursive) {
			fType = RemoteFileType(globFile->line);
			if (fType == 'd') {
				if ((cp = strrchr(globFile->line, '/')) != NULL) {
					/* If the user said something like
					 * "get -R /pub/a/b/c/d" we want to just write the
					 * contents of the 'd' as a subdirectory of the local
					 * directory, and not create ./pub, ./pub/a, etc.
					 */
					STRNCPY(rcwd, gRemoteCWD);
					*cp++ = '\0';
					if (DoChdir(globFile->line) == 0) {
						GetDir(gopt, cp, gRemoteCWD, gLocalCWD);
					}
					/* Restore the directory we were in before. */
					(void) DoChdir(rcwd);
				} else {
					/* Otherwise, the user gave a simple path, so it was
					 * something like "get -R pub"
					 */
					GetDir(gopt, globFile->line, gRemoteCWD, gLocalCWD);
				}
			} else if (fType == 'l') {
				EPrintF("Ignoring symbolic link '%s'\n",
					globFile->line);
			} else if (fType == '-') {
				goto regFile;
			}
		} else {
regFile:
			gopt->rName = globFile->line;
			gopt->lName = NULL;	/* Make it later. */
			result = DoGet(gopt);
			if (result < 0)
				err = -1;
		}
	}
	DisposeLineListContents(&globFiles);
	
	return (err);
}	/* DoGetWithGlobbingAndRecursion */
示例#2
0
文件: lunxun.c 项目: jsvisa/apue
int DealRequest(int sock, char *buf) {
	int ret = 0;
	printf("Deal Request\n");
	if(strncasecmp(buf, "login", 5) != 0 && logined != 1) {
		msend(sock, "401 Please login first\r\n");
		return -1;
	}

	if(strncasecmp(buf, "list", 4) == 0) {
		ret = DoList(sock, buf);
	}
	else if(strncasecmp(buf, "cd", 2) == 0) {
		ret = DoChdir(sock, buf);
	}
	else if(strncasecmp(buf, "login", 5) == 0) {
		ret = DoLogin(sock, buf);
	}
	else if(strncasecmp(buf, "get", 3) == 0) {
		ret = DoGet(sock, buf);
	}
	else if(strncasecmp(buf, "quit", 4) == 0) {
		ret = DoQuit(sock, buf);
	}
	else {
		printf("Unknown Request:%s\n", buf);
		msend(sock, "400 Unknown command\r\n");
	}
	return ret;

}