#include #include #include "UDFCDF_Defs.h" #include "UDFCDF_Str.h" #include "UDFCDF_Ansi.h" ByTe_2 SortKeys (void) { extern struct UserDefs InFo; struct SrcInfo *S; u_ByTe_4 KeY; ByTe_4 bytes; register ByTe_2 *s1, *s2, *sEnd; register ByTe_2 J; bytes = 2 * sizeof (ByTe_2) * InFo.EmptySrc; /* order bytes */ if ((InFo.SOrder = malloc(bytes)) == 0) /* grab array */ return (-1); /* MALLOC ERROR! */ s2 = (ByTe_2 *) InFo.SOrder + InFo.EmptySrc; /* flags here */ sEnd = s2 + InFo.EmptySrc; /* end of flags here */ for ( ; s2 < sEnd; ++s1) /* loop over flags */ *s2++ = 0; /* and zero out */ s1 = (ByTe_2 *) InFo.SOrder; /* order data here */ sEnd = s1 + InFo.EmptySrc; /* end of order */ while (s1 < sEnd) /* do all sources */ { S = (struct SrcInfo *)InFo.Src; /* sources here */ s2 = sEnd; /* flags here */ J = 0; while (*s2 == 1 && J < InFo.EmptySrc) /* loop to beg */ { /* BEG FIND BEG LOOP */ ++s2; /* next flag */ ++S; /* next source */ ++J; /* increment index */ } /* END FIND BEG LOOP */ KeY = S->Key; /* Key to match */ for ( ; J < InFo.EmptySrc; ++S, ++s2, ++J) /* order src loop */ if (S->Key == KeY) /* key match? */ { /* BEG KEY MATCH */ *s1++ = J; /* save match position */ *s2 = 1; /* set processed flag */ } /* BEG KEY MATCH */ } return (1); }