/* Functions for retrieving, modifying and deleting cross-references */
+int is_valid_pointer(const char *key)
+{
+ return (strlen(key) <= 22 &&
+ gedcom_check_token(key, STATE_NORMAL, POINTER) == 0);
+}
+
struct xref_value* gedcom_get_by_xref(const char *key)
{
- if (gedcom_check_token(key, STATE_NORMAL, POINTER) != 0) {
+ if (!is_valid_pointer(key)) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), key);
return NULL;
}
{
struct xref_node *xr = NULL;
- if (gedcom_check_token(xrefstr, STATE_NORMAL, POINTER) != 0) {
+ if (!is_valid_pointer(xrefstr)) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
{
struct xref_node *xr = NULL;
- if (gedcom_check_token(xrefstr, STATE_NORMAL, POINTER) != 0) {
+ if (!is_valid_pointer(xrefstr)) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
struct xref_value* gedcom_unlink_xref(Xref_type type, const char* xrefstr)
{
struct xref_node *xr = NULL;
- if (gedcom_check_token(xrefstr, STATE_NORMAL, POINTER) != 0) {
+ if (!is_valid_pointer(xrefstr)) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {
struct xref_node *xr = NULL;
int result = 1;
- if (gedcom_check_token(xrefstr, STATE_NORMAL, POINTER) != 0) {
+ if (!is_valid_pointer(xrefstr)) {
gedcom_error(_("String '%s' is not a valid cross-reference key"), xrefstr);
}
else {