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

/* This function is autogenerated by ResGen, and returns a pointer to a
 * ResourceFS resource file data block */
extern void *Resources(void);

/* This function is implemented in assembler. This and the previous
 * declaration could equally have been placed in a header file. */
extern void Beep(void);

/* cmhg can auto-generate a header file containing the next two
 * declarations. The header file will have the sane name as the cmhg file.
 * To use this, ensure you have a 'h' directory, and add a static dependency
 * between this object file and the header file in the Makefile. */
_kernel_oserror *Init(const char *cmd_tail, int podule_base, void *pw);
_kernel_oserror *Final(int fatal, int podule, void *pw);

/* A quick macro to silence compiler warnings about unused parameters */
#define IGNORE(x) do { (void)(x); } while(0)

int main(void)
{
  int i;
  for (i = 1; i <= 10; i++)
    printf("%d\n", i);
  Beep();
  exit(EXIT_SUCCESS);
}

_kernel_oserror *Init(const char *cmd_tail, int podule_base, void *pw)
{
  IGNORE(cmd_tail);
  IGNORE(podule_base);
  IGNORE(pw);
#ifndef ROM_MODULE
  return _swix(ResourceFS_RegisterFiles, _IN(0), Resources());
#else
  /* In ROM builds, all resource files live in the Messages module instead */
  return NULL;
#endif
}

_kernel_oserror *Final(int fatal, int podule, void *pw)
{
  IGNORE(fatal);
  IGNORE(podule);
  IGNORE(pw);
#ifndef ROM_MODULE
  _swix(ResourceFS_DeregisterFiles, _IN(0), Resources());
#endif
  return NULL;
}
