Call this v0.5.4

master
Pentium44 2021-04-15 18:06:30 -07:00
parent 9b4288cf9c
commit a3223589f4
9 changed files with 298 additions and 310 deletions

View File

@ -2,7 +2,7 @@
# (C) Copyright 2014-2021 Chris Dorman, some rights reserved (GPLv2)
# Some changes and tweaks from Menchers
VERSION = \"0.5.3\"
VERSION = \"0.5.4\"
VERSION_EXTRA = \"$(EXTRA)\"
PREFIX ?= /usr
@ -12,8 +12,8 @@ CC ?= gcc
#CC ?= tcc
#CC ?= musl-tcc
CFLAGS += -O2 -pedantic -g -Wall -Wextra
# CPPFLAGS += -DVERSION=$(VERSION) -D_FORTIFY_SOURCE=2
CPPFLAGS += -DVERSION=$(VERSION)
CPPFLAGS += -DVERSION=$(VERSION) -D_FORTIFY_SOURCE=2
#CPPFLAGS += -DVERSION=$(VERSION)
LDFLAGS += -lm
BIN ?= slidescript

View File

@ -152,6 +152,11 @@ Changelog
Changes between version bumps in SlideScript. Hoping to have a lightweight top-down scripting language
by V1.0.0 release! From there it will be molding and preserving the art.
* V0.5.4
* Added memory management framework for dynamic memory handling
* tar.c cleanup
* fflush additions for telnet usage of SS.
* V0.5.3
* Added version, and help command

View File

