# --------------------------- # get_unique_node_name_28char # --------------------------- # This subroutine returns a unique node name with a maximum length # of 28 characters so that the maximum filename length does not # exceed 32 characters (28 char for node name + 4 char for ".cfg") subroutine(get_unique_node_name_28char(string node_to_check, string the_node_name), ( if (node_exists(node_to_check . "." . the_node_name) or (length(the_node_name) > 28)) then ( subroutine(get_modified_node_name(string the_node_name, int count), ( string node_name_substring = the_node_name; string s = count . ".cfg"; int max_node_name_substring_length = 32 - length(s); if (length(node_name_substring) > max_node_name_substring_length) then ( node_name_substring = substr(node_name_substring, 0, max_node_name_substring_length); ); node_name_substring . count; )); int count = 1; bool node_name_is_unique = false; string modified_node_name; # If node_name is > 28 char then try first a simple truncation, without adding a number. if (length(the_node_name) > 28) then ( modified_node_name = substr(the_node_name, 0, 28); if (!node_exists(node_to_check . "." . modified_node_name)) then ( node_name_is_unique = true; the_node_name = modified_node_name; ); ); # if node_name is not yet unique start incrementation while (!node_name_is_unique) ( modified_node_name = get_modified_node_name(the_node_name, count); if (!node_exists(node_to_check . "." . modified_node_name)) then ( node_name_is_unique = true; the_node_name = modified_node_name; ); count++; ); ); the_node_name; ));