Skip to content
Snippets Groups Projects
  1. Jan 05, 2025
  2. Dec 02, 2024
  3. Dec 01, 2024
    • Rob Swindell's avatar
      Simplify the getnode.cpp API - use bool returns, default paramaeter value · 62ed3d3a
      Rob Swindell authored
      getnodedat() now performs a non-locked read by default.
      
      Perform more checks of getnodedat() return value before calling putnodedat()
      to avoid unintentionally zeroing out node.dab records.
      
      Add/use unlocknodedat() method for unlocking a node.dab record without
      writing.
      
      Note: The userdat.c getnodedat() and putnodedat() still return int (i.e. 0 on
      success), so that can be confusing.
      62ed3d3a
  4. Oct 23, 2024
    • Rob Swindell's avatar
      Rename sbbs_t::ansi_getlines() to ansi_getdims(), add sbbs_t::getdimensions() · e4cdd4ac
      Rob Swindell authored
      Add JS console.ansi_getdims()
      
      Use sbbs_t::getdimensions() or JS console.getdimensions() to move user
      cols/rows values to run-time console values (querying ANSI terminal if
      appropriate/supported).
      
      JS console.pushxy(), popxy(), and gotoxy() all return Boolean now.
      
      sbbs_t::getdimensions() and its JS wrapper is now the proper way to propagate
      user's cols/rows settings to the run-time console values. This was done
      (post-login) only via use of the TERMROWS and TERMCOLS @-codes in
      user_settings.js. Weird.
      e4cdd4ac
  5. Aug 09, 2024
  6. Aug 08, 2024
    • Rob Swindell's avatar
      Prevent NULL pointer dereference when 'null' object passed to JS functions · 54523145
      Rob Swindell authored
      As was discovered as part of investigation into issue #769, a JavaScript
      could crash SBBS (cause a segfault) due to a NULL pointer dereference when
      the script passes 'null' to native JS functions where an object is expected.
      
      The issue raised was with console.gotoxy(), but it turns out that *many*
      Synchronet native JS functions would call JSVAL_TO_OBJECT() and then, without
      checking for NULL/nullptr, pass its return value to JS api functions such as
      JS_GetPrivate, JS_GetProperty, JS_GetClass, JS_ObjectIsFunction,
      JS_IsArrayObject, JS_GetArrayLength, JS_DefineProperty, JS_Enumerate, etc.
      All of these JS API functions dereference the passed object pointer without
      NULL/nullptr checking.
      
      The fix here is to either call JSVAL_IS_NULL() or JSVAL_NULL_OR_VOID() and
      if true, not call JSVAL_TO_OBJECT() and/or check the return value for the NULL
      value before using as an argument to any other JS API functions.
      54523145
  7. Apr 06, 2024
    • Rob Swindell's avatar
      Save/restore js.scope property value in sbbs_t::js_execfile() · c3b47aca
      Rob Swindell authored
      This solves the problem of exit() values (e.g. non-zero return codes) not
      getting propagated to callers when nest-called (e.g. via bbs.exec()).
      
      I think it was kk4qbn that pointed this out via IRC: an exit(1) call from
      prextrn.js did not stop the external program from running (as it should, for
      any non-zero exit code). This only happened when the prextrn.js called another
      JS script (e.g. via bbs.exec() or as was the case here, indirectly via "EXEC"
      @-code in the YesNoBar text.dat string (which executed yesnobar.js). This
      nested JS script invocation via sbbs_t::js_execfile() would clobber the stored
      js.scope property value (where the "exit_code" property is written).
      
      Script invoked in their own context (e.g. via js.exec()) wouldn't have this
      issue in the first place.
      c3b47aca
  8. Mar 30, 2024
    • Rob Swindell's avatar
      Save and restore the js.exec_path, exec_dir, and exec_file properties · 9013f866
      Rob Swindell authored
      When invoking a nested JS script, these properties of the "js" object would
      be overwritten and not restored, as discovered/reported by Nightfox when his
      trivial game script would indirectly execute yesnobar.js, his subsequent use
      of js.exec_dir would point to the wrong location (the "exec" directory, parent
      of yesnobar.js, and not the direcctory where his game script was located).
      The exec_path and exec_file properties had the same problem as demonstrated
      by a simple test.js placed in (and executed from) a directory other than the
      "exec" dir:
      	function f() {
              print("js.exec_path = " + js.exec_path);
              print("js.exec_dir = " + js.exec_dir);
              print("Js.exec_file = " + js.exec_file);
      	}
      	f();
      	console.yesno("test");
      	f();
      
      This would only trigger the problem when executed from the BBS and whebn the
      YesNoQuestion text.dat string invokes the "yesnobar" module via EXEC @-code and
      yesnobar.js exists (in exec or mods dir), superceding yesnobar.bin which does
      not trigger this issue (not a JavaScript mod).
      9013f866
  9. Dec 31, 2023
    • Rob Swindell's avatar
      Don't clear the console-abort flag upon return from executing a JS module · cdfcb5f3
      Rob Swindell authored
      This completes the revert of commit c22063f9 from (Jun-2-2016). The Baja
      part of that commit was reverted in commit 932fae30 (Nov-15-2016). This
      behavior has proven to be surprising and annoying for JS mod developers
      (e.g. the yesnobar.js and Nightfox's file searcher/scanner).
      
      If we still need clearing of abort status after running JS "externals",
      that should probably be done in exec_xtrn(), not here.
      cdfcb5f3
  10. Nov 11, 2023
  11. Sep 15, 2023
  12. Sep 10, 2023
  13. Jun 09, 2023
    • Rob Swindell's avatar
      <Deuce> ... billion-and-one result of comparison of constant 100000 warnings. · 2b087b8b
      Rob Swindell authored
      So Clang-FreeBSD was warning (in compiles of scfg/scfg*.c by Deuce):
      result of comparison of constant 100000 with expression of type 'uint16_t'
      (aka 'unsigned short') is always true
      
      Why? Cause a uint16_t's max value is 65535 (less than 100000). Sure we could
      have just lowered the UIFC max number of config items to 65535, but that would
      have been too easy. And why are these compared-with values of type uint16_t to
      begin with? Because most ctrl/*.cnf lists (of configuration items) were
      limited to 65535 entries cause ... 16-bit DOS, historically. Now that *.cnf
      files aren't used, we could just increase these scfg_t.*_total type sizes from
      16 to 32-bits, yeah? The result is this commit.
      
      I went to (signed) int so we could still keep -1 as the special illegal
      sub/dir num value (e.g. INVALID_SUB, which is sometimes used to indicate the
      email message base). Theoretically, 2 billion configuration items could be
      supported in these lists, but SCFG will limit you to 100000 anyway. So there's
      a whole lot of s/uint/int in this commit.
      
      I'd be very surprised if this doesn't result in some new GCC/Clang warnings,
      but at least the old "comparison of constant 100000" warnings are now gone!
      2b087b8b
  14. Mar 11, 2023
  15. Feb 26, 2023
  16. Feb 19, 2023
    • Rob Swindell's avatar
      Eliminate old lread/lwrite/lkbrd wrapper macros · 3db498f1
      Rob Swindell authored
      Vestiges of MS-DOS and 16-bit ints and local keyboard access.
      3db498f1
    • Rob Swindell's avatar
      The great 'long int' purge of 2023 part 2 · 0932bcda
      Rob Swindell authored
      Mostly [s]printf format fixups
      0932bcda
    • Rob Swindell's avatar
      The great 'long int' purge of 2023 part 1 · 59d8974c
      Rob Swindell authored
      At one time, Synchronet was a 16-bit DOS project, plagued by the 16-bit [u]int, so long's were used everywhere > 16-bits were known to be needed/wanted (This is before the days of the standard sized types from stdint.h), and they've persisted.
      
      But '[u]long int' is 64-bits on *nix 64-bit builds, 32-bits everywhere else (even 64-bit Windows builds if/when we ever get around to that), so this could lead to insidious bugs that would only show up on one flavor or the other. Since [u]int is 32-bits on everything we currently support, we'll use that instead of [u]long.
      
      This "part 1" because I'm sure there's going to be warnings and errors from the GCC/Clang builds as a result, which I'll get to next.
      59d8974c
    • Rob Swindell's avatar
      Removed about 1500 bytes of unused scfg_t fields (cruft) · af4d7d1f
      Rob Swindell authored
      modem init strings, alt file paths, PostLink name/number, node-specific command-lines, etc., many of these haven't been used since SBBS v2.
      af4d7d1f
  17. Feb 17, 2023
    • Rob Swindell's avatar
      Move sysop notification settings from node to system level · e2a01274
      Rob Swindell authored
      The validation user (required new user feedback user number) and error notification/level settings don't make sense under node settings in today's world where all nodes typically run on the same system and serve the same BBS.
      
      Moved from SCFG->Nodes->... Advanced Options to (new sub-menu) SCFG->System->Notifications. Likewise, these 3 settings (valuser, erruser, errlevel) were moved from node*/node.ini to ctrl/main.ini.
      
      If you're already running v3.20a, then you'll want to make sure you set these in SCFG->System->Notifications how you prefer them as the migration (now handled in upgrade_to_v320.js) won't have been done for you automatically. The default is no-new-user-feedback required and no-error-notification user set.
      
      Added a prompt to the SCFG setup wizard to prompt for this setting since it still is a FAQ.
      
      Other cosmetic changes to SCFG help and setup wizard.
      e2a01274
  18. Feb 12, 2023
  19. Oct 20, 2022
  20. Oct 18, 2022
    • Rob Swindell's avatar
      Full read/write support of new user.tab userbase file · 8a22b246
      Rob Swindell authored
      Also resolved some 32 vs 64-bit 'long' issues/ambiguities that have long-remained. :-)
      
      This commit also removes logon.lst file support.
      
      There's a TODO block remaining in js_user.c for setting portions of a user's birthdate (e.g. just the year or month or day).
      8a22b246
  21. Apr 11, 2022
    • Rob Swindell's avatar
      Install OperationCallback for all executed JS scripts · d6d40bc4
      Rob Swindell authored
      JS doors with the "Use Shell or New Context" option enabled in SCFG and JS
      modules installed a global hot key handlers would not automatically terminate
      when the user disconnected (and js.auto_terminate was true, the default).
      I'm not sure why the operation callback was only installed when scope==NULL
      but always installing it fixes the issue with some global hot key modules
      and JS doors becoming "zombies" when a user disconnects while running them.
      d6d40bc4
  22. Mar 24, 2022
    • Rob Swindell's avatar
      Support user credits and transfer stats > 4GB in total · 2d4ec7b8
      Rob Swindell authored
      Credits and daily free credits are accurate to the byte up to (a maximum) of 18446744073709551615 (that's 18 Exbibytes - 1).
      
      User's upload and download byte stats are now similarly extended in maximum range, but the accuracy is only "to the byte" for values less than 10,000,000,000. Beyond that value, the accuracy declines, but is generally pretty damn accurate (to 4 decimal places beyond the nearest multiple of a power of 1024), so I don't expect that to be an issue. This method of storing upload/download byte stats allowed me to use the same 10-character user record fields in the user.dat file.
      
      As a side-effect of this enhancements:
      * User and file credit values are now expressed in multiples of powers of 1024 (e.g. 4.0G rather than 4,294,967,296).
      * Free credits per day per security level has now been extended from 32 to 64-bits (to accommodate values >= 4GB).
      * adjustuserrec() now longer takes the record length since we can easily determine that automatically and don't need more "sources of truth" that can be out-of-sync (e.g. the U_CDT field length going from 10 to 20 chars with this change).
      * setting the stage for locale-dependent thousands-separators (e.g. space instead of comma) - currently still hard-coded to comma
      * more/better support for files > 4GB in size (e.g. in the batch download queue)
      * user_t ulong fields changed to either uint32_t or uint64_t - I didn't realize how many long/ulong's remained in the code (which are sometmies 32-bit, sometimes 64-bit) - ugh
      * Steve's ultoac() function renamed to u32toac() and created a C++ wrapper that still uses the old name, for homage
      2d4ec7b8
  23. Apr 05, 2021
  24. Apr 04, 2021
    • Rob Swindell's avatar
      A poll() failure with EINTR does not mean a socket is closed. · 925e3b0a
      Rob Swindell authored
      This won't impact Synchronet as it has a separate signal handling
      thread, but we still need to behave properly for processes that
      don't.  I'm also saying that ENOMEM does not indicate a disconnection,
      though it may be better to pretend it was disconnected...
      925e3b0a
  25. Apr 02, 2021
    • Deucе's avatar
      Initial work on setTimeout() · 19289739
      Deucе authored
      This appears to work and the event handler *should* work on other
      event types already.
      
      Note, this is *nix-only due to the use of poll().  select() will
      need to be used for Windows to keep XP compatability.
      19289739
  26. Feb 18, 2021
  27. Jan 24, 2021
    • Rob Swindell's avatar
      JS module command-lines now supported quoted arguments (w/white-space) · fb2ad7dd
      Rob Swindell authored
      Example:
      Command-line: ?showargs   " a b c "d "e f"
      argc = 3
      argv[0] = ' a b c '
      argv[1] = 'd'
      argv[2] = 'e f'   
      
      This resolves a long-standing TODO comment.
      
      Also, fixed a problem where multiple spaces between the module name and the first argument would result in argv[0] being set to an empty string.
      fb2ad7dd
  28. Nov 26, 2020
  29. Nov 06, 2020
    • Rob Swindell's avatar
      Replace ctype.h function calls with new MSVC-safe XPDEV macros · ec20d959
      Rob Swindell authored
      I'm fed-up with MSVC assertions in ctype functions (e.g. isdigit, isprint, isspace, etc.) when called with out-of-range (e.g. negative) values.
      
      This problem only affects MSVC debug builds, but if you run them (like I do), these things are like little time bombs that can drive you crazy (knocking your board out of service).
      
      The new macros names are bit more descriptive as well.
      ec20d959
  30. Nov 04, 2020
    • Rob Swindell's avatar
      Always evaluate js.on_exit() installed expressions. · 48f244e7
      Rob Swindell authored
      I noticed that when executing an external JS with the new "Use Shell / New Context" option set to "Yes", that any expressions (strings) installed via js.on_exit() were not being executed upon exit from the script. These on-exit strings are important for restoring global state information (e.g. control key pass-through, console mode) to the original state before the JS mod made any changes.
      
      I'm not sure why the special treatment of "scope == NULL" is through-out this function. Going back to v3.16, it appears this was special treatment for JS mods invoked via global hot key event (when scope != NULL). When invoking an xtrn JS mod with the new Context option, the scope argument is not NULL, so this check was defeating the parsing of the "exit_code" and the evaluation of any js.on_exit() installed expressions for no apparent reason. I can't think why global hot key events should be excluded from this logic either.
      48f244e7
  31. Aug 30, 2020
    • Rob Swindell's avatar
      External program "use shell" option can be used to use a new JS context · 1decdc69
      Rob Swindell authored
      Rather than introduce yet-another-external-program/config flag to enable
      the "new JS run-time/context" per invocation of any particular JS command,
      I'm using the XTRN/EX_SH ("Use Shell") option as it had no function for
      JavaScript command-lines and the concept is similar.
      
      So if you want to invoke a JS external program/timed-event in its own
      "sandbox", enable the "Use Shell / New Context" option for that
      program/command in SCFG. There may be performance penalties when running
      JS mods in this way, but you get the benefit of isolating one JS module
      from all others, if/when necessary.
      1decdc69
    • Rob Swindell's avatar
      Previous commit fixed issue with JS_GC before JS_ENDREQUEST · 25625186
      Rob Swindell authored
      So revert the order back to the way it was in aa2bcd61
      (don't you love these git references?).
      
      Also, the previous fix for js_execfile() calls for global hot-key events also
      fixed the EX_JS_CX feature I was working on (js_execmodule)!
      25625186
    • Rob Swindell's avatar
      Fix JS global object corruption when invoking JS global hotkey handlers · cb5188bd
      Rob Swindell authored
      As reported by Ragnarok and The Lizard Master, invoking a JS global
      hot-key handler (e.g. hitting Ctrl-U or Ctrl-P with the privatemsg
      or nodelist modules installed as handlers) would lead to the global
      object being cleared/corrupted so other scripts would then fail to
      run correctly (e.g. Error: can't open sbbsdefs.js: No such file or directory)
      
      This probably explains the JS_GC/JS_ENDREQUEST change needed when
      the hotkey-specific JS runtime/context/scope was introduced last year.
      Should revisit that too.
  32. Aug 16, 2020
  33. Aug 01, 2020
    • rswindell's avatar
      An experimental external() mode flag that runs JS modules in their own... · b898eb73
      rswindell authored
      An experimental external() mode flag that runs JS modules in their own separate runtime and context - currently does not work (appears to corrupt the shared JS context). Not actually used currently.
      The reason I wanted to run a JS module (actually JS doorgame) in its own context was to get useful error messages (filenames and line numbers) when the module throws an exception. Currently, the error is just reported as occuring in xtrn_sec.js, which isn't helpful or correct.
      b898eb73
  34. May 08, 2020
    • rswindell's avatar
      More mouse hot spot stuff: · e821783a
      rswindell authored
      - User Defaults menu mousified
      - When all hot spots have scrolled off the screen, clear the hot spot list
      - Insert new hot spots in the front of the list so they will take precedence
        over any previously defined duplicate hot spots
      - Numeric hot spot commands end in a carriage-return
      - No auto-acceptence of numbers when there are keys in the keyboard buffer
      - Baja UNGETKEY function now inserts keys into the "front" of the keyboard
        buffer (next to be consumed)
      - Hot key @-code command text supports C-style escape sequences
        (allows encoding of ctrl chars, spaces, etc.)
      e821783a
Loading