ARES-SDK/ARES/application/type.lsl

88 lines
2.9 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/* =========================================================================
*
* Nanite Systems Advanced Research Encapsulation System
*
* Copyright (c) 20222024 Nanite Systems Corporation
*
* =========================================================================
*
* type Example Program
*
* This program is covered under the terms of the ARES Software Copyright
* License, Section 3 (ASCL-iii). It may be redistributed or used as the
* basis of commercial, closed-source products so long as steps are taken
* to ensure proper attribution as defined in the text of the license.
*
* To see the full text of the ASCL, type 'help license' on any standard
* ARES distribution, or visit http://nanite-systems.com/ASCL for the
* current version.
*
* DISCLAIMER
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS
* IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
* DAMAGES HOWEVER CAUSED ON ANY THEORY OF LIABILITY ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* =========================================================================
*
*/
#include <ARES/a>
#define CLIENT_VERSION "1.1.1"
#define CLIENT_VERSION_TAGS "release"
#define FILE_STEP_SIZE 4
#include <ARES/api/file.h.lsl>
key file_q;
main(integer src, integer n, string m, key outs, key ins, key user) {
if(n == SIGNAL_INVOKE) {
list argv = split(m, " ");
integer argc = count(argv);
if(argc == 1) {
print(outs, user, "Syntax: " + PROGRAM_NAME + " <filename>");
} else {
string file_name = gets(argv, 1);
file_q = fopen(outs, ins, user, file_name);
}
} else if(n == SIGNAL_NOTIFY) {
if(m == PROGRAM_NAME + " file") {
if(ins == file_q) {
user = getjs(tasks_queue, [file_q, FILE_USER]);
outs = getjs(tasks_queue, [file_q, FILE_OUTS]);
string fn = getjs(tasks_queue, [file_q, FILE_NAME]);
string unit = getjs(tasks_queue, [file_q, FILE_UNIT]);
string result = fread(file_q);
if(result == JSON_FALSE) {
print(user, user, "[" + PROGRAM_NAME + "] No file: " + fn);
} else if(result != JSON_TRUE) {
if(unit == "l")
result = llStringTrim(result, STRING_TRIM_TAIL);
print(outs, user, result);
// llSleep(0.1);
}
} else {
echo("[" + PROGRAM_NAME + "] file data offered via unexpected pipe: " + (string)ins);
}
}
} else if(n == SIGNAL_INIT) {
// print(outs, user, "[" + PROGRAM_NAME + "] init event; nothing to do");
} else if(n == SIGNAL_UNKNOWN_SCRIPT) {
echo("[" + PROGRAM_NAME + "] failed to run '" + m + "' (kernel could not find the program specified)");
} else {
echo("[" + PROGRAM_NAME + "] unimplemented signal " + (string)n + ": " + m);
}
}
#include <ARES/program>