home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsm / randjpeg / source / c / main next >
Encoding:
Text File  |  1995-12-27  |  1.1 KB  |  63 lines

  1. /* randjpeg.c
  2.  * MACHINE:     RISC OS 3.60
  3.  * LANGUAGE:    Acorn C v5.06
  4.  * AUTHOR:      Cy Booker <cy@cheepnis.demon.co.uk>
  5.  * LICENCE:     Freeware, copyright 1995
  6.  */
  7.  
  8. #include "main.h"
  9.  
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <time.h>
  14.  
  15.  
  16. #include "randfile.h"
  17. #include "process.h"
  18.  
  19.  
  20.  
  21. /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  22.  */
  23.  
  24. int main(
  25.                 int     argc,
  26.                 char    **argv) {
  27.  
  28.   char  *file;
  29.  
  30.   if (argc != 4) {
  31.     fprintf(stderr, "randjpeg: usage is randjpeg <path> <history-file> <sprite-file> (%d)\n", argc);
  32.     return EXIT_FAILURE;
  33.   }
  34.   srand(time(NULL));
  35.   file = rand_file(argv[1], argv[2]);
  36.   if (!file) {
  37.     fputs("randjpeg: no JPEG files found\n", stderr);
  38.     return EXIT_FAILURE;
  39.   }
  40.   process(file, argv[3]);
  41.   free(file);
  42.   return EXIT_SUCCESS;
  43. }
  44.  
  45.  
  46.  
  47. /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  48.  */
  49.  
  50. extern void *xmalloc(
  51.                 size_t  count) {
  52.   void  *ptr;
  53.  
  54.   ptr = malloc(count);
  55.   if (ptr == NULL) {
  56.     fprintf(stderr, "randjpeg: out of memory (need %u)\n", (unsigned int)count);
  57.     exit(EXIT_FAILURE);
  58.   }
  59.   return ptr;
  60. }
  61.  
  62.  
  63.