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

📄 admin.c

📁 通讯程序源码
💻 C
字号:
/* * Perform administrative functions.  Check to see if the user has * permission to make long distance calls, and record all phone calls * made by Pcomm. */#include <stdio.h>#include <grp.h>#include "config.h"#include "dial_dir.h"#include "param.h"static char *build_num();/* * Make a log of all calls made by Pcomm.  The argument is the index * into the queue. *//* ARGSUSED */voidlog_calls(i)int i;{#ifdef LOG_CALLS	FILE *fp;	char *number, *date, *ctime(), *getlogin(), buf[80];	long now, time();	void error_win();					/* build the complete phone number */	number = build_num(i);					/* build date and time */	time(&now);	date = ctime(&now);	date[10] = '\0';	date[16] = '\0';	if (!(fp = fopen(LOG_FILE, "a+"))) {					/* fatal! (to prevent hanky panky) */		sprintf(buf, "Can't open log file \"%s\"", LOG_FILE);		error_win(1, buf, "Contact your system administrator");	}	fprintf(fp, "pcomm: %s called %s at %s on %s\n", getlogin(), number, &date[11], date);	fclose(fp);#endif /* LOG_CALLS */	return;}/* * Check to see if long distance (toll) call is authorized.  The argument * is the index into the queue. *//* ARGSUSED */intlimit_ld(i)int i;{#ifdef LIMIT_LD	char *number, *name, *getlogin();	struct group *getgrnam(), *grpbuf;					/* if no group, don't bother */	grpbuf = getgrnam(GROUP_NAME);	if (grpbuf == NULL || *grpbuf->gr_mem == '\0')		return(0);					/* are you in the group? */	name = getlogin();	for (; *grpbuf->gr_mem!='\0'; grpbuf->gr_mem++) {		if (!strcmp(*grpbuf->gr_mem, name))			return(0);	}					/* numbers only... */	number = build_num(i);	/*	 * VERY SITE SPECIFIC!!!  We use a "9" to get an outside line,	 * so any 9 followed by a 1 is a toll call (except for 1-800	 * numbers).	 */	if (!strncmp(number, "91", 2) && strncmp(number, "91800", 5)) {		error_win(0, "You are not authorized to place long distance (toll) calls", "");		return(1);	}	if (*number == '\0') {		error_win(0, "You are not authorized direct access to the line", "Use the automatic dialing feature");		return(1);	}#endif /* LIMIT_LD */	return(0);}#if defined(LOG_CALLS) || defined(LIMIT_LD)/* * Put together the complete phone number but strip out the extraneous * characters. */static char *build_num(i)int i;{	int j;	char *t, temp[80], *strcpy(), *strcat();	static char ans[80];	temp[0] = '\0';					/* add LD codes? */	switch (dir->q_ld[i]) {		case 0:			break;		case '+':			strcpy(temp, param->ld_plus);			break;		case '-':			strcpy(temp, param->ld_minus);			break;		case '@':			strcpy(temp, param->ld_at);			break;		case '#':			strcpy(temp, param->ld_pound);			break;	}					/* add the number */	strcat(temp, dir->number[dir->q_num[i]]);					/* copy only digits */	j = 0;	t = temp;	while (*t) {		if (*t >= '0' && *t <= '9')			ans[j++] = *t;		t++;	}	ans[j] = '\0';	return(ans);}#endif /* LOG_CALLS || LIMIT_LD */

⌨️ 快捷键说明

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