PAVLOV(3)

๐Ÿ“ฆ version 0.9.7, in nixos 26.05

๐Ÿ’… PAVLOV(3) โœจ โ€” like, the whole manual page, bestie

okay so first things first: this is a page from the System Management Commands manual, and honestly? it's giving "tiny language, big main character energy". sit down, grab a strawberry ๐Ÿ“, let's go.


๐ŸŒธ NAME ๐ŸŒธ

pavlov โ€” Simple expect/response command langauge

(yes, "langauge". that's how it's spelled in the original and I refuse to gaslight the archive ๐Ÿ’…)


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <arpa2/pavlov.h>

int pavlov (
       int fdin, int fdout,
       char *progname, int argc, char *argv[] )
pavlov <arg>...

๐Ÿ’– DESCRIPTION ๐Ÿ’–

so the pavlov(3) function is almost like a normal main() program, but with a lil glow-up โœจ. instead of just getting stdin/stdout vibes, it takes input and output file descriptors directly โ€” fdin and fdout respectively. iconic.

and the way it handles arguments? a whole different agenda. instead of receiving the program name in argv[0], pavlov(3) expects it in the progname parameter. the use of argc and argv reflects this too โ€” the program name is not expected in argv[0], and instead the arguments start immediately. no filler intro, we go straight into the content, periodt.

the arguments you provide reveal the expectations and responses of the pavlov(3) function. each word is a simple operation, and will be executed in the order of appearance in the current program version. fr fr, it's just a list, read left to right.

the pavlov command is a straightforward wrapper around the library function, which is designed for use in programs that need an easily scriptable expectation/response interaction. the command form is mostly useful for testing and development โ€” think of it as the little sister who mostly hangs out at home ๐Ÿ”ฅ.


๐ŸŽ€ COMMANDS ๐ŸŽ€

the following commands are available, and yes, each one is a single word, no spaces, no drama:

  • ?<regex> โ€” matches a POSIX extended regular expression against a message as it arrives over fdin. โš ๏ธ heads up: this assumes that the input is not manually typed, as it would be with chat(8), but is instead expected to arrive in bursts, like network packets. the <regex> form is case-sensitive but may have multiple lines; the ^ and $ symbols will respectively match the beginning and end of any of these lines. as soon as a match is found within the message, this command finishes; otherwise, another message is awaited. so likeโ€ฆ it waits, and waits, and then slays ๐Ÿ’…
  • !<text> โ€” prints the <text> to fdout. it will unescape backslashes in the usual manner. and lowkey a caveat: support for groups in a prior <regex> is not built into the current version of pavlov(3). so don't try to be cute with capture groups, bestie, it's not that kind of party ๐Ÿ™ˆ
  • @<msdelay> โ€” waits for the number of milli-seconds indicated in the numeric <msdelay> value. that's it. that's the whole vibe. a little nap ๐Ÿ˜ด

โญ RETURN VALUE โญ

when the last command is completed without error, the function returns 0 and the program delivers that as its exit code. clean, flawless, ate ๐Ÿ’…

any error causes the function to return 1 and set errno to something appropriate. the command will return this return value 1 as its exit code to aid any scripts wrapped around it, and it will print an error message to aid any human user. so: scripts get the number, humans get the words. everybody eats ๐Ÿซถ


๐ŸŒˆ EXAMPLE ๐ŸŒˆ

the smallest program for pavlov that runs to successful completion is an empty program. literally. simply running the command without arguments, or calling the function with argc set to zero would lead to an immediate 0 return code. no thoughts, head empty, exit zero โœจ

a more typical sequence of commands would be pavlov ?bell @100 !drool to express that upon encountering the word bell on its input, the command should send out the word drool on its output after a 0.1 second delay. (that's 100 ms, honey, do the math on the @100 ๐Ÿงฎ)

the intention of pavlov(3) however, is to jump through the slightly variable hoops that textual protocols need to be jumped to get a STARTTLS command agreed on. once a TLS handshake is complete, protocols tend to start from scratch and forget the preceding unencrypted protocol. rude, but okay ๐Ÿ’€

such a use case could be handled with a sequence such as this for an SMTP server:

  • ?^220 .*$ โ€” to match an SMTP server's welcome message,
  • !EHLO orvelte.nep โ€” to send our mail server name and greet the server,
  • ?^250-STARTTLS$ โ€” to await the option that we desire to use,
  • ?^250 .*$ โ€” to wait for the end of the options,
  • !STARTTLS โ€” to request a switch to TLS,
  • ?^220 .*$ โ€” to await acceptance.

this kind of exchange can indeed be useful in combination with the tlstunnel(8) command. iykyk ๐Ÿ”ฅ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Written by Rick van Rein of OpenFortress.nl, for the ARPA2.net project. Pavlov starts its life as part of the TLS Pool, but may start a life of its own if it is considered generally useful. main character energy from day one, honestly ๐Ÿฆ‹


๐Ÿ› REPORTING BUGS ๐Ÿ›

for any discussion, including about bugs, please use the TLS Pool mailing list found on http://lists.arpa2.org/mailman/listinfo/tls-pool. come chat, we don't bite (much) ๐Ÿ’œ

please read the software distribution's README, INSTALL and TODO files for information about the tlspool-daemon(8) implementation status. yes, all three, they're not decoration ๐ŸŽ€


Copyright ยฉ 2019 Rick van Rein, ARPA2.net.

ARPA2 is funded from InternetWide.org, which in turns receives donations from various funding sources with an interest in a private and secure Internet that gives users control over their online presence. pretty iconic mission statement ngl ๐ŸŒโœจ


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

online resources may be found on the project home page, http://tlspool.arpa2.net. go click, it's cute over there ๐ŸŒธ


ok that's the whole page, every single detail intact, no cap. now go forth and make your protocols converse ๐Ÿ’…

and that's the wrap, bestie โ€” brought to you by ARPA2.net, dated April 2019, on manual page PAVLOV(3). see you in the next group chat ๐ŸŽ€๐Ÿ’–

๐Ÿ“ฆ where this page comes from