Пример #1
0
int main(int argc, char * argv[])
{
	while(init()) {
		if(check_path() && 
		  dfs_path(begin, 0)) {
			dump_card();
		} else {
			printf("no solution\n");
		}
	}

	return 0;
}
Пример #2
0
int
main(int argc, char **argv)
{
	int fd;
	int ac;
	isdn_ioctl_struct ioctl_s;
	isdnloop_cdef newcard;
	isdnloop_sdef startparm;

	cmd = strrchr(argv[0], '/');
	cmd = (cmd == NULL) ? argv[0] : cmd + 1;
	if (argc > 1) {
		if (!strcmp(argv[1], "-d")) {
			strcpy(ioctl_s.drvid, argv[2]);
			arg_ofs = 3;
		} else {
			ioctl_s.drvid[0] = '\0';
			arg_ofs = 1;
		}
	} else
		usage();
	ac = argc - (arg_ofs - 1);
	fd = open("/dev/isdnctrl", O_RDWR);
	if (fd < 0) {
		perror(ctrldev);
		exit(-1);
	}
#ifdef __DEBUGVAR__
	if (!strcmp(argv[arg_ofs], "dump")) {
		char *p;
		ioctl_s.arg = (ulong) & dbg;
		if ((ioctl(fd, ISDNLOOP_IOCTL_DEBUGVAR + IIOCDRVCTL, &ioctl_s)) < 0) {
			perror("ioctl DEBUGVAR");
			exit(-1);
		}
		close(fd);
		p = mapmem(dbg.dev, sizeof(icn_dev));
		dump_dev((icn_dev *) p);
		p = mapmem(dbg.card, sizeof(icn_card));
		dump_card((icn_card *) p);
		return 0;
	}
#endif
	if (!strcmp(argv[arg_ofs], "leased")) {
		if (ac == 3) {
			ioctl_s.arg = 0;
			if ((!strcmp(argv[arg_ofs + 1], "on")) ||
			    (!strcmp(argv[arg_ofs + 1], "yes")))
				ioctl_s.arg = 1;
			if ((ioctl(fd, ISDNLOOP_IOCTL_LEASEDCFG + IIOCDRVCTL, &ioctl_s)) < 0) {
				perror("ioctl LEASEDCFG");
				exit(-1);
			}
			close(fd);
			return 0;
		}
	}
	if (!strcmp(argv[arg_ofs], "add")) {
		if (ac >= 2) {
			ioctl_s.arg = (unsigned long) &newcard;
			newcard.id1[0] = 0;
			strncpy(newcard.id1, argv[arg_ofs + 1], sizeof(newcard.id1) - 1);
			if ((ioctl(fd, ISDNLOOP_IOCTL_ADDCARD + IIOCDRVCTL, &ioctl_s)) < 0) {
				perror("ioctl ADDCARD");
				exit(-1);
			}
			close(fd);
			return 0;
		}
	}
	if (!strcmp(argv[arg_ofs], "start")) {
		int needed = 99;
		if (ac > 2) {
			if (!(strcmp(argv[arg_ofs + 1], "1tr6"))) {
				needed = 4;
				startparm.ptype = ISDN_PTYPE_1TR6;
			}
			if (!(strcmp(argv[arg_ofs + 1], "dss1"))) {
				needed = 6;
				startparm.ptype = ISDN_PTYPE_EURO;
			}
			if (ac >= needed) {
				strcpy(startparm.num[0], argv[arg_ofs + 2]);
				if (needed > 4) {
					strcpy(startparm.num[1], argv[arg_ofs + 3]);
					strcpy(startparm.num[2], argv[arg_ofs + 4]);
				}
				ioctl_s.arg = (unsigned long) &startparm;
				if (ioctl(fd, ISDNLOOP_IOCTL_STARTUP + IIOCDRVCTL, &ioctl_s) < 0) {
					perror("\nioctl STARTUP");
					exit(-1);
				}
				printf("done\n");
				close(fd);
				return 0;
			}
		}
		usage();
	}
	usage();
	return 0;
}