F.3 AddCtResource
Add a Resource to a data file.
SHORT NAME
ADDRES
TYPE
Low level file resource function
DECLARATION
COUNT AddCtResource(COUNT filno, pVOID resptr, VRLEN varlen)DESCRIPTION
AddCtResource is used to add a Resource to file filno. Every Resource is identified by a unique combination of a Resource Type and a Resource Number. The Resource Number can optionally be assigned by c-tree Plus during the call to AddCtResource. In addition, each Resource can be identified by a Resource Name. The Resource Name is not guaranteed to be unique.
resptr points to a resource data block. This block contains the following fields:
The Resource Type must be a value greater than 65536. 0 through 65536 are reserved for FairCom use.
If the Resource Number is a value of 0xffffffffL, c-tree Plus assigns this Resource the next available Resource Number for this Resource Type in the specified data file. AddCtResource places assigned Resource Number in the Resource Data Block.
The Resource Name is optional. c-tree Plus does not guarantee unique Resource Names. Names starting with "FC!" or "RD!", are reserved for FairCom use.
The Resource Information is any collection of data that you wish to store as a Resource. It can be a character string, a structure, or any variable type.
RETURN
See Appendix A "c-tree Plus Error Codes" of the c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus error values.
EXAMPLE
/* add a resource and retrieve using GetCtResource */struct { /* Resource Data Block structure */ULONG resource_type;ULONG resource_number;TEXT variable_info[1016]; * Holds Resource Name and Data */} my_resource;my_resource.resource_type = 0x10001L; /* 65537 */ my_resource.resource_number = 0xffffffffL; /* c-tree Plus toassign number */ strcpy(my_resource.variable_info,"MY!resource"); strcpy(my_resource.variable_info + 12,"Actual Resource Data");if (AddCtResource(filno,&my_resource,(VRLEN)(8+12 + strlen(my_resource.variable_info+12))) == 0 ) {printf("\nThe resource has been assigned number %ld",my_resource.resource_number);printf("\nThe resource is located at byte offset %ld.", GetCtRe- source(filno,"MY!resource",&my_resource,1024L,RES_NAME); } elseprintf("\nCould not add resource. Error #%d",uerr_cod);Limitations
The recbyt parameter in this function is a 4-byte value capable of addressing at most 4 gigabytes. If your application supports HUGE files (greater than 4 gigabytes), you must use the ctSetHgh() and ctGetHgh() functions to set or get the high order 4 bytes of the file offset.
SEE ALSO
GetCtResource, UpdateCtResource, and DeleteCtResource. Section 8.1 "Resources" on page 8-1 in c-tree Plus Programmer's Reference Guide.
|
FairCom Corporation www.faircom.com |