For functions defined to return a known resource type a special local variable return_res is generated.

This variables type is a pointer to the resources payload type and points to an allready allocated piece of memory of this type unless you specified alloc="no" in the resource tag.

All you have to do is to take care of storing the appropriate payload data here. The actual resource registration and returning code will be generated for you.

Resources will be covered in more detail later on.

<resource name="my_FILE" payload="FILE" alloc="no">
 <destruct>
  fclose(resource);
 </destruct>
</resource>

<function name="my_fopen">
 <proto>resource my_FILE my_fopen(string name, string mode)</proto>
 <code>
   return_res = fopen(name, mode);
   if (!return_res) RETURN_FALSE;
 </code>
</function>