slidescript/src/inc/deps.h

112 lines
4.0 KiB
C
Executable File

/*
SlideScript - minimalistic top-down scripting language.
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
View README file supplied with this software for more details
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <grp.h>
#include <pwd.h>
#include <signal.h>
#include <regex.h>
#include <limits.h>
#include <stddef.h>
#include "config.h"
#include "sbyteswap.h"
#include <sys/types.h>
#include <sys/select.h>
// Networking
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
// For tar containers
#if !defined(__APPLE__)
#include <sys/sysmacros.h>
#endif
// For file handling
#include <assert.h>
#include <sys/stat.h>
// For string searching
#include <regex.h>
// Math for compression algorithm
#include <stdint.h>
#include <math.h>
#define MAX_VAR_NAME_LEN 512
#define MAX_VAR_NAME_BUFSIZE (MAX_VAR_NAME_LEN + 1)
#define MAX_STRING_LEN 8128
#define MAX_STRING_BUFSIZE (MAX_STRING_LEN + 1)
#define MAX_VAR_DATA_LEN 65536
#define MAX_DATA_BUFSIZE (MAX_VAR_DATA_LEN + 1)
#define MAXVARS 1488
#define MAX_PIPE_CMDS 32
#define MAX_CONCAT_BUF 131072
#define MAX_READFILE_LEN 2097152
// for networking functions
#define MAX_ADDRESS_LEN 256
#define MAX_ADDRESS_BUF (MAX_ADDRESS_LEN + 1)
#define MAX_NETSRCH_LEN 4096
#define MAX_NETSRCH_BUF (MAX_NETSRCH_LEN + 1)
#define MAX_NETRESP_LEN 65536
#define MAX_NETRESP_BUF (MAX_NETRESP_BUF + 1)
// For Expr
#define MAX_EXPR_ARGS 128
#define MAX_EXPR_LEN 512
// For search
#define MAX_SEARCH_LEN 65536
#define MAX_SEARCH_BUFSIZE (MAX_SEARCH_LEN + 1)
// For files
#define MAX_FILENAME_LEN 1024
#define MAX_FILENAME_BUFSIZE (MAX_FILENAME_LEN + 1)
#define MAX_FILES 1024
// END
#define TOKEN '%'
#define TOKEN_STR "%"
#define TOKEN_BQ '`'
#define NULLBYTE '\0'
#define NEWLINE '\n'
#define ENCOFFSET 3
#define ENCSTEPODD 2
#define ENCSTEPEVEN 2
// HELP PRINTOUT
#define FUNCTION_HELP "-[Main Functions]-\nlist:\n" \
" print \"<string>\" |" \
" sleep <integer> |" \
" encode \"<string>\"\n" \
" decode \"<string>\" |" \
" compress \"<archive name>\" \"<file/list>\"\n" \
" decompress \"<archive name>\" |" \
" calc \"<int> <+/-*> <int>\"\n" \
" move \"<orig>\" \"<new>\" |" \
" chdir \"<path>\" |" \
" showdir |" \
" showpath\n" \
" isdir \"<dirname>\" |" \
" isfile \"<filename>\" |" \
" delete \"<filename>\"\n" \
" nethttp \"<port>\" \"<forkval>\" (1 forks, 0 nofork)\n" \
" read \"<filename>\" |" \
" write \"<filename>\" \"<string>\"\n" \
" cat \"<filename>\" \"<string>\" |" \
" exec \"<cmd>\"\n" \
"\n-[Variables, Pipes, and Backquoting]-\nExample:\n" \
" FORK=`isfile \"index.html\"` -> returns 1 on find\n" \
" write \"port.txt\" \"8888\" -> writes '8888' to port.txt\n" \
" read \"port.txt\" | nethttp \"%PIPE%\" \"%FORK%\"\n\n" \
"This an example of how piping works, along with variables and \n" \
"backquote function execution. Return values are saved as variables.\n" \
"\n-[Specials]-\nExample:\n" \
"comp: \"<int1/str1>\" \"<int2/str2>\" -> returns (true|false)\n" \
"loop: <int>; <function> -> loops function for 'int' times\n"