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

📄 imports.c

📁 Ming is a library for generating Macromedia Flash files (.swf), written in C, and includes useful ut
💻 C
字号:
/* $Id: imports.c,v 1.5 2007/03/18 21:12:47 krechert Exp $ */#include <stdlib.h>#include <string.h>#include "imports.h"#include "method.h"#include "libming.h"intwriteSWFImportBlockToMethod(SWFBlock block, SWFByteOutputMethod method, void *data){	SWFImportBlock imports = (SWFImportBlock) block;	struct importitem *ip;	int length, count;	char *p;	length = 3 + strlen(imports->filename);	for(ip = imports->importlist, count = 0 ; ip ; ip = ip->next)	{	length += 3 + strlen(ip->name);		count++;	}	for(p = imports->filename ; *p ; )		method(*p++, data);	method(0, data);	if(block->swfVersion >= 8)	{		method(1, data);		method(0, data);	}	methodWriteUInt16(count, method, data);	for(ip = imports->importlist ; ip ; ip = ip->next)	{	methodWriteUInt16(ip->id, method, data);		for(p = ip->name ; *p ; )			method(*p++, data);		method(0, data);	}	return length;}intcompleteSWFImportBlock(SWFBlock block){	SWFImportBlock imports = (SWFImportBlock) block;	struct importitem *ip;	int length = 3 + strlen(imports->filename);	for(ip = imports->importlist ; ip ; ip = ip->next)		length += 3 + strlen(ip->name);	/* SWF_IMPORTASSETS is deprecated with version >= 8. */	if(block->swfVersion >= 8)	{		block->type = SWF_IMPORTASSETS2;		length += 2;	}		return length;}voiddestroySWFImportBlock(SWFImportBlock importBlock){	struct importitem *ip, *nip;	if(importBlock->filename)		free(importBlock->filename);	for(ip = importBlock->importlist ; ip ; ip = nip)	{	nip = ip->next;		if(ip->name)			free(ip->name);		free(ip);	}	free(importBlock);}static char *cpy(const char *text){	char *res, *p;	p = res = (char *)malloc(strlen(text)+1);	while((*p++ = *text++))		;	return res;}SWFImportBlocknewSWFImportBlock(const char *filename){	SWFImportBlock iblock = (SWFImportBlock) malloc(sizeof(struct SWFImportBlock_s));		BLOCK(iblock)->type = SWF_IMPORTASSETS;	BLOCK(iblock)->writeBlock = (writeSWFBlockMethod) writeSWFImportBlockToMethod;	BLOCK(iblock)->complete = completeSWFImportBlock;	BLOCK(iblock)->dtor = (destroySWFBlockMethod) destroySWFImportBlock;	BLOCK(iblock)->isDefined = 0;	BLOCK(iblock)->completed = 0;	iblock->filename = cpy(filename);	iblock->importlist = NULL;	return iblock;}

⌨️ 快捷键说明

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