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

📄 filingd.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
	}	handle->state= FILE_OPEN;	handle->file_desc= NULL;	copyhandle(results.file, &handle);	reset_continuance_timer();	return(results);}verify_store_attributes(attr, handle)FILING_AttributeSequence attr;file_handle *handle;{	int i;	FILING_AttributeType t;	int got_accesslist, got_childrenuniquelynamed, got_createdon, got_datasize;	int got_defaultaccesslist, got_isdirectory, got_istemporary, got_ordering;	int got_parentID, got_pathname, got_subtreesizelimit, got_type, got_version;	char *pathname;	FILING_Version version;	Boolean childrenuniquelynamed, istemporary;	Cardinal ordering;			Cardinal subtreesizelimit;	char *AttrToString();	Unspecified *AttrToFileID();	LongCardinal AttrToLongCardinal();#ifdef FILETOOLCOMPATIBILITY	int got_name, got_4938;	char *name;#endif FILETOOLCOMPATIBILITY#ifdef DEBUG	fprintf(msgs,"%d store attributes	",attr.length);#endif DEBUG	if ( attr.length <= 0 ) {		ReturnAttributeTypeError(FILING_illegal, 0);		/* NOT REACHED */	}	got_accesslist= got_childrenuniquelynamed= got_createdon= 0;	got_datasize= got_defaultaccesslist= got_isdirectory= 0;	got_istemporary= got_ordering= got_parentID= got_pathname= 0;	got_subtreesizelimit= got_type= got_version= 0;#ifdef FILETOOLCOMPATIBILITY	got_name= got_4938= 0;#endif FILETOOLCOMPATIBILITY	for ( i= 0 ; i < attr.length ; i++ ) {		t= attr.sequence[i].type;#ifdef DEBUG		fprintf(msgs, "%d ",t);#endif DEBUG		if ( t == FILING_createdOn ) {#ifdef DEBUG			fprintf(msgs,"createdOn  ");#endif DEBUG			if ( got_createdon ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_createdon++;			handle->createdon= AttrToLongCardinal(&attr.sequence[i]);			continue;		}		if ( t == FILING_dataSize ) {#ifdef DEBUG			fprintf(msgs,"dataSize  ");#endif DEBUG			if ( got_datasize ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_datasize++;			handle->datasize= AttrToLongCardinal(&attr.sequence[i]);			continue;		}		if ( t == FILING_isDirectory ) {#ifdef DEBUG			fprintf(msgs,"isDirectory  ");#endif DEBUG			if ( got_isdirectory ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_isdirectory++;			handle->isdirectory= AttrToBoolean(&attr.sequence[i]);			continue;		}		if ( t == FILING_pathname ) {#ifdef DEBUG			fprintf(msgs,"pathname  ");#endif DEBUG			if ( got_pathname ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_pathname++;			pathname= AttrToString(&attr.sequence[i]);			if ( check_pathname(pathname) != -1 ) {				/* NOT REACHED */			}			continue;		}					if ( t == FILING_type ) {#ifdef DEBUG			fprintf(msgs,"type  ");#endif DEBUG			if ( got_type ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_type++;			handle->type= AttrToLongCardinal(&attr.sequence[i]);#ifndef EXTENSIONS			if ( (handle->type != FILING_tText) &&					(handle->type != FILING_tUnspecified) &&					(handle->type != FILING_tDirectory) ) {				ReturnAttributeValueError(FILING_unimplemented, t);				/* NOT REACHED */			}#endif EXTENSIONS			continue;		}		if ( t == FILING_version ) {#ifdef DEBUG			fprintf(msgs,"version  ");#endif DEBUG			if ( got_version ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_version++;			version= AttrToCardinal(&attr.sequence[i]);			if ( version != FILING_highestVersion ) {					ReturnAttributeValueError(FILING_unimplemented, t);					/* NOT REACHED */			}			continue;		}#ifdef FILETOOLCOMPATIBILITY		if ( t == FILING_name ) {#ifdef DEBUG			fprintf(msgs, "name  ");#endif DEBUG			if ( got_name ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_name++;			name= AttrToString(&attr.sequence[i]);			continue;		}		if ( t == 4938 ) {			if ( got_4938 ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_4938++;			continue;		}#endif FILETOOLCOMPATIBILITY#ifdef SOMEDAY		if ( t == FILING_accessList ) {			if ( got_accesslist ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_accesslist++;			if ( FALSE ) {				ReturnAttributeValueError(FILING_unimplemented, t);				/* NOT REACHED */			}			continue;		}#endif SOMEDAY		if ( t == FILING_childrenUniquelyNamed ) {			if ( got_childrenuniquelynamed ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_childrenuniquelynamed++;			childrenuniquelynamed= AttrToBoolean(&attr.sequence[i]);			if ( childrenuniquelynamed != TRUE ) {				ReturnAttributeValueError(FILING_unimplemented, t);				/* NOT REACHED */			}			continue;		}#ifdef SOMEDAY		if ( t == FILING_defaultAccessList ) {			if ( got_defaultaccesslist ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_defaultaccesslist++;			if ( FALSE ) {				ReturnAttributeValueError(FILING_unimplemented, t);				/* NOT REACHED */			}			continue;		}#endif SOMEDAY		if ( t == FILING_isTemporary ) {			if ( got_istemporary ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_istemporary++;			istemporary= AttrToBoolean(&attr.sequence[i]);			if ( istemporary != FALSE ) {				ReturnAttributeValueError(FILING_unimplemented, t);				/* NOT REACHED */			}			continue;		}		if ( t == FILING_ordering ) {			if ( got_ordering ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_ordering++;			if ( FALSE ) {				ReturnAttributeValueError(FILING_unimplemented, t);				/* NOT REACHED */			}			continue;		}		if ( t == FILING_subtreeSizeLimit ) {			if ( got_subtreesizelimit ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_subtreesizelimit++;			subtreesizelimit= AttrToCardinal(&attr.sequence[i]);			if ( subtreesizelimit != FILING_nullSubtreeSizeLimit ) {				ReturnAttributeValueError(FILING_unimplemented, t);				/* NOT REACHED */			}			continue;		}		if ( (t == FILING_fileID) || (t == FILING_modifiedBy) ||				(t == FILING_modifiedOn) || (t == FILING_name) ||				(t == FILING_numberOfChildren) || (t == FILING_parentID) ||				(t == FILING_readBy) || (t == FILING_readOn) ||				(t == FILING_storedSize) || (t == FILING_subtreeSize) ) {			ReturnAttributeTypeError(FILING_disallowed, t);		}#ifndef EXTENSIONS		if ( ( t < 0 ) || (t > FILING_subtreeSizeLimit) ) {			ReturnAttributeTypeError(FILING_illegal, t);			/* NOT REACHED */		}		if ( (t == FILING_checksum) || (t == FILING_createdBy) ||						(t == FILING_position) )			ReturnAttributeTypeError(FILING_unimplemented, t);		else			ReturnAttributeTypeError(FILING_disallowed, t);#else EXTENSIONS		if ( t < 0 ) {			ReturnAttributeTypeError(FILING_illegal, t);			/* NOT REACHED */		}		if ( handle->type != TYPE_VP ) {			if ( (t == FILING_checksum) || (t == FILING_createdBy) ||						(t == FILING_position) )				ReturnAttributeTypeError(FILING_unimplemented, t);			else				ReturnAttributeTypeError(FILING_disallowed, t);		}#endif EXTENSIONS	}#ifdef DEBUG	fprintf(msgs, "\n");#endif DEBUG#ifdef FILETOOLCOMPATIBILITY	if ( !got_pathname && !got_name) {		handle->pathname= SERVICE_ROOT;	} else 	if ( !got_pathname )  {		strcat(handle->pathname,name);	} else {		if ( *pathname == '/' )			strcat(handle->pathname, pathname+1);		else			strcat(handle->pathname,pathname);		Deallocate(&pathname);	}#else FILETOOLCOMPATIBILITY	if ( !got_pathname ) {		ReturnAttributeTypeError(FILING_missing, t);		/* NOT REACHED */	} else {		if ( *pathname == '/' )			strcat(handle->pathname, pathname+1);		else			strcat(handle->pathname, pathname);		Deallocate(&pathname);	}#endif FILETOOLCOMPATIBILITY	if ( !got_type )		handle->type= FILING_tUnspecified;	if ( !got_createdon )		handle->createdon= 0;	if ( !got_isdirectory ) {		if ( handle->type == FILING_tDirectory )			handle->isdirectory= TRUE;		else			handle->isdirectory= FALSE;	} else {		if ( ((handle->isdirectory == TRUE) && (handle->type != FILING_tDirectory)) ||				((handle->isdirectory == FALSE) && (handle->type == FILING_tDirectory)) ) {			ReturnAttributeTypeError(FILING_unreasonable, FILING_isDirectory);			/* NOT REACHED */		}	}	return(-1);}void FILING_Retrieve(ServerConnection, BDTProc, file, content, session)CourierConnection *ServerConnection;int ( *BDTProc)();FILING_Handle file;BulkData1_Descriptor content;FILING_Session session;{	file_handle *handle;#ifdef DEBUG	if (msgs == 0) {		char logfile[50];		sprintf(logfile, "/tmp/filing%ld.msgs", getpid());		msgs= fopen(logfile,"w");	}	fprintf(msgs, "Retrieve\n");#endif DEBUG	BDTabort_expected= TRUE;	if ( verify_session(session) != -1 ) {		/* NOT REACHED */	}	if ( is_nullHandle(file) == -1 ) {		ReturnHandleError(FILING_nullDisallowed);		/* NOT REACHED */	}	copyhandle(&handle,file);	if ( handle->state != FILE_OPEN ) {		ReturnHandleError(FILING_invalid);		/* NOT REACHED */	}	if ( access_file(handle) != -1 ) {		/* NOT REACHED */	}	if ( content.designator == BulkData1_null ) {		return;	} else  if ( content.designator != BulkData1_immediate ) {		ReturnTransferError(FILING_aborted);		/* NOT REACHED */	}	if ( open_file(handle) != -1 ) {		/* NOT REACHED */	}#ifdef DEBUG	fprintf(msgs, "retrieving '%s'\n", handle->pathname);#endif DEBUG	if ( retrieveproc(ServerConnection,handle) != -1 ) {		close_file(handle);		ReturnTransferError(FILING_aborted);		/* NOT REACHED */	}	close_file(handle);	handle->file_desc= NULL;	reset_continuance_timer();	return;}void FILING_Replace(ServerConnection, BDTProc, file, attributes, content, session)CourierConnection *ServerConnection;int ( *BDTProc)();FILING_Handle file;FILING_AttributeSequence attributes;BulkData1_Descriptor content;FILING_Session session;{#ifdef EXTENSIONS	file_handle *handle;#ifdef DEBUG	if (msgs == 0) {		char logfile[50];		sprintf(logfile, "/tmp/filing%ld.msgs", getpid());		msgs= fopen(logfile,"w");	}	fprintf(msgs, "Replace\n");#endif DEBUG	BDTabort_expected= TRUE;	if ( verify_session(session) != -1 ) {		/* NOT REACHED */	}	if ( is_nullHandle(file) == -1 ) {		ReturnHandleError(FILING_nullDisallowed);		/* NOT REACHED */	}	copyhandle(&handle,file);	if ( handle->state != FILE_OPEN ) {		ReturnHandleError(FILING_invalid);		/* NOT REACHED */	}	if ( access_file(handle) != -1 ) {		/* NOT REACHED */	}	if ( content.designator == BulkData1_null ) {		return;	} else  if ( content.designator != BulkData1_immediate ) {		ReturnTransferError(FILING_aborted);		/* NOT REACHED */	}	if ( verify_replace_attributes(attributes, handle) != -1 ) {		/* NOT REACHED */	}#ifdef DEBUG	fprintf(msgs, "replacing '%s'\n", handle->pathname);#endif DEBUG	if ( make_backup(handle) != -1 ) {		/* NOT REACHED */	}	if ( open_file(handle) != -1 ) {		/* NOT REACHED */	}	if ( storeproc(ServerConnection,handle) != -1 ) {		close_file(handle);		recall_backup(handle);		ReturnTransferError(FILING_aborted);		/* NOT REACHED */	}	close_file(handle);	unlink_backup(handle);	handle->file_desc= NULL;	reset_continuance_timer();	return;#else EXTENSIONS	NoSuchProcedureValue("Filing", 14);#endif EXTENSIONS}#ifdef EXTENSIONSverify_replace_attributes(attr, handle)FILING_AttributeSequence attr;file_handle *handle;{	int i;	FILING_AttributeType t;	LongCardinal datasize;	int got_createdon, got_datasize;	LongCardinal AttrToLongCardinal();#ifdef DEBUG	fprintf(msgs,"%d replace attributes	",attr.length);#endif DEBUG	if ( attr.length < 0 ) {		ReturnAttributeTypeError(FILING_illegal, 0);		/* NOT REACHED */	}	got_createdon= 0;	for ( i= 0 ; i < attr.length ; i++ ) {		t= attr.sequence[i].type;#ifdef DEBUG		fprintf(msgs, "%d ",t);#endif DEBUG		if ( t == FILING_createdOn ) {#ifdef DEBUG			fprintf(msgs,"createdOn  ");#endif DEBUG			if ( got_createdon ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_createdon++;			handle->createdon= AttrToLongCardinal(&attr.sequence[i]);			continue;		}		if ( t == FILING_dataSize ) {#ifdef DEBUG			fprintf(msgs,"dataSize  ");#endif DEBUG			if ( got_datasize ) {				ReturnAttributeTypeError(FILING_duplicated, t);				/* NOT REACHED */			}			got_datasize++;			datasize= AttrToLongCardinal(&attr.sequence[i]);			continue;		}		if ( t < 0 ) {			ReturnAttributeTypeError(FILING_illegal, t);			/* NOT REACHED */		}		if ( (t == FILING_checksum) || (t == FILING_createdBy) ||						(t == FILING_position) )			ReturnAttributeTypeError(FILING_unimplemented, t);		else			ReturnAttributeTy

⌨️ 快捷键说明

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