### Start rc shell with Plan 9 environment Source: https://9fans.github.io/plan9port/man/man1/9.html This example demonstrates starting an rc shell with the Plan 9 commands prioritized in the PATH, followed by running the Unix ls command. This is useful for environments where Plan 9 and Unix commands might have the same names. ```shell $ 9 rc % u ls ``` -------------------------------- ### Start debugging ls with breakpoints Source: https://9fans.github.io/plan9port/man/man1/acid.html Example of starting Acid to debug `/bin/ls`, setting breakpoints, and running until the first breakpoint. This example is noted as not working on Unix. ```shell % acid /bin/ls /bin/ls: mips plan 9 executable /sys/lib/acid/port /sys/lib/acid/mips acid: new() 70094: system call _main ADD $−0x14,R29 70094: breakpoint main+0x4 MOVW R31,0x0(R29) acid: pid 70094 acid: argv0 = *main:argv acid: whatis argv0 integer variable format s acid: *argv0 /bin/ls acid: bpset(ls) acid: cont() 70094: breakpoint ls ADD $−0x16c8,R29 acid: ``` -------------------------------- ### Import Remote Plumber and Start Local Services Source: https://9fans.github.io/plan9port/man/man4/import.html This example imports the remote plumber service from 'anna' into the local namespace and then starts local instances of 'sam' and '9term', both configured to connect to 'anna'. Ensure the remote plumber is set up first. ```bash NAMESPACE=/tmp/ns.anna mkdir $NAMESPACE import -n $remotens -s plumb anna sam & 9term ssh anna & ``` -------------------------------- ### Preview Manual Page with tr2post Source: https://9fans.github.io/plan9port/man/man1/tr2post.html This example demonstrates how to preview a manual page by piping troff output through tr2post and then viewing it with psv. Ensure troff and psv are installed and accessible. ```bash troff -man /usr/local/plan9/man/man1/tr2post.1 | tr2post | psfonts >/tmp/a.ps psv /tmp/a.ps ``` -------------------------------- ### System Call Examples Source: https://9fans.github.io/plan9port/man/man1/acid.html Examples of close and pwrite system calls with their respective return values. ```c close(3) ``` ```c pwrite(1, "−−rw−rw−r−− M 9 rob rob 2519 Mar 22 10:29 lib/profile ", 54, −1) ``` -------------------------------- ### Vbackup Mount Command Example Source: https://9fans.github.io/plan9port/man/man8/vbackup.html An example of the 'mount' command line that vbackup prints upon completion. This line is a valid configuration for vnfs. ```bash mount /host/yyyy/mmdd/mtpt score yyyy/mmdd/hhmm ``` -------------------------------- ### Basic Plumbing Rules Configuration Source: https://9fans.github.io/plan9port/man/man7/plumb.html A simple starting set of plumbing rules. This example shows how to set the default editor and include basic rule sets. ```shell editor = acme # or editor = sam include basic ``` -------------------------------- ### Run Plan 9 Installation Script Source: https://9fans.github.io/plan9port/man/man1/install.html Execute the INSTALL script from the root of the Plan 9 source tree. Optional flags control the build and installation steps. ```shell cd /usr/local/plan9; ./INSTALL ``` ```shell ./INSTALL -b ``` ```shell ./INSTALL -c ``` ```shell ./INSTALL -r /path/to/plan9 ``` -------------------------------- ### Window Management Examples Source: https://9fans.github.io/plan9port/man/man3/graphics.html Provides code examples for reconnecting to a window after a resize event and for creating and setting up a new rio window. ```APIDOC ## Window Management Examples ### Description Illustrates common window management tasks in Plan 9. ### Method N/A (Code examples) ### Endpoint N/A ### Parameters N/A ### Request Example ```c // Reconnect to window after resize if(getwindow(display, Refnone) < 0) sysfatal("resize failed: %r"); // Create and set up a new rio window Image *screen2; Screen *_screen2; char *srvwsys; int fd; srvwsys = getenv("wsys"); if(srvwsys == nil) sysfatal("can't find $wsys: %r"); rfork(RFNAMEG); /* keep mount of rio private */ fd = open(srvwsys, ORDWR); if(fd < 0) sysfatal("can't open $wsys: %r"); /* mount creates window; see `_rio_`(4) */ if(mount(fd, −1, "/tmp", MREPL, "new −dx 300−dy 200") < 0) sysfatal("can't mount new window: %r"); if(gengetwindow(display, "/tmp/winname", &screen2, &_screen2, Refnone) < 0) sysfatal("resize failed: %r"); /* now open /tmp/cons, /tmp/mouse */ ... ``` ### Response N/A #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Sort Command Examples Source: https://9fans.github.io/plan9port/man/man1/sort.html Illustrative examples of how to use the sort command with various options. ```APIDOC ## Sort Command Examples ### Example 1: Unique alphabetical sort `sort -u +0f +0 list` **Description:** Print in alphabetical order all the unique spellings in a list of words where capitalized words differ from uncapitalized. ### Example 2: Sort by user name (second colon-separated field) `sort -t: +1 /adm/users` **Description:** Print the users file sorted by user name (the second colon-separated field). ### Example 3: Unique month sort on sorted file `sort -umM dates` **Description:** Print the first instance of each month in an already sorted file. Options `−um` with just one input file make the choice of a unique representative from a set of equal lines predictable. ### Example 4: Stable sort using grep, sort, and sed `grep -n '^' input | sort -t: +1f +0n | sed 's/[0-9]*://'` **Description:** A stable sort: input lines that compare equal will come out in their original order. ``` -------------------------------- ### Map Command Examples Source: https://9fans.github.io/plan9port/man/man1/map.html Examples demonstrating the usage of the 'map' command with various projections and options. ```APIDOC ## Perspective Map Example ### Description A view looking down on New York from 100 miles up. Options `-o` for coordinates, `-l` for limits, and `-w` for circular border are demonstrated. ### Method N/A (Command-line utility) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example `map perspective 1.025 -o 40.75 74` `map perspective 1.025 -o 40.75 74 -l 20 60 30 100` `map perspective 1.025 -o 40.75 74 -w 77.33` ### Response #### Success Response (200) N/A (Generates a map image) #### Response Example N/A ``` ```APIDOC ## Mercator Map Example ### Description An 'equatorial' map of the earth centered on New York using the Mercator projection. Demonstrates coordinate centering and twisting. ### Method N/A (Command-line utility) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example `map mercator -o 49.25 -106 180` `map mercator -o 130.75 74` ### Response #### Success Response (200) N/A (Generates a map image) #### Response Example N/A ``` ```APIDOC ## Albers Map Example ### Description A customary curved-latitude map of the United States using the Albers projection. Demonstrates limits and map file usage. ### Method N/A (Command-line utility) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example `map albers 28 45 -l 20 50 60 130 -m states` ### Response #### Success Response (200) N/A (Generates a map image) #### Response Example N/A ``` ```APIDOC ## Harrison Projection Fan View Example ### Description A fan view covering 60° on either side of the Date Line, as seen from one earth radius above the North Pole. Demonstrates overriding default orientation with the `-o` option. ### Method N/A (Command-line utility) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example `map harrison 2 30 -l -90 90 120 240 -o 90 0 0` ### Response #### Success Response (200) N/A (Generates a map image) #### Response Example N/A ``` -------------------------------- ### Example: Announce and echo server Source: https://9fans.github.io/plan9port/man/man3/dial.html This example sets up an announce on TCP/IP for 'kremvax' and enters a loop to receive calls and echo back any received data. ```c int bekremvax(void) { int dfd, acfd, lcfd; char adir[40], ldir[40]; int n; ``` -------------------------------- ### Pic Drawing Examples Source: https://9fans.github.io/plan9port/man/man1/pic.html Examples demonstrating object placement, splines, arcs, and loops in Pic. ```pic arrow "input" above; box "process"; arrow "output" above move A: ellipse ``` ```pic circle rad .1 with .w at A.e circle rad .05 at 0.5 circle rad .065 at 0.5 spline from last circle.nw left .25 then left .05 down .05 arc from A.c to A.se rad 0.5 for i = 1 to 10 do { line from A.s+.025*i,.01*i down i/50 } ``` -------------------------------- ### Test Command Examples Source: https://9fans.github.io/plan9port/man/man1/test.html Illustrative examples of using the 'test' command. ```APIDOC ## Test Examples **Incorrect string comparison (demonstrates a common pitfall):** ```sh if (test $1 '=' "−c") echo OK # wrong! ``` **Corrected string comparison using shell pattern matching:** ```sh if (~ $1 −c) echo OK ``` **Check if 'abc' exists as a file or directory:** ```sh test −f abc −o −d abc ``` ``` -------------------------------- ### Start a new process and halt Source: https://9fans.github.io/plan9port/man/man1/acid.html Starts a new process with the given arguments and halts it at the first instruction. Arguments are provided as a single string. ```acid newproc(_arguments_) ``` -------------------------------- ### Example Output of Option Parsing Source: https://9fans.github.io/plan9port/man/man3/arg.html Shows the expected output when the example C program is run with specific command-line arguments. ```text prog −b −f(file1) badflag('r') −f(file2) 2 args: 'arg1' 'arg2' ``` -------------------------------- ### Example: Connect to a Unix socket Source: https://9fans.github.io/plan9port/man/man3/dial.html This example shows how to connect to a Unix domain socket served by 'acme' using the dial function with a specific path. ```c int dialacme(void) { return dial("unix!/tmp/ns.ken.:0/acme", 0, 0, 0); } ``` -------------------------------- ### BC Example Source: https://9fans.github.io/plan9port/man/man1/bc.html An example demonstrating how to define a function for calculating the exponential and using it. ```APIDOC ## BC Example ### Description This example defines a function to compute an approximate value of the exponential and then uses it to print 10 values. Note that the exponential function in the math library provides more accurate results. ### Code ```bc scale = 20 define e(x) { auto a, b, c, i, s a = 1 b = 1 s = 1 for(i=1; 1; i++) { a *= x b *= i c = a/b if(c == 0) return s s += c } } for(i=1; i<=10; i++) print e(i) ``` ``` -------------------------------- ### Pic Language Example Source: https://9fans.github.io/plan9port/man/man1/pic.html A practical example demonstrating the usage of Pic language syntax for drawing shapes and lines. ```APIDOC ## Pic Language Example This example illustrates drawing arrows, boxes, ellipses, circles, splines, and arcs, along with using loops. ```pic arrow "input" above; box "process"; arrow "output" above move A: ellipse circle rad .1 with .w at A.e circle rad .05 at 0.5 circle rad .065 at 0.5 spline from last circle.nw left .25 then left .05 down .05 arc from A.c to A.se rad 0.5 for i = 1 to 10 do { line from A.s+.025*i,.01*i down i/50 } ``` ``` -------------------------------- ### Example Usage of Unsharp Source: https://9fans.github.io/plan9port/man/man3/get9root.html This example demonstrates how to use unsharp to open a file within the Plan 9 tree, as used by the plumber utility. Avoid using unsharp on paths obtained from user input. ```c snprint(buf, sizeof buf, "#9/plumb/%s", name); fd = open(unsharp(buf), OREAD); ``` -------------------------------- ### 9P File Interface and Examples Source: https://9fans.github.io/plan9port/man/man3/9p.html Information on the `File` interface, its appropriate use cases, and examples of servers built with the library. ```APIDOC ## 9P File Interface and Examples ### Description The `File` interface is suitable for managing arbitrary file trees. It is best avoided when the tree structure can be generated dynamically, such as for highly structured trees or trees maintained externally. ### Examples - `/usr/local/plan9/src/lib9p/ramfs.c`: An example of a simple single-threaded file server. - Plan 9 examples: `_archfs_`, `_cdfs_`, `_nntpfs_`, `_webfs_`, and `_sshnet_`. ### Use Cases - **`File` interface appropriate for**: Maintaining arbitrary file trees (e.g., `ramfs`). - **`File` interface to avoid when**: Tree structure is easily generated (e.g., `cdfs`, `nntpfs`) or maintained elsewhere. ### SOURCE - `/usr/local/plan9/src/lib9p` ### SEE ALSO - `_9p-fid_(3)` - `_9p-file_(3)` - `_intro_(9p)` ``` -------------------------------- ### Example: Make a call to kremvax Source: https://9fans.github.io/plan9port/man/man3/dial.html This example demonstrates making a simple network call using the dial function to 'kremvax'. It returns an open file descriptor for communication. ```c int callkremvax(void) { return dial("kremvax", 0, 0, 0); } ``` -------------------------------- ### Example table definition Source: https://9fans.github.io/plan9port/man/man1/tbl.html A complete example showing the definition of a table with headers and data rows. ```text .TS c s s c c s c c c l n n. Household Population TownHouseholds NumberSize Bedminster7893.26 Bernards Twp.30873.74 Bernardsville20183.30 .TE ``` -------------------------------- ### Vnfs Address Option Example Source: https://9fans.github.io/plan9port/man/man8/vbackup.html Example of the -a option for vnfs, specifying the network address for serving requests. ```bash -a addr Serve requests on addr (see above). ``` -------------------------------- ### fossil/fossil Source: https://9fans.github.io/plan9port/man/man4/fossil.html Starts a new instance of the Fossil file server. ```APIDOC ## fossil/fossil ### Description Starts a new instance of the Fossil file server. It is configured mainly through console commands. ### Method EXEC ### Parameters #### Options - **-D** (flag) - Optional - Toggle the debugging flag. - **-t** (flag) - Optional - Start a file server console on /dev/cons. - **-c** (string) - Optional - Execute the console command cmd. - **-f** (string) - Optional - Read and execute console commands stored in the Fossil disk file. - **-m** (integer) - Optional - Allocate free-memory-percent percent of the available free RAM for buffers. ``` -------------------------------- ### Mkfile Example: Maintaining a Library Source: https://9fans.github.io/plan9port/unix/man/mk1.html An example mkfile for maintaining a static library (libc.a). It shows how to add new members to the library using the 'ar' command and the 'N' attribute to update timestamps. ```mk libc.a(%.$O):N: %.$O ar r libc.a $newmember ``` -------------------------------- ### Example Thumbprint File Entry Source: https://9fans.github.io/plan9port/man/man7/thumbprint.html This is an example of a line in a thumbprint file, specifying the x509 certificate and its SHA1 checksum, along with a common name for a web server. ```text x509 sha1=8fe472d31b360a8303cd29f92bd734813cbd923c cn=*.cs.bell−labs.com ``` -------------------------------- ### Mkfile Variable Substitution Example Source: https://9fans.github.io/plan9port/unix/man/mk1.html Demonstrates variable substitution in Mk. The first part shows substitution when the rule is read, and the second part shows substitution during recipe execution. This example compiles 'b.c' into 'foo' if 'a.c' is newer. ```mk bar=a.c foo: $bar $CC -o foo $bar bar=b.c ``` -------------------------------- ### Create and set up a new rio window Source: https://9fans.github.io/plan9port/man/man3/graphics.html This sequence demonstrates how to mount a new window via the wsys service and initialize the display context. ```C Image *screen2; Screen *_screen2; srvwsys = getenv("wsys"); if(srvwsys == nil) sysfatal("can't find $wsys: %r"); rfork(RFNAMEG); /* keep mount of rio private */ fd = open(srvwsys, ORDWR); if(fd < 0) sysfatal("can't open $wsys: %r"); /* mount creates window; see _rio_(4) */ if(mount(fd, −1, "/tmp", MREPL, "new −dx 300−dy 200") < 0) sysfatal("can't mount new window: %r"); if(gengetwindow(display, "/tmp/winname", &screen2, &_screen2, Refnone) < 0) sysfatal("resize failed: %r"); /* now open /tmp/cons, /tmp/mouse */ ... ``` -------------------------------- ### Example: Walking Path and Creating File with Reference Handling Source: https://9fans.github.io/plan9port/man/man3/9p-file.html Demonstrates correct reference counting when walking a path and creating a new file. It uses `incref` to manage references and `closefile` to release them. ```c f = tree->root; incref(f); for(i=0; iargs, Complex); return fmtprint(f, "(%g,%g)", c.r, c.i); } main(...) { Complex x = (Complex){ 1.5, -2.3 }; fmtinstall('X', Xfmt); print("x = %X\n", x); } ``` -------------------------------- ### TLS Server Initialization Source: https://9fans.github.io/plan9port/man/man3/pushtls.html Example of initializing a TLS server connection and loading a certificate. ```c fd = accept(lcfd, ldir); conn = (TLSconn*)mallocz(sizeof *conn, 1); conn−>cert = readcert("cert.pem", &conn−>certlen); fd = tlsServer(fd, conn); ...application begins... ``` -------------------------------- ### RAMFS(4) - Memory File System Source: https://9fans.github.io/plan9port/man/man4/ramfs.html The ramfs command starts a 9P file server that keeps all files in memory. It's primarily useful as an example of a user-level file server or for high-performance temporary files. ```APIDOC ## RAMFS(4) ### Description _Ramfs_ starts a 9P file server keeping all files in memory. Initially the file tree is empty. By default, _ramfs_ posts its service as `ramfs` using _9pserve_(4). This program is useful mainly as an example of how to write a user-level file server. It can also be used to provide high-performance temporary files. ### Method This describes the command-line invocation of the `ramfs` utility. ### Endpoint N/A (This is a command-line utility, not a network endpoint). ### Parameters #### Command-line Flags - **-i** (flag) - Optional - Tells _ramfs_ to use file descriptors 0 and 1 for its communication channel rather than create a pipe. This makes it possible to use _ramfs_ as a file server on a remote machine: the file descriptors 0 and 1 will be the network channel from _ramfs_ to the client machine. - **-S _service_** (string) - Optional - Specifies an alternate service name for ramfs to use. ### Request Example ```bash ramfs -S myramfs ``` ### Response This command does not produce a direct response in the traditional sense. It starts a file server process. The success of the operation is indicated by the process running without errors. The file system itself is accessed via the 9P protocol. ### SEE ALSO _9p_(3), _9pserve_(4) ``` -------------------------------- ### Starting Venti and Checking Statistics Source: https://9fans.github.io/plan9port/man/man8/venti.html Commands to launch the Venti server and retrieve storage statistics via HTTP. ```shell venti/venti hget http://$sysname/storage ``` -------------------------------- ### Custom Verb Installation Source: https://9fans.github.io/plan9port/man/man3/print.html Information on how to install custom formatting verbs. ```APIDOC ## Custom Verb Installation ### Description Allows for the installation of custom formatting verbs. ### Function - `fmtinstall(3)`: Installs custom verbs. ``` -------------------------------- ### Formatting and Installation Source: https://9fans.github.io/plan9port/unix/man/quote3.html Functions for installing custom formatters and handling string output. ```APIDOC ## void quotefmtinstall(void) ### Description Installs quotestrfmt and quoterunestrfmt under the standard format characters 'q' and 'Q' for use with print(3). ## int quotestrfmt(Fmt*) ### Description Formatting routine that produces quoted strings as output. ## int quoterunestrfmt(Fmt*) ### Description Formatting routine that produces quoted rune strings as output. ``` -------------------------------- ### Initialize Display Structures Source: https://9fans.github.io/plan9port/man/man3/graphics.html Sets up display structures but does not allocate fonts or call _getwindow_. Arguments are similar to _initdraw_, with _win_ specifying the directory for window-associated files. ```c void _initdisplay(Display *d, char *win, char *label, int (*errfun)(Display *, char *)) ``` -------------------------------- ### Shell script shebang example Source: https://9fans.github.io/plan9port/man/man3/exec.html Example of a shell script header using the #! syntax. ```shell #!/bin/rc ls | mc ``` -------------------------------- ### Fossil Configuration File Example Source: https://9fans.github.io/plan9port/man/man8/fossilcons.html A sample configuration file used by the Plan 9 distribution file server. ```text srv −p fscons.sources srv −p fscons.sources.adduserd srv sources fsys main config /dev/sdC0/fossil.outside fsys main open −c 25600 fsys main users /active/adm/users listen tcp!*!564 msg −m 40 −p 10 snaptime −a 0000 −s 15 ``` -------------------------------- ### ctime Output Format Example Source: https://9fans.github.io/plan9port/man/man3/ctime.html Example of the string format returned by the ctime function. ```text Wed Aug 5 01:07:47 EST 1973 ``` -------------------------------- ### Implement a TCP echo server using announce and listen Source: https://9fans.github.io/plan9port/man/man3/dial.html This snippet demonstrates the standard pattern for creating a network server in Plan 9. It uses announce to bind to a port, listen to accept incoming calls, and fork to handle each connection independently. ```c char buf[256]; acfd = announce("tcp!*!7", adir); if(acfd < 0) return −1; for(;;){ /* listen for a call */ lcfd = listen(adir, ldir); if(lcfd < 0) return −1; /* fork a process to echo */ switch(fork()){ case −1: perror("forking"); close(lcfd); break; case 0: /* accept the call and open the data file */ dfd = accept(lcfd, ldir); if(dfd < 0) return −1; /* echo until EOF */ while((n = read(dfd, buf, sizeof(buf))) > 0) write(dfd, buf, n); exits(0); default: close(lcfd); break; } } } ``` -------------------------------- ### Process Line Starting with '.' - GRAP(1) Source: https://9fans.github.io/plan9port/man/man1/grap.html Lines starting with a '.' are copied verbatim to the output. ```grap .anything at beginning of line ``` -------------------------------- ### Implement Custom ioread using iocall Source: https://9fans.github.io/plan9port/man/man3/ioproc.html Example showing how to implement a custom I/O routine using the iocall primitive. ```c static long _ioread(va_list *arg) { int fd; void *a; long n; fd = va_arg(*arg, int); a = va_arg(*arg, void*); n = va_arg(*arg, long); return read(fd, a, n); } long ioread(Ioproc *io, int fd, void *a, long n) { return iocall(io, _ioread, fd, a, n); } ``` -------------------------------- ### Install Quoting Formatters Source: https://9fans.github.io/plan9port/unix/man/quote3.html Installs quotestrfmt and quoterunestrfmt under the standard format characters 'q' and 'Q'. ```c void quotefmtinstall(void) ``` -------------------------------- ### Initialize Graphics Display Connection Source: https://9fans.github.io/plan9port/man/man3/graphics.html Connects to the display, setting up global variables for display, screen, and font. Returns -1 on failure and sets the error string. Optionally writes a label to /dev/label for window identification. ```c int _initdraw(char *label, char *font, int (*errfun)(Display *, char *)) ``` -------------------------------- ### Formatting Venti Storage Components Source: https://9fans.github.io/plan9port/man/man8/venti.html Commands to initialize index sections, arenas, and the bloom filter before starting the server. ```shell venti/fmtisect isect0. /tmp/disks/isect0 venti/fmtisect isect1. /tmp/disks/isect1 venti/fmtarenas arenas0. /tmp/disks/arenas & venti/fmtbloom /tmp/disks/bloom & wait venti/fmtindex venti.conf ``` -------------------------------- ### Start SmugMug rpc log Source: https://9fans.github.io/plan9port/man/man4/smugfs.html Starts the SmugMug remote procedure call logging in the background. ```shell % cat /n/smug/rpclog & ``` -------------------------------- ### Fatal Error Function Example Source: https://9fans.github.io/plan9port/unix/man/print3.html An example implementation of a `fatal` function that prints an error message and exits. ```APIDOC ## Fatal Error Function Example ### Description This function prints a formatted error message to standard error and then terminates the program. ### Function Signature `void fatal(char *msg, ...)` ### Implementation Details - Uses a buffer (`buf`) of 1024 bytes. - Initializes `va_list` for variable arguments. - Prepends "Fatal error: " to the message. - Uses `vseprint` to format the message with variable arguments. - Writes the buffer content to file descriptor 2 (stderr). - Calls `exit(1)` to terminate the program. ### Example Code ```c void fatal(char *msg, ...) { char buf[1024], *out; va_list arg; out = seprint(buf, buf+sizeof buf, "Fatal error: "); va_start(arg, msg); out = vseprint(out, buf+sizeof buf, msg, arg); va_end(arg); write(2, buf, out-buf); exit(1); } ``` ``` -------------------------------- ### X.509 Subject String Example Source: https://9fans.github.io/plan9port/man/man3/rsa.html Example format for the subject string used in X.509 certificate generation. ```text "C=US ST=NJ L=07922 O=Lucent OU='Bell Labs' CN=Eric" ``` -------------------------------- ### Initialize Venti Index with fmtindex Source: https://9fans.github.io/plan9port/man/man8/venti-fmt.html Use fmtindex to initialize index sections based on a configuration file. Arena and index files must be pre-formatted. ```bash venti/fmtindex venti.conf ``` -------------------------------- ### Fatal Error Function Example Source: https://9fans.github.io/plan9port/man/man3/print.html An example C function demonstrating how to print a formatted error message and exit. ```APIDOC ## Fatal Error Function Example ### Description This function prints a formatted error message to standard error and then exits the program. ### Function Signature `void fatal(char *msg, ...)` ### Code Example ```c void fatal(char *msg, ...) { char buf[1024], *out; va_list arg; out = seprint(buf, buf+sizeof buf, "Fatal error: "); va_start(arg, msg); out = vseprint(out, buf+sizeof buf, msg, arg); va_end(arg); write(2, buf, out-buf); exits("fatal error"); } ``` ``` -------------------------------- ### intro - Introduction to Library Functions Source: https://9fans.github.io/plan9port/man/man3 Provides a general introduction to the library functions available in Plan 9 from User Space. ```APIDOC ## intro /intro ### Description Introduction to library functions in Plan 9 from User Space. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Custom Verb Installation Source: https://9fans.github.io/plan9port/man/man3/fmtinstall.html Demonstrates how to install a custom verb ('X') for formatting complex numbers using the fmt library. ```APIDOC ## Custom Verb Installation Example ### Description This example shows how to add a new verb, 'X', to the `fmt` library to format complex numbers. It defines a `Complex` struct, a formatting function `Xfmt`, and registers it using `fmtinstall`. ### Method `fmtinstall` ### Endpoint N/A (Library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c typedef struct { double r, i; } Complex; #pragma varargck type "X" Complex int Xfmt(Fmt *f) { Complex c; c = va_arg(f->args, Complex); return fmtprint(f, "(%g,%g)", c.r, c.i); } main(...) { Complex x = (Complex){ 1.5, -2.3 }; fmtinstall('X', Xfmt); print("x = %X\n", x); } ``` ### Response #### Success Response (200) Prints the formatted complex number. #### Response Example ``` x = (1.5,-2.3) ``` ``` -------------------------------- ### Initialize and mount a new Fossil file system Source: https://9fans.github.io/plan9port/man/man4/fossil.html Formats a disk, configures the server with specific permissions, and mounts the resulting service. ```shell fossil/flfmt /dev/sdC0/fossil fossil/conf −w /dev/sdC0/fossil <