FTAM/9000 Programmer's Guide
Chapter 10 377
Example Programs
Setting Ae_dir_dn and P_address Utility Example
/*
** Set the p_addr.
*/
j = 0;
index = 0;
while ( !null_flag ) {
/*
** Has the end of the string been reached?
*/
if (name[j] == NULL)
null_flag = TRUE;
/* Parse the next field until a delimiter or the
** end of the string has been reached.
*/
if ((name[j] != ‘.’) & & ( !null_flag )) {
temp[i] = name[j];
++i;
++j;
}
/*
** Another field has been parsed; set up the correct p_addr field.
*/
if ((null_flag) || (name[j] == ‘.’)) {
if (i != 0) {
++index;
switch (index) {
case 1:
/* p_selector
*/
p_addr->p_selector->pointer = (Octet *)malloc
(i*sizeof(Octet));
char_to_hex(temp, i, (char *)p_addr->p_selector->pointer,
& (p_addr->p_selector->length));
break;
case 2:
/* s_selector
*/
p_addr->s_selector->pointer = (Octet *)malloc
(i*sizeof(Octet));
char_to_hex(temp, i, (char *)p_addr->s_selector->pointer,
& (p_addr->s_selector->length));
break;
case 3:
/* t_selector
*/
p_addr->t_selector->pointer = (Octet *)malloc
(i*sizeof(Octet));
char_to_hex(temp, i, (char *)p_addr->t_selector->pointer,
& (p_addr->t_selector->length));
break;
default:
/* nsaps ... could be multiple nsaps.
*/
p_addr->nsaps[index - 4].pointer = (Octet *)malloc
(i*sizeof(Octet));
char_to_hex(temp, i, (char *)p_addr->nsaps[index -
4].pointer,
& (p_addr->nsaps[index - 4].length));
break;
}