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

📄 filingd.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
	if ( delete_file(handle) != -1 ) {		/* NOT REACHED */	}	handle->state= FILE_CLOSED;	handle->pathname= (char *)0;	free(handle);	reset_continuance_timer();	return;}FILING_GetControlsResults FILING_GetControls(ServerConnection, BDTProc, file, types, session)CourierConnection *ServerConnection;int ( *BDTProc)();FILING_Handle file;FILING_ControlTypeSequence types;FILING_Session session;{	NoSuchProcedureValue("Filing", 6);}void FILING_ChangeControls(ServerConnection, BDTProc, file, controls, session)CourierConnection *ServerConnection;int ( *BDTProc)();FILING_Handle file;FILING_ControlSequence controls;FILING_Session session;{	NoSuchProcedureValue("Filing", 7);}FILING_GetAttributesResults FILING_GetAttributes(ServerConnection, BDTProc, file, types, session)CourierConnection *ServerConnection;int ( *BDTProc)();FILING_Handle file;FILING_AttributeTypeSequence types;FILING_Session session;{#ifdef EXTENSIONS	file_handle *handle;	FILING_GetAttributesResults results;#ifdef DEBUG	if (msgs == 0) {		char logfile[50];		sprintf(logfile, "/tmp/filing%ld.msgs", getpid());		msgs= fopen(logfile,"w");	}	fprintf(msgs, "Getattributes\n");#endif DEBUG	BDTabort_expected= FALSE;	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 */	}	close_file(handle);				/* do it now */	if ( get_types(types,&results.attributes) != -1 ) {		/* NOT REACHED */	}	make_attribute_sequence(handle->pathname,&results.attributes);	return(results);#else EXTENSIONS	NoSuchProcedureValue("Filing", 8);#endif EXTENSIONS}get_types(types, attrseq)FILING_AttributeTypeSequence types;FILING_AttributeSequence *attrseq;{	int i;	LongCardinal t;	if ( types.length <= 0 ) {		ReturnAttributeTypeError(FILING_illegal, 0);		/* NOT REACHED */	}#ifdef EXTENSIONS	if ( *(types.sequence) == 037777777777 ) {#ifdef DEBUG		fprintf(msgs, "get_types: asking for all\n");#endif DEBUG		attrseq->length= -1;		attrseq->sequence= (FILING_Attribute *)				Allocate((SUPPORTEDATTRIBUTES + OPTIONALATTRIBUTES) * sizeof(FILING_Attribute)/sizeof(Unspecified));	} else {#endif EXTENSIONS		attrseq->length= types.length;		attrseq->sequence= (FILING_Attribute *)				Allocate(types.length * sizeof(FILING_Attribute)/sizeof(Unspecified));#ifdef DEBUG		fprintf(msgs, "get_types: asking for ");#endif DEBUG		for ( i = 0; i < types.length ; i ++ ) {			t= types.sequence[i];#ifdef DEBUG			fprintf(msgs, "%d  ",t);#endif DEBUG						if ( (t < 0) || ( t > FILING_subtreeSizeLimit) ) {#ifdef FILETOOLCOMPATIBILITY				if ( t != 4938 ) {					ReturnAttributeTypeError(FILING_illegal, t);					/* NOT REACHED */				}#else FILETOOLCOMPATIBILITY				ReturnAttributeTypeError(FILING_illegal, t);				/* NOT REACHED */#endif FILETOOLCOMPATIBILITY			}			if ( (t != FILING_createdOn) && (t != FILING_modifiedOn) &&					(t != FILING_isDirectory) && (t != FILING_isTemporary) &&					(t != FILING_name) && (t != FILING_pathname) &&#ifndef FILETOOLCOMPATIBILITY					(t != FILING_dataSize) && (t != FILING_type) &&					(t != FILING_version) ) {#else FILETOOLCOMPATIBILITY					(t != FILING_dataSize) && (t != FILING_type) &&					(t != FILING_createdBy) && (t != FILING_readOn) &&					(t != FILING_version) && (t != FILING_fileID)  &&					(t != 4938) ) {#endif FILETOOLCOMPATIBILITY				ReturnAttributeTypeError(FILING_disallowed, t);				/* NOT REACHED */			}			attrseq->sequence[i].type= t;		}#ifdef EXTENSIONS	}#endif EXTENSIONS#ifdef DEBUG	fprintf(msgs, "\n");#endif DEBUG}#ifdef EXTENSIONSmake_supported_attributes(attrseq)FILING_AttributeSequence *attrseq;{	attrseq->length= SUPPORTEDATTRIBUTES;	attrseq->sequence[0].type= FILING_createdOn;	attrseq->sequence[1].type= FILING_isDirectory;	attrseq->sequence[2].type= FILING_modifiedOn;	attrseq->sequence[3].type= FILING_name;	attrseq->sequence[4].type= FILING_dataSize;	attrseq->sequence[5].type= FILING_type;	attrseq->sequence[6].type= FILING_version;	attrseq->sequence[7].type= FILING_pathname;}make_required_attributes(attrseq)FILING_AttributeSequence *attrseq;{	attrseq->length= REQUIREDATTRIBUTES;	attrseq->sequence[0].type= FILING_createdOn;	attrseq->sequence[1].type= FILING_modifiedOn;	attrseq->sequence[2].type= FILING_name;	attrseq->sequence[3].type= FILING_dataSize;	attrseq->sequence[4].type= FILING_version;	attrseq->sequence[5].type= FILING_pathname;}#endif EXTENSIONSvoid FILING_ChangeAttributes(ServerConnection, BDTProc, file, attributes, session)CourierConnection *ServerConnection;int ( *BDTProc)();FILING_Handle file;FILING_AttributeSequence attributes;FILING_Session session;{#ifdef EXTENSIONS	file_handle *handle;	char oldname[MAX_FILE_NAME_LENGTH];#ifdef DEBUG	if (msgs == 0) {		char logfile[50];		sprintf(logfile, "/tmp/filing%ld.msgs", getpid());		msgs= fopen(logfile,"w");	}	fprintf(msgs, "ChangeAttributes\n");#endif DEBUG	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 */	}	close_file(handle);				/* do it now */	strcpy(oldname, handle->pathname);	if ( verify_change_attributes(attributes, handle) != -1 ) {		/* NOT REACHED */	}	if ( strcmp(oldname, handle->pathname) != 0 ) {		rename_file(oldname, handle);	}	set_create_time(handle);	return;#else EXTENSIONS	NoSuchProcedureValue("Filing", 9);#endif EXTENSIONS}#ifdef EXTENSIONSverify_change_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_ordering;	int got_subtreesizelimit, got_type, got_version;	FILING_Version version;	Boolean childrenuniquelynamed;	Cardinal ordering;			Cardinal subtreesizelimit;	char *AttrToString();	LongCardinal AttrToLongCardinal();	int got_name;	char *name;#ifdef DEBUG	fprintf(msgs,"%d change 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= 0;	got_ordering= got_subtreesizelimit= got_type= got_version= 0;	got_name= 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++;			handle->datasize= AttrToLongCardinal(&attr.sequence[i]);			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]);			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;		}		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;		}#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_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_isDirectory) ||				(t == FILING_isTemporary) || (t == FILING_modifiedBy) ||				(t == FILING_modifiedOn) || (t == FILING_numberOfChildren) ||				(t == FILING_parentID) || (t == FILING_pathname) ||				(t == FILING_readBy) || (t == FILING_readOn) ||				(t == FILING_storedSize) || (t == FILING_subtreeSize) ) {			ReturnAttributeTypeError(FILING_disallowed, t);		}		if ( t < 0 ) {			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);	}#ifdef DEBUG	fprintf(msgs, "\n");#endif DEBUG	if ( got_name ) {		char *ptr, *rindex();		if ( (ptr= rindex(handle->pathname, '/')) == 0 ) {			ptr= handle->pathname;		} else {			ptr++;			*ptr= '\0';		}		strcat(handle->pathname, name);	}	return(-1);}#endif EXTENSIONSFILING_CopyResults FILING_Copy(ServerConnection, BDTProc, file, destdir, attributes, controls,  session)CourierConnection *ServerConnection;int ( *BDTProc)();FILING_Handle file;FILING_Handle destdir;FILING_AttributeSequence attributes;FILING_ControlSequence controls;FILING_Session session;{#ifdef EXTENSIONS	FILING_CopyResults results;	file_handle *handle;	file_handle *dir_handle;	file_handle *new_handle;#ifdef DEBUG	if (msgs == 0) {		char logfile[50];		sprintf(logfile, "/tmp/filing%ld.msgs", getpid());		msgs= fopen(logfile,"w");	}	fprintf(msgs, "Copy\n");#endif DEBUG	BDTabort_expected= FALSE;	if ( verify_session(session) != -1 ) {		/* NOT REACHED */	}	copyhandle(&handle, file);	if ( handle->state != FILE_OPEN ) {		ReturnHandleError(FILING_invalid);		/* NOT REACHED */	}	if ( access_file(handle) != -1 ) {		/* NOT REACHED */	}	if ( (new_handle= (file_handle *)malloc(sizeof(file_handle))) == NULL ) {		ReturnUndefinedError(0);		/* NOT REACHED */	}	if ( (new_handle->pathname= (char *)malloc(MAX_FILE_NAME_LENGTH)) == NULL ) {		ReturnUndefinedError(0);		/* NOT REACHED */	}#ifdef DEBUG	fprintf(msgs, "copy handle= %x\n",new_handle);#endif DEBUG	copyhandle(&dir_handle,destdir);	if ( dir_handle == 0 ) {		dir_handle= &RootHandle;		strcpy(new_handle->pathname, SERVICE_ROOT);	} else {		if ( dir_handle->state != FILE_OPEN ) {			ReturnHandleError(FILING_invalid);			/* NOT REACHED */		}		if ( access_file(dir_handle) != -1 ) {			/* NOT REACHED */		}		if ( dir_handle->isdirectory != TRUE ) {			ReturnHandleError(FILING_directoryRequired);			/* NOT REACHED */		}		strcpy(new_handle->pathname,dir_handle->pathname);		if ( strcmp(new_handle->pathname, "/") != 0 )			strcat(new_handle->pathname,"/");	} 	if ( verify_copy_attributes(attributes,new_handle,handle) != -1 ) {		/* NOT REACHED */	}	close_file(handle);#ifdef DEBUG	fprintf(msgs, "copying %s to %s\n", handle->pathname, new_handle->pathname);	fflush(msgs);#endif DEBUG	if ( copy_file(handle, new_handle) != -1 ) {		/* NOT REACHED */	}	new_handle->state= FILE_OPEN;	new_handle->file_desc= NULL;

⌨️ 快捷键说明

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