rem: if (hData == 0) printf ("Can't create data for '%s' <%lu>\n", file_buf, data_len);
add: if (hData == 0) fprintf (stderr, "Can't create data for '%s' <%lu>\n", file_buf, data_len);
context: load_package (INDEX_HEADERPTR ResHeaderPtr, RES_PACKAGE res_package){	BOOLEAN DanglingOpen;	MEM_HANDLE hList;	FILE *fp;	COUNT t, num_types, num_instances;	DWORD file_offs, data_len;	RES_HANDLE_LISTPTR ResourceHandleListPtr;	ENCODEPTR TypeEncodePtr;	DATAPTR DataPtr;#ifdef PACKAGING	extern#endif /* PACKAGING */	char file_buf[PATHLEN];	num_types = CountPackageTypes (ResHeaderPtr, res_package);	num_instances = CountPackageInstances (ResHeaderPtr, res_package);	if ((hList = AllocResourceHandleList (			num_types, num_instances			)) == NULL_HANDLE){#ifdef DEBUGprintf ("Unable to allocate resource handle list <%d, %d>\n", num_types, num_instances);#endif /* DEBUG */		return (NULL_HANDLE);}	LockResourceHandleList (ResHeaderPtr, hList, res_package,			&ResourceHandleListPtr, &TypeEncodePtr, &DataPtr);	ResourceHandleListPtr->flags_and_data_loc =			ResHeaderPtr->PackageList[res_package - 1].flags_and_data_loc;	DanglingOpen = FALSE;	file_offs = get_packmem_offs (ResHeaderPtr, res_package);	if (!(ResHeaderPtr->res_flags & IS_PACKAGED))	{		SeekResFile (ResHeaderPtr->res_fp, (long)file_offs, SEEK_SET);		if (ReadResFile ((PSTR)TypeEncodePtr,				(PACKMEM_LIST_SIZE * num_types)				+ (INSTANCE_LIST_SIZE * num_instances),				1, ResHeaderPtr->res_fp) != 1)		{			UnlockResourceHandleList (hList);			FreeResourceHandleList (hList);			return (NULL_HANDLE);		}		dword_convert (TypeEncodePtr, num_types);	}	else	{		COUNT file_index;		memcpy (TypeEncodePtr,				(PSTR)((PSTR)ResHeaderPtr + (COUNT)file_offs),				(PACKMEM_LIST_SIZE * num_types)				+ (INSTANCE_LIST_SIZE * num_instances));		dword_convert (TypeEncodePtr, num_types);		file_index = GET_PACKAGE (				ResHeaderPtr->PackageList[res_package - 1].packmem_info				);		get_resource_filename (ResHeaderPtr, file_buf, file_index);		if (!stricmp (ResHeaderPtr->index_file_name, file_buf))			fp = ResHeaderPtr->res_fp;		else		{			fp = OpenResFile (file_buf, "rb");			if (fp)				DanglingOpen = TRUE;		}		if (fp == NULL)			num_types = 0;		else		{			file_offs = ResourceHandleListPtr->flags_and_data_loc & ~0xFF000000;			if (file_offs)				SeekResFile (fp, (long)file_offs, SEEK_SET);			else if (num_types == 1 && GET_PACKAGE (*TypeEncodePtr) == 1)			{ /* if only one thing in this package which is only				 * package in its file, let file length be determined				 * by the current length of package rather than the				 * length at package time.				 */				RES_PACKAGE p;				for (p = 1; p <= ResHeaderPtr->num_packages; ++p)				{					if (p != res_package							&& GET_PACKAGE (							ResHeaderPtr->PackageList[p - 1].packmem_info)							== file_index)						break;				}				if (p > ResHeaderPtr->num_packages)				{					data_len = (LengthResFile (fp) + 3) >> 2;					DataPtr[0] = LOBYTE (data_len);					DataPtr[1] = HIBYTE (data_len);				}			}		}	}	for (t = 0; t < num_types; ++t)	{		RES_TYPE type;		type = GET_TYPE (*TypeEncodePtr);		num_instances = GET_PACKAGE (*TypeEncodePtr);		while (num_instances--)		{			MEM_HANDLE hData;			_cur_resfile_name = file_buf;			hData = NULL_HANDLE;			data_len = MAKE_WORD (DataPtr[0], DataPtr[1]);			if (ResHeaderPtr->res_flags & IS_PACKAGED)			{				if ((data_len <<= 2) == 0)					;				else if (SeekResFile (fp, (long)file_offs, SEEK_SET))					;				else				{					hData = DoLoad (ResHeaderPtr, type, fp, data_len);					if (hData && IsIndexType (ResHeaderPtr, type))						DanglingOpen = FALSE;#ifdef DEBUGif (hData == 0)printf ("fp = 0x%08lx(%d), type = %u, file_offs = %lu, len = %lu\n", fp, DanglingOpen, type, file_offs, data_len);#endif /* DEBUG */				}				file_offs += data_len;			}			else			{				get_resource_filename (ResHeaderPtr, file_buf, (COUNT)data_len);				fp = OpenResFile (file_buf, "rb");				if (fp == NULL)#if 1 // def DEBUGprintf ("Can't open '%s'\n", file_buf)#endif /* DEBUG */					;				else				{					data_len = LengthResFile (fp);#ifndef PACKAGINGprintf ("\t'%s' -- %lu bytes\n", file_buf, data_len);#endif /* PACKAGING */					if (data_len == 0)						hData = NULL_HANDLE;					else						hData = DoLoad (ResHeaderPtr, type, fp, data_len);					if (hData == 0 || !IsIndexType (ResHeaderPtr, type))						CloseResFile (fp);				}			}#ifdef DEBUGif (hData == 0) printf ("Can't create data for '%s' <%lu>\n", file_buf, data_len);#endif /* DEBUG */			DataPtr[0] = LOBYTE (hData);			DataPtr[1] = HIBYTE (hData);			DataPtr += 2;			if (hData)				++ResourceHandleListPtr->num_valid_handles;			_cur_resfile_name = 0;		}		++TypeEncodePtr;	}	if (DanglingOpen)		CloseResFile (fp);	num_instances = ResourceHandleListPtr->num_valid_handles;	UnlockResourceHandleList (hList);	if (num_instances == 0)	{#ifdef DEBUGprintf ("Nothing in package!\n");#endif /* DEBUG */		FreeResourceHandleList (hList);		hList = NULL_HANDLE;	}	return (hList);}