Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2003 Pekka Riikonen
+ Copyright (C) 2003 - 2004 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
/* Read width and height */
- ret = fscanf(fp, "%s %ld %ld %ld ",
- type, &map->width, &map->height, &map->maxcolor);
+ ret = fscanf(fp, "%s %ld %ld %ld ", type,
+ (unsigned long *)&map->width,
+ (unsigned long *)&map->height,
+ (unsigned long *)&map->maxcolor);
if (ret < 4) {
fprintf(stderr, "Invalid PPM file");
retval = FALSE;
}
/* Read the picture */
- map->bitsilc_map_size = map->width * 3 * map->height;
- map->bitmap = silc_malloc(map->bitsilc_map_size);
- ret = fread(map->bitmap, map->bitsilc_map_size, 1, fp);
+ map->bitmap_size = map->width * 3 * map->height;
+ map->bitmap = silc_malloc(map->bitmap_size);
+ ret = fread(map->bitmap, map->bitmap_size, 1, fp);
if (ret < 0) {
fprintf(stderr, "fread: %s\n", strerror(errno));
retval = FALSE;
{
FILE *fp;
int retval = TRUE;
- int i, k;
SILC_LOG_DEBUG(("Write PPM '%s'", filename));
}
/* Write the header */
- fprintf(fp, "P6 %ld %ld %ld\n", map->width, map->height, map->maxcolor);
+ fprintf(fp, "P6 %ld %ld %ld\n",
+ (unsigned long)map->width,
+ (unsigned long)map->height,
+ (unsigned long)map->maxcolor);
/* Write the bitmap */
- fwrite(map->bitmap, map->bitsilc_map_size, 1, fp);
+ fwrite(map->bitmap, map->bitmap_size, 1, fp);
fclose(fp);
return retval;
/* Sanity checks */
if (height > map->height - y) {
- fprintf(stderr, "Requesting too much height: %ld\n", height);
+ fprintf(stderr, "Requesting too much height: %ld\n",
+ (unsigned long)height);
return FALSE;
}
if (width > map->width - x) {
- fprintf(stderr, "Requesting too much width: %ld\n", width);
+ fprintf(stderr, "Requesting too much width: %ld\n",
+ (unsigned long)width);
return FALSE;
}
(*ret_map)->width = width;
(*ret_map)->height = height;
(*ret_map)->maxcolor = map->maxcolor;
- (*ret_map)->bitsilc_map_size = (width * 3) * height;
- (*ret_map)->bitmap = silc_malloc((*ret_map)->bitsilc_map_size);
+ (*ret_map)->bitmap_size = (width * 3) * height;
+ (*ret_map)->bitmap = silc_malloc((*ret_map)->bitmap_size);
/* Copy the requested area */
for (i = 0; i < height; i++) {