<commit_before>/**
 *   (c) 2002 <NAME> <<EMAIL>>
 *   v0.0.2 endian.c
 *
 *   upod endianness functions
 *
 *   (7-9-2002) Added breaks to the cases.
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the Lesser GNU Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *   
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *   
 *   You should have received a copy of the Lesser GNU Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **/

#include "itunesdbi.h"

#include <stdio.h>
#include <stdlib.h>

void bswap_block (char *ptr, size_t membsize, size_t nmemb) {
  int i;

#if BYTE_ORDER == BIG_ENDIAN
  for (i = 0 ; i < nmemb ; i++)
    switch (membsize) {
    case 2:
      {
	short *r = (short *)ptr;
	/* may be needed for unicode strings */

	r[i] = bswap_16 (r[i]);
	break;
      }
    case 4:
      {
	long *r = (long *)ptr;
	r[i] = bswap_32 (r[i]);
	break;
      }
    }
#endif
}<commit_msg>made it work with linux<commit_after>/**
 *   (c) 2002 <NAME> <<EMAIL>>
 *   v0.0.2 endian.c
 *
 *   upod endianness functions
 *
 *   (7-9-2002) Added breaks to the cases.
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the Lesser GNU Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *   
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *   
 *   You should have received a copy of the Lesser GNU Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **/

#include "itunesdbi.h"

#include <stdio.h>
#include <stdlib.h>
#include <endian.h>

void bswap_block (char *ptr, size_t membsize, size_t nmemb) {
  int i;

#if __BYTE_ORDER == __BIG_ENDIAN
  switch (membsize) {
    case 2:
      {
        u_int16_t *r = (u_int16_t *)ptr;

        for (i = 0 ; i < nmemb ; i++)
          r[i] = bswap_16 (r[i]);

        break;
      }

    case 4:
      {
        u_int32_t *r = (u_int32_t *)ptr;

        for (i = 0 ; i < nmemb ; i++)
          r[i] = bswap_32 (r[i]);

        break;
      }
  }
#endif
}
{'fraction_non_alphanumeric': 0.10397992111868053, 'fraction_numerical': 0.024022947292936535, 'mean_word_length': 2.609314359637775, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6491171', 'n_tokens_mistral': 990, 'n_tokens_neox': 928, 'n_words': 368}