static int match_auth(register Xauth *a, register Xauth *b) { return ((match_auth_dpy(a, b) && a->name_length == b->name_length && memcmp(a->name, b->name, a->name_length) == 0) ? 1 : 0); }
static int iterdpy (char *inputfilename, int lineno, int start, int argc, char *argv[], YesNoFunc yfunc, YesNoFunc nfunc, char *data) { int i; int status; int errors = 0; Xauth proto; AuthList *l, *next; /* * iterate */ for (i = start; i < argc; i++) { char *displayname = argv[i]; proto.address = proto.number = NULL; if (!get_displayname_auth (displayname, &proto)) { prefix (inputfilename, lineno); baddisplayname (displayname, argv[0]); errors++; continue; } status = 0; for (l = xauth_head; l; l = next) { next = l->next; if (match_auth_dpy (&proto, l->auth)) { if (yfunc) { status = (*yfunc) (inputfilename, lineno, l->auth, data); if (status < 0) break; } } else { if (nfunc) { status = (*nfunc) (inputfilename, lineno, l->auth, data); if (status < 0) break; } } } if (proto.address) free (proto.address); if (proto.number) free (proto.number); if (status < 0) { errors -= status; /* since status is negative */ break; } } return errors; }
static int iterdpy (const char *inputfilename, int lineno, int start, int argc, const char *argv[], YesNoFunc yfunc, YesNoFunc nfunc, char *data) { int i; int status; int errors = 0; Xauth *tmp_auth; AuthList *proto_head, *proto; AuthList *l, *next; /* * iterate */ for (i = start; i < argc; i++) { const char *displayname = argv[i]; if (!get_displayname_auth (displayname, &proto_head)) { prefix (inputfilename, lineno); baddisplayname (displayname, argv[0]); errors++; continue; } status = 0; for (l = xauth_head; l; l = next) { Bool matched = False; /* l may be freed by remove_entry below. so save its contents */ next = l->next; tmp_auth = copyAuth(l->auth); for (proto = proto_head; proto; proto = proto->next) { if (match_auth_dpy (proto->auth, tmp_auth)) { matched = True; if (yfunc) { status = (*yfunc) (inputfilename, lineno, tmp_auth, data); if (status < 0) break; } } } XauDisposeAuth(tmp_auth); if (matched == False) { if (nfunc) { status = (*nfunc) (inputfilename, lineno, l->auth, data); } } if (status < 0) break; } for (proto = proto_head; proto ; proto = next) { next = proto->next; if (proto->auth->address) free (proto->auth->address); if (proto->auth->number) free (proto->auth->number); free (proto->auth); free (proto); } if (status < 0) { errors -= status; /* since status is negative */ break; } } return errors; }