8888 loader: rename STAND to _STANDALONE
[unleashed.git] / usr / src / common / ficl / ficlplatform / unix.c
blob420ec0254678226d6ccde5d4f815fc477cc02f8e
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2015 Toomas Soome <tsoome@me.com>
16 #include "ficl.h"
18 void *
19 ficlMalloc(size_t size)
21 return (malloc(size));
24 void *
25 ficlRealloc(void *p, size_t size)
27 return (realloc(p, size));
30 void
31 ficlFree(void *p)
33 free(p);
36 void
37 ficlCallbackDefaultTextOut(ficlCallback *callback, char *message)
39 FICL_IGNORE(callback);
41 if (message != NULL) {
42 #ifdef _STANDALONE
43 while (*message != 0)
44 putchar((unsigned char)*(message++));
45 #else
46 (void) fputs(message, stdout);
47 (void) fflush(stdout);
48 #endif
52 #if FICL_WANT_FILE
53 int
54 ficlFileTruncate(ficlFile *ff, ficlUnsigned size)
56 return (ftruncate(fileno(ff->f), size));
59 int
60 ficlFileStatus(char *filename, int *status)
62 struct stat statbuf;
64 if (stat(filename, &statbuf) == 0) {
65 *status = statbuf.st_mode;
66 return (0);
68 *status = ENOENT;
69 return (-1);
72 long
73 ficlFileSize(ficlFile *ff)
75 struct stat statbuf;
77 if (ff == NULL)
78 return (-1);
80 statbuf.st_size = -1;
81 if (fstat(fileno(ff->f), &statbuf) != 0)
82 return (-1);
84 return (statbuf.st_size);
86 #endif