@ -43,9 +43,9 @@
#define MAX_VAR_NAME_LEN 512
#define MAX_VAR_NAME_BUFSIZE (MAX_VAR_NAME_LEN + 1)
#define MAX_STRING_LEN 8128
#define MAX_STRING_LEN 65535
#define MAX_STRING_BUFSIZE (MAX_STRING_LEN + 1)
#define MAX_VAR_DATA_LEN 65536
#define MAX_VAR_DATA_LEN 65535
#define MAX_DATA_BUFSIZE (MAX_VAR_DATA_LEN + 1)
#define MAXVARS 1488
#define MAX_PIPE_CMDS 32
@ -109,3 +109,270 @@
"\n-[Specials]-\nExample:\n" \
"comp: \"<int1/str1>\" \"<int2/str2>\" -> returns (true|false)\n" \
"loop: <int>; <function> -> loops function for 'int' times\n"
// Purpose: UX3 basic definitions
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2021.
#ifndef _X3BASIC_H /* skip this file if loaded */
#define _X3BASIC_H 1 /* flag this file */
/* ------------------------------------------------------------ */
/* basic definitions */
/* ------------------------------------------------------------ */
#ifndef ZERO
#define ZERO 0
#endif // Endif ZERO
#ifndef ONE
#define ONE 1
#endif // Endif ONE
#ifndef FALSE
#define FALSE 0
#endif // Endif FALSE
#ifndef TRUE
#define TRUE 1
#endif // Endif TRUE
#ifndef CH_EOS
#define CH_EOS '\0'
#endif // Endif CH_EOS
#ifndef x3u_char
#define x3u_char unsigned char
#endif
#ifndef x3u_int
#define x3u_int unsigned int
#endif
#ifndef x3u_long
#define x3u_long unsigned long
#endif
#ifndef MODPRIV // Module-private
#define MODPRIV static
#endif // Endif MODPRIV
#ifndef MODPUB // Module-public
#define MODPUB
#endif // Endif MODPUB
#ifndef REG_VAR
#define REG_VAR
#endif // Endif NULL_PTR
/* ------------------------------------------------------------ */
/* "erase item" macro functions */
/* ------------------------------------------------------------ */
/* If "dp" is a data pointer (of any type) and "nb" is a short */
/* or long integer, "b_clr(dp,nb)" clears "nb" bytes to zero, */
/* starting with the first byte pointed to by "dp". */
/* Note: "nb" may use any integer data type, but the value of */
/* "nb" should fit into an unsigned integer. */
#define b_clr(dp,nb) \
{ \
REG_VAR char *cp = (char *) (dp); \
REG_VAR u_int x = (u_int) (nb); \
while (x-- > ZERO) *cp++ = CH_EOS; \
}
/* ------------------------------------------------------------ */
/* If "a[]" is an array, "a_clr(a)" clears the array (bytewise) */
/* to zero. "a[]" must be an array and not a pointer. The */
/* array must have a known fixed size. */
#define a_clr(a) b_clr ((char *) (&((a)[0])),sizeof(a))
/* ------------------------------------------------------------ */
/* If "p" is a pointer to a structure or variable, "p_clr(p)" */
/* clears the structure or variable. The pointer object must */
/* have a known fixed size. */
#define p_clr(p) b_clr ((char *) (p),sizeof(*p))
/* ------------------------------------------------------------ */
/* If "x" is a variable (and not an array), "v_clr(x)" clears */
/* the variable (bytewise) to zero. The variable must have a */
/* known fixed size. */
#define v_clr(x) b_clr ((char *) (&(x)),sizeof(x))
/* ------------------------------------------------------------ */
/* handle "void" data type */
/* ------------------------------------------------------------ */
/* The following five symbols provide a portable interface to */
/* the "void" data type. These five symbols are translated */
/* appropriately for systems which don't support the "void" */
/* type. */
/* (a) V_FUNC -- defines a void function */
/* (b) V_PROTO -- declares a void function */
/* (c) NO_PARAM -- void function parameter type */
/* (d) V_CAST -- void typecast */
/* (e) V_OBJ -- void pointer object */
/* ------------------------------------------------------------ */
/* V_FUNC may be used to declare a void function in the follow- */
/* ing context: */
/* */
/* V_FUNC function-definition(...) { ... } */
/* V_FUNC should not be used in function declarations or */
/* function prototypes. */
/* ------------------------------------------------------------ */
/* V_PROTO may be used to declare a void function in the */
/* following two contexts: */
/* */
/* V_PROTO function-declaration(); */
/* V_PROTO function-prototype(...); */
/* V_PROTO should not be used in function definitions. */
/* ------------------------------------------------------------ */
/* NO_PARAM may be used to declare a void function argument; */
/* for example, */
/* */
/* int foo(NO_PARAM) { ... } */
/* NO_PARAM may be used in function declarations, in function */
/* definitions, and in function prototypes. */
/* ------------------------------------------------------------ */
/* "V_OBJ *" translates into the appropriate void-pointer data */
/* type; for example, */
/* */
/* V_OBJ *malloc (argp1 (u_int)); */
/* ------------------------------------------------------------ */
/* V_CAST translates into a "void" typecast; for example, */
/* */
/* char *strcpy (argp2(char *,char *)); */
/* V_CAST strcpy (s,t); */
/* ------------------------------------------------------------ */
/* if "void" is not supported */
#ifdef NO_VOID /* "void" type is not supported */
#define NO_PARAM /* void parameter type (empty) */
#define V_CAST /* void typecast (no effect) */
#define V_FUNC /* void function definition */
#define V_OBJ char /* void pointer object */
#define V_PROTO extern /* void function declaration */
#endif /* endif "void not supported" */
/* ------------------------------------------------------------ */
/* if "void" is supported */
#ifndef NO_VOID /* "void" type is supported */
#ifdef NO_PROTO /* prototypes are not supported */
#define NO_PARAM /* void parameter type (empty) */
#else /* prototypes are supported */
#define NO_PARAM void /* void parameter type */
#endif /* endif NO_PARAM */
#endif /* endif "void is supported" */
#ifndef NO_VOID /* "void" type is supported */
#define V_CAST (void) /* void typecast */
#define V_FUNC void /* void function definition */
#define V_OBJ void /* void pointer object */
#define V_PROTO void /* void function declaration */
#endif /* endif "void is supported" */
/* ------------------------------------------------------------ */
/* ANSI prototype setup */
/* ------------------------------------------------------------ */
/* The following "argp#(...)" macros may be used in ANSI */
/* function prototypes. "#" should be replaced with the number */
/* of function arguments; e.g.: */
/* */
/* V_OBJ *malloc (argp1(u_int)); */
/* char *strcpy (argp2(char *,char *)); */
/* The "argp#(...)" macros discard their arguments on systems */
/* which do not support ANSI prototypes. */
/* The "ellipse" construct "..." counts as one argument. */
/* ------------------------------------------------------------ */
#ifdef NO_PROTO
#define argp0()
#define argp1(a)
#define argp2(a,b)
#define argp3(a,b,c)
#define argp4(a,b,c,d)
#define argp5(a,b,c,d,e)
#define argp6(a,b,c,d,e,f)
#define argp7(a,b,c,d,e,f,g)
#define argp8(a,b,c,d,e,f,g,h)
#define argp9(a,b,c,d,e,f,g,h,i)
#else
#define argp0() NO_PARAM
#define argp1(a) a
#define argp2(a,b) a,b
#define argp3(a,b,c) a,b,c
#define argp4(a,b,c,d) a,b,c,d
#define argp5(a,b,c,d,e) a,b,c,d,e
#define argp6(a,b,c,d,e,f) a,b,c,d,e,f
#define argp7(a,b,c,d,e,f,g) a,b,c,d,e,f,g
#define argp8(a,b,c,d,e,f,g,h) a,b,c,d,e,f,g,h
#define argp9(a,b,c,d,e,f,g,h,i) a,b,c,d,e,f,g,h,i
#endif
/* ------------------------------------------------------------ */
/* null pointers of various types */
/* ------------------------------------------------------------ */
/* Note: NULLXP is a null function pointer. */
#ifndef NULLXP
#define NULL_PTR ((void *) ZERO)
#define NULLCP ((char *) ZERO)
#define NULLFP ((FILE *) ZERO)
#define NULLVP ((V_OBJ *) ZERO)
#define NULLXP ((int (*)()) ZERO)
#endif // Endif NULLXP
/* ------------------------------------------------------------ */
/* resolve global variables */
/* ------------------------------------------------------------ */
#ifdef RES_UX3 /* resolve external variables? */
#define UX3_EXT /* yes */
#else /* no */
#define UX3_EXT extern /* variables are externals */
#endif
#ifdef VMS /* VMS host */
#undef UX3_EXT
#ifdef RES_UX3 /* resolve externals? */
#define UX3_EXT globaldef
#else /* don't resolve externals */
#define UX3_EXT globalref
#endif /* endif RES_UX3 */
#endif /* endif VMS */
/* ------------------------------------------------------------ */
/* wrap it up */
/* ------------------------------------------------------------ */
#endif // Endif _X3BASIC_H

