37 int n = (
int)list.size();
42 for (i=incr; i<
n; i++) {
45 if (
stricmp(list[j].c_str(), list[j + incr].c_str()) > 0) {
47 list[j] = list[j + incr];
52 (*info)[j] = (*info)[j + incr];
53 (*info)[j + incr] = tt;
72 for (i=incr; i<
n; i++) {
75 if ( (*info)[j].write_time < (*info)[j + incr].write_time ) {
77 list[j] = list[j + incr];
81 (*info)[j] = (*info)[j + incr];
82 (*info)[j + incr] = tt;
96 std::reverse( list.begin(), list.end() );
99 std::reverse( info->begin(), info->end() );
105 nprintf((
"Error",
"Unknown sorting method %d passed to cf_sort_filenames()\n", sort));
124 for (i=incr; i<
n; i++) {
127 if (
stricmp(list[j], list[j + incr]) > 0) {
129 list[j] = list[j + incr];
134 info[j] = info[j + incr];
154 for (i=incr; i<
n; i++) {
157 if (info[j].write_time < info[j + incr].write_time) {
159 list[j] = list[j + incr];
163 info[j] = info[j + incr];
182 for (i = 0; i < incr; i++) {
191 tt = info[n - 1 -
i];
202 nprintf((
"Error",
"Unknown sorting method %d passed to cf_sort_filenames()\n", sort));
206 #if (0) // these aren't used anywhere now
214 int cf_compress(
char *out,
char *
in,
int bytecount )
217 char *inputpixel=NULL;
218 char *matchpixel=NULL;
239 if ( pixcount == 129 ) {
244 if ( rlcount >= rlthresh ) {
251 memmove( flagbyte, copyloc, pixcount-1 );
252 flagbyte += pixcount-1;
260 if ( pixcount == 1 ) {
262 copyloc = inputpixel;
263 matchpixel = inputpixel;
272 if ( *inputpixel == *matchpixel ) {
279 if ( ++rlcount == rlthresh ) {
283 if ( pixcount > (rlcount+1) ) {
286 *flagbyte++ = (char)(pixcount - 2 - rlthresh);
288 memmove(flagbyte, copyloc, (pixcount-1-rlcount) );
289 flagbyte += (pixcount-1-rlcount);
291 copyloc = inputpixel;
292 pixcount = rlcount + 1;
302 if ( rlcount >= rlthresh ) {
304 *flagbyte++ = (char)(0x80 | rlcount);
305 memmove(flagbyte, copyloc, 1 );
315 matchpixel = inputpixel;
320 }
while ( inputpixel < (in + bytecount));
323 if ( --pixcount >= 1 ) {
324 *flagbyte = (char)(pixcount - 1);
325 if ( rlcount >= rlthresh ) {
332 memmove(flagbyte, copyloc, pixcount );
333 flagbyte += pixcount;
335 return(flagbyte-out);
345 int cf_decompress(
char *out,
char *in )
349 char *param_out = out;
354 int run_span = count & 0x80;
363 memset( out, c, count );
366 memmove( out, in, count );
373 return out - param_out;
387 char *out = (
char *)buf;
393 if (
cfread( &count, 1, 1, cfile ) != 1 ) {
397 int run_span = count & 0x80;
405 if (
cfread( &c, 1, 1, cfile ) != 1 ) {
408 memset( out, c, count );
410 if (
cfread( out, 1, count, cfile ) != count ) {
415 if ( out >= (
char *)buf + (elsize*nelem)) {
423 return (out - (
char *)buf)/elsize;
428 char *in = (
char *)param_buf;
429 int bytecount = (param_elsize * param_nelem );
432 char *inputpixel=NULL;
433 char *matchpixel=NULL;
452 if ( pixcount == 129 ) {
457 if ( rlcount >= rlthresh ) {
465 cfwrite( copyloc, 1, pixcount-1, cfile );
473 if ( pixcount == 1 ) {
475 copyloc = inputpixel;
476 matchpixel = inputpixel;
485 if ( *inputpixel == *matchpixel ) {
492 if ( ++rlcount == rlthresh ) {
496 if ( pixcount > (rlcount+1) ) {
502 cfwrite( copyloc, 1, (pixcount-1-rlcount), cfile );
503 copyloc = inputpixel;
504 pixcount = rlcount + 1;
514 if ( rlcount >= rlthresh ) {
518 cfwrite( copyloc, 1, 1, cfile );
527 matchpixel = inputpixel;
532 }
while ( inputpixel < (in + bytecount));
535 if ( --pixcount >= 1 ) {
540 if ( rlcount >= rlthresh ) {
548 cfwrite( copyloc, 1, pixcount, cfile );
int cfread(void *buf, int elsize, int nelem, CFILE *fp)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
GLenum GLuint GLenum GLsizei const GLchar * buf
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
int cfwrite(const void *buf, int elsize, int nelem, CFILE *cfile)
int cfread_compressed(void *buf, int elsize, int nelem, CFILE *cfile)
int cfwrite_compressed(void *param_buf, int param_elsize, int param_nelem, CFILE *cfile)
void cf_sort_filenames(SCP_vector< SCP_string > &list, int sort, SCP_vector< file_list_info > *info)