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

📄 filingd.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
	copyhandle(results.newFile, &new_handle);	reset_continuance_timer();	return(results);#else EXTENSIONS	NoSuchProcedureValue("Filing", 10);#endif EXTENSIONS}#ifdef EXTENSIONSverify_copy_attributes(attr, tohandle, fromhandle)FILING_AttributeSequence attr;file_handle *tohandle;file_handle *fromhandle;{	int i;	FILING_AttributeType t;	int got_accesslist, got_defaultaccesslist, got_istemporary;	int got_name, got_pathname, got_subtreesizelimit, got_version;	char *pathname;	char *name;	FILING_Version version;	Boolean istemporary;	Cardinal subtreesizelimit;	char *AttrToString();	LongCardinal AttrToLongCardinal();#ifdef DEBUG	fprintf(msgs,"%d copy attributes	",attr.length);#endif DEBUG	if ( attr.length < 0 ) {		ReturnAttributeTypeError(FILING_illegal, 0);		/* NOT REACHED */	}	got_accesslist= got_defaultaccesslist= got_istemporary= 0;	got_name= got_pathname= got_subtreesizelimit= got_version= 0;	for ( i= 0 ; i < attr.length ; i++ ) {		t= attr.sequence[i].type;#ifdef DEBUG		fprintf(msgs, "%d ",t);#endif DEBUG		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_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;		}		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_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_position ) {			ReturnAttributeTypeError(FILING_unimplemented, t);			/* NOT REACHED */		}		if ( ( t < 0 ) || (t > FILING_subtreeSizeLimit) ) {			ReturnAttributeTypeError(FILING_illegal, t);			/* NOT REACHED */		}		ReturnAttributeTypeError(FILING_disallowed, t);	}#ifdef DEBUG	fprintf(msgs, "\n");#endif DEBUG#ifdef FILETOOLCOMPATIBILITY	if ( !got_pathname && !got_name) {		char *ptr, *rindex();		if ( (ptr= rindex(fromhandle->pathname,'/')) == 0 ) 			ptr= fromhandle->pathname;		else			ptr++;		strcat(tohandle->pathname, ptr);	} else 	if ( !got_pathname )  {		strcat(tohandle->pathname,name);	} else {		if ( *pathname == '/' )			strcat(tohandle->pathname, pathname+1);		else			strcat(tohandle->pathname,pathname);		Deallocate(&pathname);	}#else FILETOOLCOMPATIBILITY	if ( !got_pathname ) {		ReturnAttributeTypeError(FILING_missing, t);		/* NOT REACHED */	} else {		if ( *pathname == '/' )			strcat(tohandle->pathname, pathname+1);		else			strcat(tohandle->pathname, pathname);		Deallocate(&pathname);	}#endif FILETOOLCOMPATIBILITY	return(-1);}#endif EXTENSIONSvoid FILING_Move(ServerConnection, BDTProc, file, destdir, attributes, session)CourierConnection *ServerConnection;int ( *BDTProc)();FILING_Handle file;FILING_Handle destdir;FILING_AttributeSequence attributes;FILING_Session session;{#ifdef EXTENSIONS	file_handle *handle;	file_handle *dir_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, "Move\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 */	}	strcpy(oldname, handle->pathname);	copyhandle(&dir_handle,destdir);	if ( dir_handle == 0 ) {		dir_handle= &RootHandle;		strcpy(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(handle->pathname,dir_handle->pathname);		if ( strcmp(handle->pathname, "/") != 0 )			strcat(handle->pathname,"/");	} 	if ( verify_move_attributes(attributes,handle,oldname) != -1 ) {		/* NOT REACHED */	}	close_file(handle);#ifdef DEBUG	fprintf(msgs, "moving %s to %s\n", oldname, handle->pathname);#endif DEBUG	if ( rename_file(oldname, handle) != -1 ) {		/* NOT REACHED */	}	reset_continuance_timer();	return;#else EXTENSIONS	NoSuchProcedureValue("Filing", 11);#endif EXTENSIONS}#ifdef EXTENSIONSverify_move_attributes(attr, tohandle, fromname)FILING_AttributeSequence attr;file_handle *tohandle;char *fromname;{	int i;	FILING_AttributeType t;	int got_accesslist, got_defaultaccesslist, got_istemporary;	int got_name, got_subtreesizelimit, got_version;	char *name;	FILING_Version version;	Boolean istemporary;	Cardinal subtreesizelimit;	char *AttrToString();	LongCardinal AttrToLongCardinal();#ifdef DEBUG	fprintf(msgs,"%d move attributes	",attr.length);#endif DEBUG	if ( attr.length < 0 ) {		ReturnAttributeTypeError(FILING_illegal, 0);		/* NOT REACHED */	}	got_accesslist= got_defaultaccesslist= got_istemporary= 0;	got_name= got_subtreesizelimit= got_version= 0;	for ( i= 0 ; i < attr.length ; i++ ) {		t= attr.sequence[i].type;#ifdef DEBUG		fprintf(msgs, "%d ",t);#endif DEBUG		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;		}		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_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_position ) {			ReturnAttributeTypeError(FILING_unimplemented, t);			/* NOT REACHED */		}		if ( ( t < 0 ) || (t > FILING_subtreeSizeLimit) ) {			ReturnAttributeTypeError(FILING_illegal, t);			/* NOT REACHED */		}		ReturnAttributeTypeError(FILING_disallowed, t);	}#ifdef DEBUG	fprintf(msgs, "\n");#endif DEBUG	if ( !got_name) {		char *ptr, *rindex();		if ( (ptr= rindex(fromname,'/')) == 0 ) 			ptr= fromname;		else			ptr++;		strcat(tohandle->pathname, ptr);	} else {		strcat(tohandle->pathname,name);	} 	return(-1);}#endif EXTENSIONSFILING_StoreResults FILING_Store(ServerConnection, BDTProc, directory, attributes, controls, content, session)CourierConnection *ServerConnection;int ( *BDTProc)();FILING_Handle directory;FILING_AttributeSequence attributes;FILING_ControlSequence controls;BulkData1_Descriptor content;FILING_Session session;{	FILING_StoreResults results;	file_handle *handle, *dir_handle;#ifdef DEBUG	if (msgs == 0) {		char logfile[50];		sprintf(logfile, "/tmp/filing%ld.msgs", getpid());		msgs= fopen(logfile,"w");	}	fprintf(msgs, "Store  ");#endif DEBUG	BDTabort_expected= TRUE;	if ( verify_session(session) != -1 ) {		/* NOT REACHED */	}#ifndef FILETOOLCOMPATIBILITY	if ( is_nullControls(controls) != -1) {		ReturnControlTypeError(FILING_disallowed, 0);		/* NOT REACHED */	}	if ( is_nullHandle(directory) != -1 ) {		ReturnHandleError(FILING_invalid);		/* NOT REACHED */	}#endif FILETOOLCOMPATIBILITY	if ( content.designator == BulkData1_null ) {		return;	} else  if ( content.designator != BulkData1_immediate ) {		ReturnTransferError(FILING_aborted);		/* NOT REACHED */	}	if ( (handle= (file_handle *)malloc(sizeof(file_handle))) == NULL ) {		ReturnUndefinedError(0);		/* NOT REACHED */	}	if ( (handle->pathname= (char *)malloc(MAX_FILE_NAME_LENGTH)) == NULL ) {		ReturnUndefinedError(0);		/* NOT REACHED */	}#ifdef DEBUG	fprintf(msgs, "store handle= %x\n",handle);#endif DEBUG#ifdef FILETOOLCOMPATIBILITY	copyhandle(&dir_handle,directory);	if ( dir_handle == 0 ) {		dir_handle= &RootHandle;		strcpy(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(handle->pathname,dir_handle->pathname);		if ( strcmp(handle->pathname, "/") != 0 )			strcat(handle->pathname,"/");	} #else FILETOOLCOMPATIBILITY	strcpy(handle->pathname, SERVICE_ROOT);#endif FILETOOLCOMPATIBILITY	if ( verify_store_attributes(attributes, handle) != -1 ) {		/* NOT REACHED */	}#ifdef DEBUG	fprintf(msgs, "creating '%s'\n", handle->pathname);#endif DEBUG	if ( handle->isdirectory == TRUE ) {		if ( dir_storeproc(ServerConnection,handle,content) != -1 ) {			/* NOT REACHED */		}	} else {		if ( create_file(handle) != -1 ) {			/* NOT REACHED */		}#ifdef EXTENSIONS		if ( (handle->type > LAST_FILING_TYPE) && (handle->type != TYPE_Interpress) &&					(handle->type != TYPE_VPCanvas) ) {			SaveExtendedAttributes(handle->file_desc, attributes);		}#endif EXTENSIONS		if ( storeproc(ServerConnection,handle) != -1 ) {			close_file(handle);			delete_partial_file(handle);			ReturnTransferError(FILING_aborted);			/* NOT REACHED */		}		close_file(handle);

⌨️ 快捷键说明

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