[nos-bbs] STRICTCALL LOGIN

Barry Siegfried k2mf at nnj.k2mf.ampr.org
Fri Oct 14 07:32:14 EDT 2005


[maiko at pcs.mb.ca wrote]:

> > > in JNOS there is no such a function, how difficult
> > > would be to add this in future versions.
>
> Just take the code from TNOS and put it in.  If I'm not
> mistaken, TNOS was a variant of JNOS itself back when.

Here is a relatively decent callsign checking subfunction which
I have been using in my software for over 10 years.  It seems to
work ok.

/* Universal callsign validation subroutine.  It is assumed that a string
 * containing only alphanumeric characters is being passed to it.
 * - 08/94 K2MF */
int
callcheck
(char *str)
{
	int i, length;
	int8 digits = 0, firstdigit = 0, seconddigit = 0;
	int8 thirddigit = 0, fourthdigit = 0, fifthdigit = 0;

	length = strlen(str);

	if(length < 3 || length > 6)
		/* Callsign less than 3 or greater than 6 characters */
		return -1;				/* invalid */

	for(i = 0; i < length; i++) {
		if(!isalnum(str[i]))
			/* Character is not alphanumeric */
			return -1;			/* invalid */

		if(isdigit(str[i])) {
			/* Got a digit */
			if(++digits > 2)
				/* More than 2 digits in callsign */
				return -1;		/* invalid */

			switch(i) {
				case 0:
					/* 1st character */
					if(length == 3)
						/* Callsign only 3
						 * characters */
						return -1;	/* invalid */

					firstdigit++;
					break;
				case 1:
					/* 2nd character */
					if(firstdigit || length == 3)
						/* 1st character also a
						 * digit or callsign only
						 * 3 characters */
						return -1;	/* invalid */

					seconddigit++;
					break;
				case 2:
					if(seconddigit && length == 3)
						/* 2nd character also a
						 * digit and callsign only
						 * 3 characters */
						return -1;	/* invalid */

					thirddigit++;
					break;
				case 3:
					/* 4th character */
					if(firstdigit || length == 4)
						/* 1st character also a
						 * digit or callsign only
						 * 4 characters */
						return -1;	/* invalid */

					fourthdigit++;
					break;
				case 4:
					/* 5th character */
					if(firstdigit || length == 5)
						/* 1st character also a
						 * digit or callsign only
						 * 5 characters */
						return -1;	/* invalid */

					fifthdigit++;
					break;
				case 5:
					/* Digit in 6th character */
					return -1;		/* invalid */
			}
		}
	}
	if(!thirddigit && (firstdigit || !seconddigit))
		/* The 3rd character is not a digit and the 1st character
		 * is a digit or the 2nd character is not a digit */
		return -1;					/* invalid */

	/* String is a valid callsign (it passed all the tests!) */
	return 0;
}

73, de Barry, K2MF >>
           o
          <|>      Barry Siegfried
+---------/-\---------------------------+
| Internet | bgs at mfnos.net              |
| HomePage | http://www.mfnos.net/~bgs  |
+----------+----------------------------+
| Amprnet  | k2mf at nnj.k2mf.ampr.org     |
| PBBS     | k2mf at k2ge.#cnj.nj.usa.noam |
+----------+----------------------------+




More information about the nos-bbs mailing list