Пример #1
0
static int
process_line(struct conf_writedata *cnf)
{
	unsigned char *cp = cnf->conf_line;
	int i;

	if (cnf->card->debug_flags & LOG_CNF_LINE)
		hysdn_addlog(cnf->card, "conf line: %s", cp);

	if (*cp == '-') {	/* option */
		cp++;		/* point to option char */

		if (*cp++ != 'c')
			return (0);	/* option unknown or used */
		i = 0;		/* start value for channel */
		while ((*cp <= '9') && (*cp >= '0'))
			i = i * 10 + *cp++ - '0';	/* get decimal number */
		if (i > 65535) {
			if (cnf->card->debug_flags & LOG_CNF_MISC)
				hysdn_addlog(cnf->card, "conf channel invalid  %d", i);
			return (-ERR_INV_CHAN);		/* invalid channel */
		}
		cnf->channel = i & 0xFFFF;	/* set new channel number */
		return (0);	/* success */
	}			/* option */
	if (*cp == '*') {	/* line to send */
		if (cnf->card->debug_flags & LOG_CNF_DATA)
			hysdn_addlog(cnf->card, "conf chan=%d %s", cnf->channel, cp);
		return (hysdn_tx_cfgline(cnf->card, cnf->conf_line + 1,
					 cnf->channel));	/* send the line without * */
	}			/* line to send */
	return (0);
}				/* process_line */
static int
process_line(struct conf_writedata *cnf)
{
	unsigned char *cp = cnf->conf_line;
	int i;

	if (cnf->card->debug_flags & LOG_CNF_LINE)
		hysdn_addlog(cnf->card, "conf line: %s", cp);

	if (*cp == '-') {	/*        */
		cp++;		/*                      */

		if (*cp++ != 'c')
			return (0);	/*                        */
		i = 0;		/*                         */
		while ((*cp <= '9') && (*cp >= '0'))
			i = i * 10 + *cp++ - '0';	/*                    */
		if (i > 65535) {
			if (cnf->card->debug_flags & LOG_CNF_MISC)
				hysdn_addlog(cnf->card, "conf channel invalid  %d", i);
			return (-ERR_INV_CHAN);		/*                 */
		}
		cnf->channel = i & 0xFFFF;	/*                        */
		return (0);	/*         */
	}			/*        */
	if (*cp == '*') {	/*              */
		if (cnf->card->debug_flags & LOG_CNF_DATA)
			hysdn_addlog(cnf->card, "conf chan=%d %s", cnf->channel, cp);
		return (hysdn_tx_cfgline(cnf->card, cnf->conf_line + 1,
					 cnf->channel));	/*                         */
	}			/*              */
	return (0);
}				/*              */