Push to V0.7.1
This commit is contained in:
parent
83a56a9f18
commit
3435d0a48e
6
Makefile
6
Makefile
@ -1,14 +1,14 @@
|
||||
# SlideScript makefile
|
||||
# (C) Copyright 2014-2021 Chris Dorman, some rights reserved (GPLv2)
|
||||
# (C) Copyright 2014-2022 Chris Dorman, some rights reserved (GPLv2)
|
||||
# Some changes and tweaks from Menchers
|
||||
|
||||
VERSION = \"0.7.0\"
|
||||
VERSION = \"0.7.1\"
|
||||
VERSION_EXTRA = \"$(EXTRA)\"
|
||||
|
||||
PREFIX ?= /usr
|
||||
|
||||
#CC ?= musl-gcc
|
||||
CC ?= gcc
|
||||
CC ?= gcc-9
|
||||
#CC ?= tcc
|
||||
#CC ?= musl-tcc
|
||||
CFLAGS += -O3 -g -Wall -Wextra
|
||||
|
@ -1,8 +1,8 @@
|
||||
# SlideScript makefile
|
||||
# (C) Copyright 2014-2021 Chris Dorman, some rights reserved (GPLv2)
|
||||
# (C) Copyright 2014-2022 Chris Dorman, some rights reserved (GPLv2)
|
||||
# Some changes and tweaks from Menchers
|
||||
|
||||
VERSION = \"0.6.0\"
|
||||
VERSION = \"0.7.1\"
|
||||
VERSION_EXTRA = \"$(EXTRA)\"
|
||||
|
||||
PREFIX ?= /usr
|
||||
@ -16,11 +16,10 @@ CPPFLAGS += -DVERSION=$(VERSION) -D_FORTIFY_SOURCE=2
|
||||
LDFLAGS += -lc -L/planck/lib/tcc -L/planck/lib -ltcc1 -dynamic-linker /planck/lib/libc.so /planck/lib/crti.o /planck/lib/crt1.o /planck/lib/crtn.o -nostdlib
|
||||
BIN ?= slidescript
|
||||
|
||||
SRCS=$(wildcard src/*.c)
|
||||
SRCS=$(wildcard src/*.c) $(wildcard src/lz78/*.c)
|
||||
|
||||
OBJECTS=$(SRCS:%.c=%.o)
|
||||
|
||||
|
||||
all: main
|
||||
|
||||
fresh: clean all
|
||||
|
@ -151,6 +151,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.7.1
|
||||
* Removed tar sources from SlideScript, does it need to create tar packages. (You can use system utils)
|
||||
* Reworked compress / decompress for single file operations. Great for resources FOR slidescript (assets)
|
||||
* Working on the lexer engine for line parsing and cleaner syntax.
|
||||
|
||||
* V0.7.0
|
||||
* Ditched old LZ77 example code, and went with a more polished LZ78 ()
|
||||
* Converted dynamic memory management layer into LZ78 engine and tar code.
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// Filename: eprintf.c
|
||||
// Purpose: TTY and error-message routines
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2021.
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2022.
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* header files */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
@ -8,7 +8,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
//#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
@ -81,26 +81,26 @@
|
||||
|
||||
// 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>\" | unset \"<variable>\"\n" \
|
||||
#define FUNCTION_HELP "-[Main Functions]-\n Need function information? Use: help <function> \n list:\n" \
|
||||
"print, " \
|
||||
"sleep, " \
|
||||
"encode, " \
|
||||
"decode, " \
|
||||
"compress, " \
|
||||
"decompress, " \
|
||||
"calc, " \
|
||||
"move, " \
|
||||
"chdir, " \
|
||||
"showdir, " \
|
||||
"showpath, " \
|
||||
"isdir, " \
|
||||
"isfile, " \
|
||||
"delete, " \
|
||||
"nethttp, " \
|
||||
"read, " \
|
||||
"write, " \
|
||||
"cat, " \
|
||||
"exec, unset \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" \
|
||||
@ -113,7 +113,7 @@
|
||||
"if(n): <true/false/1/0>; <function> -> Processes function if true or false\n"
|
||||
|
||||
// Purpose: UX3 basic definitions
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2021.
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2022.
|
||||
|
||||
#ifndef _X3BASIC_H /* skip this file if loaded */
|
||||
#define _X3BASIC_H 1 /* flag this file */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// Filename: eprintf.h
|
||||
// Purpose: TTY and error-message routines
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2021.
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2022.
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* header file setup */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
@ -9,5 +9,4 @@
|
||||
|
||||
UX3_EXT QLIST QM_SS [ONE]; // Dynamic-memory QLIST
|
||||
|
||||
|
||||
char *process_line(char *line);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -1,10 +1,10 @@
|
||||
// BUSYBOX MD5 code, repurposed for the function in SlideScript
|
||||
// Licensing and contributions to the BusyBox development team, changes
|
||||
// and cleanup done by Bob (OldCoder) Kiraly, 2021
|
||||
// and cleanup done by Bob (OldCoder) Kiraly, 2022
|
||||
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -1,10 +1,8 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
||||
#define TMPBUF_LEN 2048
|
||||
|
||||
char *ss_search(const char *filename, FILE *fd, char *pat);
|
||||
|
164
src/inc/tar.h
164
src/inc/tar.h
@ -1,164 +0,0 @@
|
||||
/*
|
||||
tar.h
|
||||
tar data structure and accompanying functions
|
||||
|
||||
Copyright (c) 2015 Jason Lee
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE
|
||||
*/
|
||||
|
||||
#ifndef __TAR__
|
||||
#define __TAR__
|
||||
|
||||
#include "x3mem.h"
|
||||
|
||||
UX3_EXT QLIST QM_TAR [ONE]; // Dynamic-memory QLIST
|
||||
|
||||
|
||||
extern void tar_free_pool (void);
|
||||
|
||||
#ifndef _DEFAULT_SOURCE
|
||||
#define _DEFAULT_SOURCE
|
||||
#endif
|
||||
|
||||
#define DEFAULT_DIR_MODE S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH // 0755
|
||||
|
||||
#define BLOCKSIZE 512
|
||||
#define BLOCKING_FACTOR 20
|
||||
#define RECORDSIZE 10240
|
||||
|
||||
// file type values (1 octet)
|
||||
#define REGULAR 0
|
||||
#define NORMAL '0'
|
||||
#define HARDLINK '1'
|
||||
#define SYMLINK '2'
|
||||
#define CHAR '3'
|
||||
#define BLOCK '4'
|
||||
#define DIRECTORY '5'
|
||||
#define FIFO '6'
|
||||
#define CONTIGUOUS '7'
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
// tar entry metadata structure (singly-linked list)
|
||||
struct tar_t {
|
||||
char original_name[100]; // original filenme; only availible when writing into a tar
|
||||
unsigned int begin; // location of data in file (including metadata)
|
||||
union {
|
||||
union {
|
||||
// Pre-POSIX.1-1988 format
|
||||
struct {
|
||||
char name[100]; // file name
|
||||
char mode[8]; // permissions
|
||||
char uid[8]; // user id (octal)
|
||||
char gid[8]; // group id (octal)
|
||||
char size[12]; // size (octal)
|
||||
char mtime[12]; // modification time (octal)
|
||||
char check[8]; // sum of unsigned characters in block, with spaces in the check field while calculation is done (octal)
|
||||
char link; // link indicator
|
||||
char link_name[100]; // name of linked file
|
||||
};
|
||||
|
||||
// UStar format (POSIX IEEE P1003.1)
|
||||
struct {
|
||||
char old[156]; // first 156 octets of Pre-POSIX.1-1988 format
|
||||
char type; // file type
|
||||
char also_link_name[100]; // name of linked file
|
||||
char ustar[8]; // ustar\000
|
||||
char owner[32]; // user name (string)
|
||||
char group[32]; // group name (string)
|
||||
char major[8]; // device major number
|
||||
char minor[8]; // device minor number
|
||||
char prefix[155];
|
||||
};
|
||||
};
|
||||
|
||||
char block[512]; // raw memory (500 octets of actual data, padded to 1 block)
|
||||
};
|
||||
|
||||
struct tar_t * next;
|
||||
};
|
||||
|
||||
// core functions //////////////////////////////////////////////////////////////
|
||||
// read a tar file
|
||||
// archive should be address to null pointer
|
||||
int tar_read(const int fd, struct tar_t ** archive, const char verbosity);
|
||||
|
||||
// write to a tar file
|
||||
// if archive contains data, the new data will be appended to the back of the file (terminating blocks will be rewritten)
|
||||
int tar_write(const int fd, struct tar_t ** archive, const size_t filecount, const char * files[], const char verbosity);
|
||||
|
||||
// recursive freeing of entries
|
||||
void tar_free(struct tar_t * archive);
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// utilities ///////////////////////////////////////////////////////////////////
|
||||
// print contents of archive
|
||||
// verbosity should be greater than 0
|
||||
int tar_ls(FILE * f, struct tar_t * archive, const size_t filecount, const char * files[], const char verbosity);
|
||||
|
||||
// extracts files from an archive
|
||||
int tar_extract(const int fd, struct tar_t * archive, const size_t filecount, const char * files[], const char verbosity);
|
||||
|
||||
// update files in tar with provided list
|
||||
int tar_update(const int fd, struct tar_t ** archive, const size_t filecount, const char * files[], const char verbosity);
|
||||
|
||||
// remove entries from tar
|
||||
int tar_remove(const int fd, struct tar_t ** archive, const size_t filecount, const char * files[], const char verbosity);
|
||||
|
||||
// show files that are missing from the current directory
|
||||
int tar_diff(FILE * f, struct tar_t * archive, const char verbosity);
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// internal functions; generally don't call from outside ///////////////////////
|
||||
// print raw data with definitions (meant for debugging)
|
||||
int print_entry_metadata(FILE * f, struct tar_t * entry);
|
||||
|
||||
// print metadata of entire tar file
|
||||
int print_tar_metadata(FILE * f, struct tar_t * archive);
|
||||
|
||||
// check if file with original name/modified name exists
|
||||
struct tar_t * exists(struct tar_t * archive, const char * filename, const char ori);
|
||||
|
||||
// read file and construct metadata
|
||||
int format_tar_data(struct tar_t * entry, const char * filename, const char verbosity);
|
||||
|
||||
// calculate checksum (6 ASCII octet digits + NULL + space)
|
||||
unsigned int calculate_checksum(struct tar_t * entry);
|
||||
|
||||
// print single entry
|
||||
// verbosity should be greater than 0
|
||||
int ls_entry(FILE * f, struct tar_t * archive, const size_t filecount, const char * files[], const char verbosity);
|
||||
|
||||
// extracts a single entry
|
||||
// expects file descriptor offset to already be set to correct location
|
||||
int extract_entry(const int fd, struct tar_t * entry, const char verbosity);
|
||||
|
||||
// write entries to a tar file
|
||||
int write_entries(const int fd, struct tar_t ** archive, struct tar_t ** head, const size_t filecount, const char * files[], int * offset, const char verbosity);
|
||||
|
||||
// add ending data
|
||||
int write_end_data(const int fd, int size, const char verbosity);
|
||||
|
||||
// check if entry is a match for any of the given file names
|
||||
// returns index + 1 if match is found
|
||||
int check_match(struct tar_t * entry, const size_t filecount, const char * files[]);
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
@ -40,3 +40,4 @@ char *ss_concat(char *str1, char *str2);
|
||||
void parse_args(int argc, char** argv);
|
||||
char *ss_time();
|
||||
void gen_random_string(char *s, const int len);
|
||||
char *remove_extension(char *string);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// Filename: x3mem.h
|
||||
// Purpose: Memory management
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2021.
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2022.
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* header file setup */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
@ -8,7 +8,6 @@
|
||||
#include "inc/deps.h"
|
||||
#include "inc/inset.h"
|
||||
#include "inc/lexer.h"
|
||||
#include "inc/tar.h"
|
||||
#include "inc/vars.h"
|
||||
#include "inc/util.h"
|
||||
|
||||
|
132
src/lexer.c
132
src/lexer.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
@ -15,9 +15,7 @@
|
||||
#include "inc/network.h"
|
||||
#include "inc/search.h"
|
||||
#include "inc/inset.h"
|
||||
|
||||
// For slidescript compression algorithm
|
||||
#include "inc/tar.h"
|
||||
// For compression!
|
||||
#include "lz78/wrapper.h"
|
||||
|
||||
#define strtok_next(s) strtok_r (NULL, s, &strtok_save)
|
||||
@ -57,6 +55,15 @@ char *process_line (char *line)
|
||||
{
|
||||
x_warn(":ss:help:\n%s", FUNCTION_HELP);
|
||||
return NULL;
|
||||
|
||||
/* if(strncmp("read", tok_srch[5], 4) == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else if()
|
||||
{
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
// Lets add if and loop statements, make this
|
||||
@ -485,9 +492,8 @@ char *process_line (char *line)
|
||||
/* COMPRESSION AND DECOMPRESSION */
|
||||
else if (strncmp("decompress",tok_srch,10) == 0)
|
||||
{
|
||||
char *filename;
|
||||
struct tar_t *archive = NULL;
|
||||
int fd, lzret;
|
||||
char *filename, *decomp_filename;
|
||||
int lzret;
|
||||
wrapper *lzwrapper;
|
||||
int bsize = B_SIZE_DEFAULT;
|
||||
uint8_t w_mode = WRAPPER_MODE_DECOMPRESS;
|
||||
@ -502,17 +508,14 @@ char *process_line (char *line)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strtok_next ("\"")==NULL)
|
||||
if (strtok_next ("\"") == NULL)
|
||||
{
|
||||
x_warn("ss:warn:decompress syntax error, missing end quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
filename = parse_vars(tok_srch);
|
||||
|
||||
char filedecout[128];
|
||||
|
||||
sprintf(filedecout, "uncompressed.tar");
|
||||
decomp_filename = remove_extension(parse_vars(tok_srch));
|
||||
|
||||
if (bsize <= 0) {
|
||||
x_warn("ss:warn:compress, default buffer not set?");
|
||||
@ -527,7 +530,7 @@ char *process_line (char *line)
|
||||
}
|
||||
|
||||
/* Executes the wrapper function */
|
||||
lzret = wrapper_exec(lzwrapper, filename, filedecout);
|
||||
lzret = wrapper_exec(lzwrapper, filename, decomp_filename);
|
||||
|
||||
if (lzret != WRAPPER_SUCCESS)
|
||||
{
|
||||
@ -536,34 +539,7 @@ char *process_line (char *line)
|
||||
}
|
||||
|
||||
/* Destroyes the wrapper instance */
|
||||
//wrapper_destroy(lzwrapper);
|
||||
|
||||
// open existing file
|
||||
if ((fd = open(filedecout, O_RDWR)) < 0) {
|
||||
x_warn("ss:warn:decompress, failed to tar open archive");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// read in data
|
||||
if (tar_read(fd, &archive, '1') < 0) {
|
||||
close(fd);
|
||||
x_warn("ss:warn:decompress, failed to read archive");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// perform operation
|
||||
if (tar_extract(fd, archive, 0, NULL, '1') < 0) { // extract entries
|
||||
x_warn("ss:warn:decompress, error occured");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
usleep(50);
|
||||
|
||||
tar_free(archive);
|
||||
|
||||
close(fd); // don't bother checking for fd < 0
|
||||
|
||||
remove(filedecout);
|
||||
wrapper_destroy(lzwrapper);
|
||||
|
||||
return retbuf;
|
||||
|
||||
@ -572,9 +548,9 @@ char *process_line (char *line)
|
||||
/* Compression function of tar */
|
||||
else if (strncmp("compress",tok_srch,8) == 0)
|
||||
{
|
||||
char filename[MAX_FILENAME_LEN+1]; // Files to be added into the archive
|
||||
struct tar_t *archive = NULL;
|
||||
int fd, lzret;
|
||||
char filename[MAX_FILENAME_LEN+1];
|
||||
char cfilename[MAX_FILENAME_LEN+4];
|
||||
int lzret;
|
||||
wrapper *lzwrapper;
|
||||
int bsize = B_SIZE_DEFAULT;
|
||||
uint8_t w_mode = WRAPPER_MODE_COMPRESS;
|
||||
@ -582,7 +558,6 @@ char *process_line (char *line)
|
||||
|
||||
retbuf = qmalloc(QM_SS, 8129);
|
||||
|
||||
tar_free_pool();
|
||||
tok_srch = strtok_next ("\"");
|
||||
if (tok_srch == NULL)
|
||||
{
|
||||
@ -590,16 +565,11 @@ char *process_line (char *line)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||
{
|
||||
x_warn("ss:warn:compress syntax error, missing archive name...");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Save tarball filename
|
||||
if (strlen(parse_vars(tok_srch)) < MAX_FILENAME_LEN)
|
||||
if (strlen(parse_vars(tok_srch)+3) < MAX_FILENAME_LEN)
|
||||
{
|
||||
sprintf(filename, "%s", parse_vars(tok_srch));
|
||||
sprintf(cfilename, "%s.lz", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -607,11 +577,6 @@ char *process_line (char *line)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR)) == -1){
|
||||
x_warn("ss:warn:compress, failed to open new archive");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tok_srch = strtok_next ("\"");
|
||||
if (tok_srch == NULL)
|
||||
{
|
||||
@ -619,52 +584,6 @@ char *process_line (char *line)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tok_srch = strtok_next ("\"");
|
||||
if (tok_srch == NULL)
|
||||
{
|
||||
x_warn("ss:warn:compress syntax error, missing quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||
{
|
||||
x_warn("ss:warn:compress, missing file path (what are we gonna compress?)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strtok_next ("\"")==NULL)
|
||||
{
|
||||
x_warn("ss:warn:compress syntax error, missing end quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int argc = 0;
|
||||
char *argv [MAX_FILES];
|
||||
char *alt_save;
|
||||
char *p2 = strtok_r (tok_srch, " ", &alt_save);
|
||||
|
||||
while (p2 && argc < MAX_FILES-1)
|
||||
{
|
||||
argv[argc++] = p2;
|
||||
p2 = strtok_r (NULL, " ", &alt_save);
|
||||
}
|
||||
|
||||
argv[argc] = 0;
|
||||
const char **tarin = (const char **) &argv[0];
|
||||
|
||||
if (tar_write(fd, &archive, argc, tarin, '1') < 0) {
|
||||
x_warn("ss:warn:compress, failed to create tar archive");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tar_free(archive);
|
||||
|
||||
close(fd); // don't bother checking for fd < 0
|
||||
|
||||
char file_comp[MAX_FILENAME_LEN+9];
|
||||
|
||||
sprintf(file_comp, "%s.tar.ss", filename);
|
||||
|
||||
if (bsize <= 0) {
|
||||
x_warn("ss:warn:compress, default buffer not set?");
|
||||
return NULL;
|
||||
@ -678,7 +597,7 @@ char *process_line (char *line)
|
||||
}
|
||||
|
||||
/* Executes the wrapper function */
|
||||
lzret = wrapper_exec(lzwrapper, filename, file_comp);
|
||||
lzret = wrapper_exec(lzwrapper, filename, cfilename);
|
||||
|
||||
if (lzret != WRAPPER_SUCCESS)
|
||||
{
|
||||
@ -687,15 +606,12 @@ char *process_line (char *line)
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(retbuf, "Compressed -> %s.tar.ss", filename);
|
||||
sprintf(retbuf, "Compressed -> %s.lz", filename);
|
||||
}
|
||||
|
||||
/* Destroyes the wrapper instance */
|
||||
wrapper_destroy(lzwrapper);
|
||||
|
||||
// Remove the decompressed version for sanity check
|
||||
remove(filename);
|
||||
|
||||
return retbuf;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
@ -14,7 +14,6 @@
|
||||
#include "inc/util.h"
|
||||
#include "inc/lexer.h"
|
||||
#include "inc/pipe.h"
|
||||
#include "inc/tar.h"
|
||||
#include "inc/inset.h"
|
||||
#include "inc/vars.h"
|
||||
|
||||
@ -66,7 +65,6 @@ int main(int argc, char **argv)
|
||||
pipechk = get_cmd_count();
|
||||
|
||||
return_dat = process_line(spipe[0].command);
|
||||
tar_free_pool();
|
||||
|
||||
// Blank line, getting up outta here.
|
||||
if(return_dat == NULL) continue;
|
||||
@ -79,7 +77,6 @@ int main(int argc, char **argv)
|
||||
set_var(varc, "PIPE", return_dat);
|
||||
// Process functions based on previous pipe return
|
||||
return_dat = process_line(spipe[ii].command);
|
||||
tar_free_pool();
|
||||
|
||||
set_var(varc, "\0", "\0");
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -1,10 +1,10 @@
|
||||
// BUSYBOX MD5 code, repurposed for the function in SlideScript
|
||||
// Licensing and contributions to the BusyBox development team, changes
|
||||
// and cleanup done by Bob (OldCoder) Kiraly, 2021
|
||||
// and cleanup done by Bob (OldCoder) Kiraly, 2022
|
||||
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
@ -18,7 +18,6 @@ char *ss_search(const char *filename, FILE *fp, char *pat)
|
||||
char *s_buf = NULL;
|
||||
size_t size = 0;
|
||||
int ret;
|
||||
char tmpbuf[TMPBUF_LEN+1];
|
||||
int flags = REG_NOSUB; /* don't need where-matched info */
|
||||
|
||||
bzero(retbuf, MAX_SEARCH_LEN);
|
||||
@ -40,9 +39,10 @@ char *ss_search(const char *filename, FILE *fp, char *pat)
|
||||
{
|
||||
if(strlen(s_buf) < MAX_SEARCH_LEN)
|
||||
{
|
||||
char tmpbuf[strlen(s_buf) + strlen(filename) + 7];
|
||||
sprintf(tmpbuf, "ss: %s: %s", filename, s_buf);
|
||||
strcat(retbuf, tmpbuf);
|
||||
bzero(tmpbuf, TMPBUF_LEN);
|
||||
bzero(tmpbuf, strlen(tmpbuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
16
src/util.c
16
src/util.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
@ -109,7 +109,7 @@ void parse_args(int argc, char** argv)
|
||||
/* -v flag given, show version */
|
||||
else if(argc == 2 && strncmp("-v", argv[1], 2) == 0)
|
||||
{
|
||||
printf("SlideScript %s, Chris Dorman (cddo@riseup.net), 2021\n", VERSION);
|
||||
printf("SlideScript %s, Chris Dorman (cddo@riseup.net), 2022\n", VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@ -133,3 +133,15 @@ void gen_random_string(char *s, const int len) {
|
||||
|
||||
s[len] = 0;
|
||||
}
|
||||
|
||||
char *remove_extension(char *string) {
|
||||
char *ret_string;
|
||||
char *lastExt;
|
||||
if (string == NULL) return (char *)NULL;
|
||||
if ((ret_string = malloc (strlen (string) + 1)) == NULL) return (char *)NULL;
|
||||
strcpy (ret_string, string);
|
||||
lastExt = strrchr (ret_string, '.');
|
||||
if (lastExt != NULL)
|
||||
*lastExt = '\0';
|
||||
return ret_string;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
SlideScript - minimalistic top-down scripting language.
|
||||
(C) Copyright 2014-2021 Chris Dorman - some rights reserved (GPLv2)
|
||||
(C) Copyright 2014-2022 Chris Dorman - some rights reserved (GPLv2)
|
||||
View README file supplied with this software for more details
|
||||
*/
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// Filename: x3mem.c
|
||||
// Purpose: Memory management
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2021.
|
||||
// License: MIT/X. (c) OldCoder (Robert Kiraly) 1987-2022.
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* header files */
|
||||
|
Loading…
x
Reference in New Issue
Block a user