-/*
- * sort_mxrecs()
- *
- * Sort a pile of MX records (struct mx, definted in domain.h) by preference
- *
- */
-void sort_mxrecs(struct mx *mxrecs, int num_mxrecs) {
- int a, b;
- struct mx hold1, hold2;
-
- if (num_mxrecs < 2) return;
-
- /* do the sort */
- for (a = num_mxrecs - 2; a >= 0; --a) {
- for (b = 0; b <= a; ++b) {
- if (mx_compare_pref(mxrecs[b].pref,mxrecs[b+1].pref)) {
- memcpy(&hold1, &mxrecs[b], sizeof(struct mx));
- memcpy(&hold2, &mxrecs[b+1], sizeof(struct mx));
- memcpy(&mxrecs[b], &hold2, sizeof(struct mx));
- memcpy(&mxrecs[b+1], &hold1, sizeof(struct mx));
- }
- }
- }
-}
-
-
-