View File

@ -13,7 +13,7 @@
#ifndef _EPRINTF_H /* skip this file if loaded */
#define _EPRINTF_H 1 /* flag this file */
#include "x3basic.h"
#include "deps.h"
/* ------------------------------------------------------------ */
/* TTY (console mode) flags */

View File

@ -1,275 +0,0 @@
/* ------------------------------------------------------------ */
/* file information */
/* ------------------------------------------------------------ */
// Filename: x3basic.h
// Purpose: UX3 basic definitions
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2021.
/* ------------------------------------------------------------ */
/* header file setup */
/* ------------------------------------------------------------ */
#ifndef _X3BASIC_H /* skip this file if loaded */
#define _X3BASIC_H 1 /* flag this file */
/* ------------------------------------------------------------ */
/* basic definitions */
/* ------------------------------------------------------------ */
#ifndef ZERO
#define ZERO 0
#endif // Endif ZERO
#ifndef ONE
#define ONE 1
#endif // Endif ONE
#ifndef FALSE
#define FALSE 0
#endif // Endif FALSE
#ifndef TRUE
#define TRUE 1
#endif // Endif TRUE
#ifndef CH_EOS
#define CH_EOS '\0'
#endif // Endif CH_EOS
#ifndef x3u_char
#define x3u_char unsigned char
#endif
#ifndef x3u_int
#define x3u_int unsigned int
#endif
#ifndef x3u_long
#define x3u_long unsigned long
#endif
#ifndef MODPRIV // Module-private
#define MODPRIV static
#endif // Endif MODPRIV
#ifndef MODPUB // Module-public
#define MODPUB
#endif // Endif MODPUB
#ifndef REG_VAR
#define REG_VAR
#endif // Endif NULL_PTR
/* ------------------------------------------------------------ */
/* "erase item" macro functions */
/* ------------------------------------------------------------ */
/* If "dp" is a data pointer (of any type) and "nb" is a short */
/* or long integer, "b_clr(dp,nb)" clears "nb" bytes to zero, */
/* starting with the first byte pointed to by "dp". */
/* Note: "nb" may use any integer data type, but the value of */
/* "nb" should fit into an unsigned integer. */
#define b_clr(dp,nb) \
{ \
REG_VAR char *cp = (char *) (dp); \
REG_VAR u_int x = (u_int) (nb); \
while (x-- > ZERO) *cp++ = CH_EOS; \
}
/* ------------------------------------------------------------ */
/* If "a[]" is an array, "a_clr(a)" clears the array (bytewise) */
/* to zero. "a[]" must be an array and not a pointer. The */
/* array must have a known fixed size. */
#define a_clr(a) b_clr ((char *) (&((a)[0])),sizeof(a))
/* ------------------------------------------------------------ */
/* If "p" is a pointer to a structure or variable, "p_clr(p)" */
/* clears the structure or variable. The pointer object must */
/* have a known fixed size. */
#define p_clr(p) b_clr ((char *) (p),sizeof(*p))
/* ------------------------------------------------------------ */
/* If "x" is a variable (and not an array), "v_clr(x)" clears */
/* the variable (bytewise) to zero. The variable must have a */
/* known fixed size. */
#define v_clr(x) b_clr ((char *) (&(x)),sizeof(x))
/* ------------------------------------------------------------ */
/* handle "void" data type */
/* ------------------------------------------------------------ */
/* The following five symbols provide a portable interface to */
/* the "void" data type. These five symbols are translated */
/* appropriately for systems which don't support the "void" */
/* type. */
/* (a) V_FUNC -- defines a void function */
/* (b) V_PROTO -- declares a void function */
/* (c) NO_PARAM -- void function parameter type */
/* (d) V_CAST -- void typecast */
/* (e) V_OBJ -- void pointer object */
/* ------------------------------------------------------------ */
/* V_FUNC may be used to declare a void function in the follow- */
/* ing context: */
/* */
/* V_FUNC function-definition(...) { ... } */
/* V_FUNC should not be used in function declarations or */
/* function prototypes. */
/* ------------------------------------------------------------ */
/* V_PROTO may be used to declare a void function in the */
/* following two contexts: */
/* */
/* V_PROTO function-declaration(); */
/* V_PROTO function-prototype(...); */
/* V_PROTO should not be used in function definitions. */
/* ------------------------------------------------------------ */
/* NO_PARAM may be used to declare a void function argument; */
/* for example, */
/* */
/* int foo(NO_PARAM) { ... } */
/* NO_PARAM may be used in function declarations, in function */
/* definitions, and in function prototypes. */
/* ------------------------------------------------------------ */
/* "V_OBJ *" translates into the appropriate void-pointer data */
/* type; for example, */
/* */
/* V_OBJ *malloc (argp1 (u_int)); */
/* ------------------------------------------------------------ */
/* V_CAST translates into a "void" typecast; for example, */
/* */
/* char *strcpy (argp2(char *,char *)); */
/* V_CAST strcpy (s,t); */
/* ------------------------------------------------------------ */
/* if "void" is not supported */
#ifdef NO_VOID /* "void" type is not supported */
#define NO_PARAM /* void parameter type (empty) */
#define V_CAST /* void typecast (no effect) */
#define V_FUNC /* void function definition */
#define V_OBJ char /* void pointer object */
#define V_PROTO extern /* void function declaration */
#endif /* endif "void not supported" */
/* ------------------------------------------------------------ */
/* if "void" is supported */
#ifndef NO_VOID /* "void" type is supported */
#ifdef NO_PROTO /* prototypes are not supported */
#define NO_PARAM /* void parameter type (empty) */
#else /* prototypes are supported */
#define NO_PARAM void /* void parameter type */
#endif /* endif NO_PARAM */
#endif /* endif "void is supported" */
#ifndef NO_VOID /* "void" type is supported */
#define V_CAST (void) /* void typecast */
#define V_FUNC void /* void function definition */
#define V_OBJ void /* void pointer object */
#define V_PROTO void /* void function declaration */
#endif /* endif "void is supported" */
/* ------------------------------------------------------------ */
/* ANSI prototype setup */
/* ------------------------------------------------------------ */
/* The following "argp#(...)" macros may be used in ANSI */
/* function prototypes. "#" should be replaced with the number */
/* of function arguments; e.g.: */
/* */
/* V_OBJ *malloc (argp1(u_int)); */
/* char *strcpy (argp2(char *,char *)); */
/* The "argp#(...)" macros discard their arguments on systems */
/* which do not support ANSI prototypes. */
/* The "ellipse" construct "..." counts as one argument. */
/* ------------------------------------------------------------ */
#ifdef NO_PROTO
#define argp0()
#define argp1(a)
#define argp2(a,b)
#define argp3(a,b,c)
#define argp4(a,b,c,d)
#define argp5(a,b,c,d,e)
#define argp6(a,b,c,d,e,f)
#define argp7(a,b,c,d,e,f,g)
#define argp8(a,b,c,d,e,f,g,h)
#define argp9(a,b,c,d,e,f,g,h,i)
#else
#define argp0() NO_PARAM
#define argp1(a) a
#define argp2(a,b) a,b
#define argp3(a,b,c) a,b,c
#define argp4(a,b,c,d) a,b,c,d
#define argp5(a,b,c,d,e) a,b,c,d,e
#define argp6(a,b,c,d,e,f) a,b,c,d,e,f
#define argp7(a,b,c,d,e,f,g) a,b,c,d,e,f,g
#define argp8(a,b,c,d,e,f,g,h) a,b,c,d,e,f,g,h
#define argp9(a,b,c,d,e,f,g,h,i) a,b,c,d,e,f,g,h,i
#endif
/* ------------------------------------------------------------ */
/* null pointers of various types */
/* ------------------------------------------------------------ */
/* Note: NULLXP is a null function pointer. */
#ifndef NULLXP
#define NULL_PTR ((void *) ZERO)
#define NULLCP ((char *) ZERO)
#define NULLFP ((FILE *) ZERO)
#define NULLVP ((V_OBJ *) ZERO)
#define NULLXP ((int (*)()) ZERO)
#endif // Endif NULLXP
/* ------------------------------------------------------------ */
/* resolve global variables */
/* ------------------------------------------------------------ */
#ifdef RES_UX3 /* resolve external variables? */
#define UX3_EXT /* yes */
#else /* no */
#define UX3_EXT extern /* variables are externals */
#endif
#ifdef VMS /* VMS host */
#undef UX3_EXT
#ifdef RES_UX3 /* resolve externals? */
#define UX3_EXT globaldef
#else /* don't resolve externals */
#define UX3_EXT globalref
#endif /* endif RES_UX3 */
#endif /* endif VMS */
/* ------------------------------------------------------------ */
/* wrap it up */
/* ------------------------------------------------------------ */
#endif // Endif _X3BASIC_H

