LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Blogs > rainbowsally
User Name
Password

Notices


Rate this Entry

new.sfxz text-based archive creation utility, C version

Posted 05-20-2015 at 04:53 AM by rainbowsally

new.sfxz text-based archive creation utility, C version

Today's fantastic adventure in Computer Mad Science is the creation of a utility to create the 'sfxz' text-based archives, such as this one (see below). But for anyone not familiar with amazing, magical, and mystifying power of Computer Mad Science, there are some other interesting things going on here.

Feature:
  • A simpler, faster, more reliable sfzx sytem using the C slist variation.
  • 'new.codeblocks code=c' test with codeblocks ide output to compile the app.
  • Yet another slist demo.

First, about 'slist'. This variation is for straight C. The slist utility was intended to get the nifty pipes and files functionality of lowly bash into high falutin' binary apps.

Just dropping in? All that junk with files and pipes is awkward and time consuming to write longhand every time you want to capture the output from a shell command or read/write a text file. Even pasting snippets is big and ugly, hard to read.

Whether you agree or not, have you ever wished you could do simple stuff like this in C/C++?
Code:
a=$(ls)
or
Code:
b=$(<textfile.txt)
or
Code:
echo "$b" > textfile.txt
That's what we're talkin' about. You can. Check it out in the fileset in the sfxz archive below.

Now for what's up with this code thing down below.

This archive is the sources for creating new.sfxz which replaces the ugly and overly complicated script version of new.sfxz uploaded a while back. It doubles as the test for 'new.codeblocks' using the "code=c" option. Works great still. You can add files and update them automatically using 'new.codeblocks' even while editing the files. Pretty cool.

'Nuff said, let's just run this and see what it does.

file: lq-new-sfxz.sfxz
purpose: self extracting archive
Code:
# run this as 'sh lq-new-sfxz.sfxz' to extract the files

# This is the binary sfxz creator that created this file which can be
# used to make text based self extracting filesets.
#
# Here are the contents of the extracted sfxz
#
# |-- new.sfxz.cbp 	(codeblocks ide launcher)
# `-- src
#     |-- new.sfxz.c	(the brainz)
#     |-- objlist.c	(base for for slist)
#     |-- objlist.h	
#     |-- sfxz.c	(strings for output)
#     |-- slist.c	(bash-like utility for C/C++ strings <--> files)
#     |-- slist.h
#     |-- update-strings.exec	(help compiler)
#     |-- usage_str.dat		(help strings)
#     `-- usage_str.txt		(source for help strings)
# 
# This sfxz creates 'new.sfxz' using the codeblocks ide.  If you have 
# mc2, use the -fetch switch and grab a C template instead, if you like.
#
# new.codeblocks, mc2, and new.sfxz are all here (or linked here) at 
# linuxquestions.org.
#
# The Computer Mad Science Team.  :-)

cat << _eof | base64 -d > tmp.tar.xz
/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4Hf/F7xdADYcQaV5tVmg7ZFk7zoL+OOR4aJ8fX+LDKa+
jRcU62wOQtBm5YdDcOhejsfYQhMJBJNW0BVh8LMDoEKUInZlWiPJWl31F+uaDeIx2IWg/VxgsfQj
a0Wvdxy/flA52DgYGSnBhtdKD5KDpxV5aYIbCGZICHtpTodwJjPhPIY0FLRXwtbCafbiAL2OOk7E
jyxWVUPf5zTWKqBN0D15H9R/+zBfvMvsFXR4s9WwR0v437iTUXBTE6+Ypp4QSeh3ZxxhKkhha4qv
NqHo468fJArc2AwlUurVL14ELI0n2SC13qanJSJ6VZZ92pZ4oh5Wxro3YctOUA4cd7mfz4jNsMAT
9FegnGLBUl7+UiUjoyrTWdOV1CqBARX0oTolLUJHW3W1FV0MAWQjxr0SU57eC9FXNDwd0bKILQS5
juySLvrsqC3OKT10fOgWwFztbEIFkzAfbNe3PMRsrLeeuGawhBPNrzfOf7+Rsfkuhw1HtKhqZSQB
rds8zZzVU7canP3GoE1tTJ27JbQKWnij5UlZA8wlk/r5lFojzsXsjV1EmPtkXhnzCtYLF6BLOxuH
D4NVniso8U48seub5kw7cTPECRl/xbnNU68zQBJTeaS4N22KBFCkep7gb9DjpjrL12/QtK6hZ81s
8C8mX1jVePnRANGF1yBeZCxJFQRjfYhlY7I2lIx1vxg8Jjoqnije60TqYtzS3lrsMzEKf99/oVj2
sTlPUrnm+j8DTp2DAYdfdRhI12tO1wBJMQciCTrD2A5x1gk3WZy/i0FL5PLUFp424fNtVGkFkScF
LYYb5g7p1aUTx7KBlzJd9fqVzwDP8rWy3E0uAL8ARp2ahtY0L5ZzenReC60kOT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yn2J7/ebRgeT
mH7N9dJIATTrfSHsJJsZIl6s0JWRX0bLT+S+y5x++KUjnGqymlQkmsDSEmWW0oYRv/pwQvNQ5lfT
AJOzDzofTH7/f1ph+11HFAdI8lT+THjwPs/EYwioCVZoa6E4+IWZ2TGZoYPRfcvzB/zbyB7Mg+5V
nUE4PeYlDe44GuraSBce/2vqpnrpqRjqxXDqTreqocQwvn3y5sxyYOHrmJy+5okycxN1KVzWiJHG
nWXi1DhyN7YocwHAEooJSgD/Xm/jKe5MU/sgpb1GwRmy9h0k8qyznFf3Qzcdm0M69vczgP5cWJ+a
5TnPLCbn75OrCMu5qMSh4vHnNZkG7Y2mMLxXXJdwW6jNYuPbrZzxl59rd1RG7rnL+ywJXFvOmP2q
8LhUxIPwQcHnCHU5BYGRejQNCePEP+yJAPLBgp8csbcX4acEpB+3uRm9syWrMxM0eddCrjUvTQNL
NA9boq3DBnB2XHY9cgAM96bdWKEp1oRhCbrREAKR6beQaP3x49PH68eS/93OGaPOPEhuhS7G1YUZ
0S82H+d76DH9ZqXCJMpktLLU1B05pb7id+jkd4q75KarS2m4TJHWAWjgW++0fmKM7/rXBeQnr+XQ
W57U74JmudNBoQXAqmvmmsIhjF8Ppuzu/17sqNsZLOXOrwXx9ynCIWriaAFaEHG509EBBalQP7cY
826O8sSHuu+8dBybiQaLGVcW7OdrWh+6nerGsG1U/g6z6RleJkMsQnEhfj6lnGxf9Q2fn18s0sez
yCAIcRcZoY6BJSmTlAsn6kvHygX9stE1ax3qJNErXei6qVNnG0cn5nkY50XUB+eNwy2EiWBB4weR
tFHbarY3cAAA0YOOHL/Ft/MAAdgvgPABAOAGLz+xxGf7AgAAAAAEWVo=
_eof

tar xaf tmp.tar.xz
rm tmp.tar.xz
-The Computer Mad Science Team

:-)
Posted in Uncategorized
Views 1114 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 01:16 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration