aboutsummaryrefslogtreecommitdiff
path: root/apps/interpreters/ficl/src/nuttx.c
blob: 16b3fa1dbc0c7b841c07b6b209d071bf6a1f2b26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <sys/stat.h>
#include <sys/statfs.h>

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

#include "ficl.h"

void *ficlMalloc(size_t size)
{
  return malloc(size);
}

void *ficlRealloc(void *p, size_t size)
{
  return realloc(p, size);
}

void ficlFree(void *p)
{
  free(p);
}

void  ficlCallbackDefaultTextOut(ficlCallback *callback, char *message)
{
  FICL_IGNORE(callback);
  if (message != NULL)
      fputs(message, stdout);
  else
      fflush(stdout);
  return;
}

int ficlFileStatus(char *filename, int *status)
{
    struct stat statbuf;
    if (stat(filename, &statbuf) == 0)
    {
        *status = statbuf.st_mode;
        return 0;
    }
    *status = ENOENT;
    return -1;
}

long ficlFileSize(ficlFile *ff)
{
    struct stat statbuf;
    if (ff == NULL)
        return -1;
	
    statbuf.st_size = -1;
    if (fstat(fileno(ff->f), &statbuf) != 0)
        return -1;
	
    return statbuf.st_size;
}

void ficlSystemCompilePlatform(ficlSystem *system)
{
    return;
}