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

📄 var.c

📁 使用BorlandC++4.5编译的一个MUD客户端程序
💻 C
字号:
head	2.1;access;symbols;locks; strict;comment	@ * @;2.1date	95.10.24.15.46.14;	author tsurace;	state Release;branches;next	1.1;1.1date	95.10.12.21.05.28;	author tsurace;	state Beta;branches;next	;desc@(Interpreted) variable hash table.@2.1log@Roll.@text@/* var.c: Maintains variable indices hash table */
/* $Id: var.c 1.1 1995/10/12 21:05:28 tsurace Beta tsurace $ */

#include "vt.h"
#define VTSIZE 203

/* Variable values are kept in a global array.	Variable names are
** kept in a hash table used to access indices.	 The function
** get_index() is called by walk.c. */

/* Variables are hashed to unordered chains. */

struct var {
	char *name;
	int ind;
	struct var *next;
};

static int vindex = 0;
static struct var *vtab[VTSIZE];

/* Return an index to a variable, creating one if necessary */
int get_vindex(name)
	char *name;
{
	int hval;
	struct var *vp;

	hval = hash(name, VTSIZE);
	for (vp = vtab[hval]; vp; vp = vp->next) {
		if (streq(vp->name, name))
			return vp->ind;
	}
	vp = New(struct var);
	vp->name = vtstrdup(name);
	vp->ind = vindex++;
	vp->next = vtab[hval];
	vtab[hval] = vp;
	return vp->ind;
}

void write_vartab(fp)
	FILE *fp;
{
	int i;
	struct var *vp;

	fputs("VARS\n", fp);
	for (i = 0; i < VTSIZE; i++) {
		for (vp = vtab[i]; vp; vp = vp->next)
			fprintf(fp, "%d %s\n", vp->ind, vp->name);
	}
}


@1.1log@Initial revision@text@d2 1a2 1/* $Id$ */@

⌨️ 快捷键说明

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