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

📄 dialfile.c

📁 unix高级编程源代码.<<unix高级编程>>
💻 C
字号:
#include	"calld.h"

static FILE	*fpdial = NULL;
static int	diallineno;			/* for error messages */
static char	dialline[MAXLINE];
		/* can't be automatic; dial_next() returns pointers into here */

/* Read and break apart a line in the Dialers file. */

int
dial_next(Dialers *dialptr)	/* pointers in structure are filled in */
{
	if (fpdial == NULL) {
		if ( (fpdial = fopen(DIALERS, "r")) == NULL)
			log_sys("can't open %s", DIALERS);
		diallineno = 0;
	}

again:
	if (fgets(dialline, MAXLINE, fpdial) == NULL)
		return(-1);		/* EOF */
	diallineno++;

	if ( (dialptr->dialer = strtok(dialline, WHITE)) == NULL) {
		if (dialline[0] == '\n')
			goto again;		/* ignore empty line */
		log_quit("missing `dialer' in Dialers file, line %d", diallineno);
	}
	if (dialptr->dialer[0] == '#')
		goto again;			/* ignore comment line */

	if ( (dialptr->sub = strtok(NULL, WHITE)) == NULL)
		log_quit("missing `sub' in Dialers file, line %d", diallineno);

	if ( (dialptr->expsend = strtok(NULL, "\n")) == NULL)
		log_quit("missing `expsend' in Dialers file, line %d", diallineno);

	return(0);
}

void
dial_rew(void)
{
	if (fpdial != NULL)
		rewind(fpdial);
	diallineno = 0;
}

/* Find a dialer match */

int
dial_find(Dialers *dialptr, const Devices *devptr)
{
	dial_rew();
	while (dial_next(dialptr) >= 0) {
		if (strcmp(dialptr->dialer, devptr->dialer) == 0)
			return(0);		/* found a dialer match */
	}
	sprintf(errmsg, "dialer `%s' not found\n", dialptr->dialer);
	return(-1);
}

⌨️ 快捷键说明

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