/****** uti/hostname/sge_hostmatch() ******************************************** * NAME * sge_hostmatch() -- fnmatch() for hostnames * * SYNOPSIS * int sge_hostmatch(const char *h1, const char*h2) * * FUNCTION * fnmatch() for hostnames. Honours some configuration values: * - Domain name may be ignored * - Domain name may be replaced by a 'default domain' * - Hostnames may be used as they are. * * INPUTS * const char *h1 - 1st hostname * const char *h2 - 2nd hostname * * RESULT * int - 0, 1 or -1 * * SEE ALSO * uti/hostname/sge_hostcmp() * uti/hostname/sge_hostcpy() * * NOTES: * MT-NOTE: sge_hostmatch() is MT safe ******************************************************************************/ int sge_hostmatch(const char *h1, const char*h2) { int cmp = -1; char h1_cpy[CL_MAXHOSTLEN], h2_cpy[CL_MAXHOSTLEN]; DENTER(BASIS_LAYER, "sge_hostmatch"); if (h1 != NULL && h2 != NULL) { sge_hostcpy(h1_cpy,h1); sge_hostcpy(h2_cpy,h2); cmp=fnmatch(h1_cpy, h2_cpy, 0); DPRINTF(("sge_hostmatch(%s, %s) = %d\n", h1_cpy, h2_cpy, cmp)); } DEXIT; return cmp; }
/****** uti/hostname/sge_hostcmp() ******************************************** * NAME * sge_hostcmp() -- strcmp() for hostnames * * SYNOPSIS * int sge_hostcmp(const char *h1, const char*h2) * * FUNCTION * strcmp() for hostnames. Honours some configuration values: * - Domain name may be ignored * - Domain name may be replaced by a 'default domain' * - Hostnames may be used as they are. * * INPUTS * const char *h1 - 1st hostname * const char *h2 - 2nd hostname * * RESULT * int - 0, 1 or -1 * * SEE ALSO * uti/hostname/sge_hostmatch() * uti/hostname/sge_hostcpy() * * NOTES: * MT-NOTE: sge_hostcmp() is MT safe ******************************************************************************/ int sge_hostcmp(const char *h1, const char*h2) { int cmp = -1; char h1_cpy[CL_MAXHOSTLEN+1], h2_cpy[CL_MAXHOSTLEN+1]; DENTER(BASIS_LAYER, "sge_hostcmp"); if (h1 != NULL && h2 != NULL) { sge_hostcpy(h1_cpy,h1); sge_hostcpy(h2_cpy,h2); cmp = SGE_STRCASECMP(h1_cpy, h2_cpy); DPRINTF(("sge_hostcmp(%s, %s) = %d\n", h1_cpy, h2_cpy)); } DEXIT; return cmp; }