Exemple #1
0
READOSM_DECLARE int
readosm_open (const char *path, const void **osm_handle)
{
/* opening and initializing the OSM input file */
    readosm_file *input;
    int len;
    int format;
    int little_endian_cpu = test_endianness ();

    *osm_handle = NULL;
    if (path == NULL || osm_handle == NULL)
	return READOSM_NULL_HANDLE;

    len = strlen (path);
    if (len > 4 && strcasecmp (path + len - 4, ".osm") == 0)
	format = READOSM_OSM_FORMAT;
    else if (len > 4 && strcasecmp (path + len - 4, ".pbf") == 0)
	format = READOSM_PBF_FORMAT;
    else
	return READOSM_INVALID_SUFFIX;

/* allocating the OSM input file struct */
    input = alloc_osm_file (little_endian_cpu, format);
    if (!input)
	return READOSM_INSUFFICIENT_MEMORY;
    *osm_handle = input;

    input->in = fopen (path, "rb");
    if (input->in == NULL)
	return READOSM_FILE_NOT_FOUND;

    return READOSM_OK;
}
Exemple #2
0
/**
 * The application entry point under linux and windows.
 *
 * @param argc number of arguments including the program name
 * @param argv program arguments including the program name
 */
int main(int argc, char *argv[])
{
    /* rhash_transmit(RMSG_SET_OPENSSL_MASK, 0, RHASH_ALL_HASHES, 0); */

#ifndef USE_RHASH_DLL
    rhash_library_init();
#endif

    test_endianness();

    if(argc > 1 && strcmp(argv[1], "--speed") == 0) {
        unsigned hash_id = (argc > 2 ? find_hash(argv[2]) : RHASH_SHA1);
        if(hash_id == 0) {
            fprintf(stderr, "error: unknown hash_id: %s\n", argv[2]);
            return 1;
        }
        test_known_strings(hash_id);

        run_benchmark(hash_id, 0, stdout);
    } else if(argc > 1 && strcmp(argv[1], "--flags") == 0) {
        printf("%s", compiler_flags);
    } else {
        test_all_known_strings();
        test_long_strings();
        test_alignment();
        if(n_errors == 0) printf("All sums are working properly!\n");
        fflush(stdout);
    }

    if(n_errors > 0) printf("%s", compiler_flags);

    return (n_errors == 0 ? 0 : 1);
}
void CPocketStreetPushPinsWriter::psp_fwrite_double(double x, FILE *fp)
{
	unsigned char *cptr = (unsigned char *)&x;
	unsigned char cbuf[8];

	if (!m_endianness_tested) 
	{
		test_endianness();
	}
	
	if (m_i_am_little_endian) 
	{
		fwrite(&x, 8, 1, fp);
	} 
	else 
	{
		cbuf[0] = cptr[7];
		cbuf[1] = cptr[6];
		cbuf[2] = cptr[5];
		cbuf[3] = cptr[4];
		cbuf[4] = cptr[3];
		cbuf[5] = cptr[2];
		cbuf[6] = cptr[1];
		cbuf[7] = cptr[0];

		fwrite(cbuf, 8, 1, fp);
	}
}
Exemple #4
0
void validate (int argc, const char* argv[])
{
    init_deterministic_keys();
    test_endianness();
    print_disable_stohastic_rounding_warning();
    validate_vector_ops();
    validate_matrix_ops();
}
Exemple #5
0
/**
 * Run various simple tests.
 */
static void test_generic_assumptions(void)
{
	unsigned mask = (1 << RHASH_HASH_COUNT) - 1;
	if (mask != RHASH_ALL_HASHES) {
		log_message("error: wrong algorithms count %d for the mask 0x%x\n", RHASH_HASH_COUNT, RHASH_ALL_HASHES);
		g_errors++;
	}

	test_endianness();
}
Exemple #6
0
main ()
{
  if (test_endianness () != test_endianness_vol ())
    abort ();
  exit (0);
}