View File

@ -13,10 +13,7 @@
#ifndef _X3MEM_H /* skip this file if loaded */
#define _X3MEM_H 1 /* flag this file */
#include <stdio.h>
#include <stdlib.h>
#include "x3basic.h"
#include "deps.h"
#include "eprintf.h"
/* ------------------------------------------------------------ */

View File

@ -7,7 +7,11 @@
#define MY_GLOBAL
#define RES_UX3 1 /* resolve UX3 global variables */
#include "inc/deps.h"
#include "inc/eprintf.h"
#include "inc/x3mem.h"
#include "inc/util.h"
#include "inc/lexer.h"
#include "inc/pipe.h"

View File

@ -1,4 +1,5 @@
#include "inc/deps.h"
#include "inc/util.h"
#include "inc/tar.h"
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
@ -341,14 +342,14 @@ int tar_update (const int fd,
{
if (st.st_mtime > oct2uint(old -> mtime, 11))
{
strncpy(newer[count++], files[i], strlen(files[i]));
strcpy(newer[count++], files[i]);
V_PRINT(stdout, "%s", files[i]);
}
}
// if there is no older version, just add it
else
{
strncpy(newer[count++], files[i], strlen(files[i]));
strcpy(newer[count++], files[i]);
V_PRINT(stdout, "%s", files[i]);
}
}
@ -684,8 +685,8 @@ int format_tar_data(struct tar_t * entry, const char * filename, const char verb
// start putting in new data (all fields are NULL terminated ASCII strings)
memset(entry, 0, sizeof(struct tar_t));
strncpy(entry -> original_name, filename, 100);
strncpy(entry -> name, filename + move, 100);
strcpy(entry -> original_name, filename);
strcpy(entry -> name, filename + move);
snprintf(entry -> mode, sizeof(entry -> mode), "%07o", st.st_mode & 0777);
snprintf(entry -> uid, sizeof(entry -> uid), "%07o", st.st_uid);
snprintf(entry -> gid, sizeof(entry -> gid), "%07o", st.st_gid);
@ -747,7 +748,14 @@ int format_tar_data(struct tar_t * entry, const char * filename, const char verb
V_PRINT(stderr, "Warning: Unable to get username of uid %u for entry '%s': %s", st.st_uid, filename, strerror(err));
}
strncpy(entry -> owner, buffer, sizeof(entry -> owner) - 1);
if(sizeof(entry -> owner) < 4096)
{
strcpy(entry -> owner, buffer);
}
else
{
syn_warn("ss:warn:tar, failed to get username entry...");
}
// get group name
struct group * grp = getgrgid(st.st_gid);
@ -871,7 +879,7 @@ int extract_entry(const int fd, struct tar_t * entry, const char verbosity){
}
char * path = qcalloc (QM_TAR, len + 1, sizeof(char));
strncpy(path, entry -> name, len);
strcpy(path, entry -> name);
// remove file from path
while (--len && (path[len] != '/'));
@ -1196,7 +1204,7 @@ int recursive_mkdir(const char * dir, const unsigned int mode){
}
char * path = qcalloc (QM_TAR, len + 1, sizeof(char));
strncpy(path, dir, len);
strcpy(path, dir);
// remove last '/'
if (path[len - 1] == '/'){

View File

@ -1,18 +0,0 @@
/* ------------------------------------------------------------ */
/* file information */
/* ------------------------------------------------------------ */
// Filename: x3basic.c
// Purpose: Resolve UX3 global variables
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2021.
/* ------------------------------------------------------------ */
/* header files */
/* ------------------------------------------------------------ */
#define RES_UX3 1 /* resolve UX3 global variables */
#include "inc/x3basic.h"
#include "inc/eprintf.h"
#include "inc/x3mem.h"
#include "inc/tar.h"