Browse Source

Header comments for a bunch of apps

K. Lange 5 years ago
parent
commit
2531edb2da

+ 11 - 0
apps/about.c

@@ -1,3 +1,14 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * about - Show an "About <Application>" dialog.
+ *
+ * By default, shows "About ToaruOS", suitable for use as an application
+ * menu entry. Optionally, takes arguments specifying another application
+ * to describe, suitable for the "Help > About" menu bar entry.
+ */
 #include <toaru/yutani.h>
 #include <toaru/graphics.h>
 #include <toaru/decorations.h>

+ 12 - 0
apps/background.c

@@ -1,3 +1,15 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * background - Draw a desktop wallpaper.
+ *
+ * TODO: This is a very minimal wallpaper renderer.
+ *       ToaruOS-mainline, before it went all Python,
+ *       included a more complete wallpaper application,
+ *       which supported icons and config files.
+ */
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/utsname.h>

+ 11 - 1
apps/chmod.c

@@ -1,4 +1,14 @@
-/* probably-non-compliant chmod implementation */
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * chmod - change file permissions
+ *
+ * Note: This implementation is likely non-compliant, though it does
+ *       attempt to look similar to the standard POSIX syntax,
+ *       supporting both octal mode setings and +/-rwx flavors.
+ */
 #include <unistd.h>
 #include <stdio.h>
 #include <fcntl.h>

+ 13 - 0
apps/cursor-off.c

@@ -1,3 +1,16 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2016-2018 K. Lange
+ *
+ * cursor-off - Disables the VGA text mode cursor.
+ *
+ * This is an old tool that calls a special system call
+ * to change the VGA text-mode cursor position. The VGA
+ * terminal renders its own cursor in software, so we
+ * try to move the hardware cursor off screen so it doesn't
+ * interfere with the rest of the terminal and look weird.
+ */
 #include <syscall.h>
 
 int main(int argc, char * argv[]) {

+ 16 - 0
apps/date.c

@@ -1,7 +1,23 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * date - Print the current date and time.
+ *
+ * TODO: The traditional POSIX version of this tool is supposed
+ *       to accept a format *and* allow you to set the time.
+ *       We currently lack system calls for setting the time,
+ *       but when we add those this should probably be updated.
+ *
+ *       At the very least, improving this to print the "correct"
+ *       default format would be good.
+ */
 #include <stdio.h>
 #include <time.h>
 #include <sys/time.h>
 
+/* XXX Why do we have our own list of weekdays */
 char * daysofweeks[] = {
     "Sunday",
     "Monday",

+ 7 - 0
apps/false.c

@@ -1,3 +1,10 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * false - returns a failure status code.
+ */
 int main() {
 	return 1;
 }

+ 17 - 0
apps/file-browser.c

@@ -1,3 +1,14 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * file-browser - Show directory listings.
+ *
+ * This is a basic graphical file navigator. It's based somewhat
+ * on the original Python implementation. There's still a lot
+ * of work to do here presentation-wise.
+ */
 #include <stdio.h>
 #include <unistd.h>
 #include <dirent.h>
@@ -260,9 +271,12 @@ static void resize_finish(int w, int h) {
 	yutani_flip(yctx, main_window);
 }
 
+/* TODO */
+#if 0
 static void _menu_action_input_path(struct MenuEntry * entry) {
 
 }
+#endif
 
 static void _menu_action_navigate(struct MenuEntry * entry) {
 	/* go to entry->action */
@@ -318,8 +332,11 @@ int main(int argc, char * argv[]) {
 	menu_set_insert(menu_bar.set, "file", m);
 
 	m = menu_create(); /* Go */
+	/* TODO implement input dialog for Path... */
+#if 0
 	menu_insert(m, menu_create_normal("open",NULL,"Path...", _menu_action_input_path));
 	menu_insert(m, menu_create_separator());
+#endif
 	menu_insert(m, menu_create_normal("home",getenv("HOME"),"Home",_menu_action_navigate));
 	menu_insert(m, menu_create_normal(NULL,"/","File System",_menu_action_navigate));
 	menu_insert(m, menu_create_normal("up",NULL,"Up",_menu_action_up));

+ 12 - 6
apps/font-server.c

@@ -1,3 +1,15 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * font-server - Provides shared-memory fonts.
+ *
+ * This is an implementation of the shared memory font server
+ * from Yutani in mainline ToaruOS. In theory, with the fonts
+ * installed, this could be used to provide fonts for legacy
+ * mainline applications in ToaruOS-NIH, but this is untested.
+ */
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
@@ -29,12 +41,6 @@ static struct font_def fonts[] = {
 
 /**
  * Preload a font into the font cache.
- *
- * TODO This should probably be moved out of the compositor,
- *      perhaps into a generic resource cache daemon. This
- *      is mostly kept this way for legacy reasons - the old
- *      compositor did it, but it was also using some of the
- *      fonts for internal rendering. We don't draw any text.
  */
 static char * precache_shmfont(char * ident, char * name) {
 	FILE * f = fopen(name, "r");

+ 9 - 2
apps/getty.c

@@ -1,5 +1,12 @@
-/*
- * runs a proper tty on a serial port
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * getty - Manage a TTY.
+ *
+ * Wraps a serial port (or other dumb connection) with a pty
+ * and manages a login for it.
  */
 #include <stdio.h>
 #include <stdlib.h>

+ 7 - 0
apps/hello.c

@@ -1,3 +1,10 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2011~2018 K. Lange
+ *
+ * hello - Prints "Hello, world."
+ */
 #include <stdio.h>
 
 int main(int argc, char * argv[]) {

+ 13 - 0
apps/help-browser.c

@@ -1,3 +1,16 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * help-browser - Display documentation.
+ *
+ * This is a work-in-progress reimplementation of the help browser
+ * from mainline ToaruOS. It is currently incomplete.
+ *
+ * Eventually, this should be a rich text document browser, almost
+ * akin to a web browser. Right now it just says "Hello, world."
+ */
 #include <stdio.h>
 #include <unistd.h>
 

+ 10 - 0
apps/hexify.c

@@ -1,3 +1,13 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * hexify - Convert binary to hex.
+ *
+ * This is based on the output of xxd.
+ * Does NOT a hex-to-bin option - something to consider.
+ */
 #include <stdio.h>
 #include <ctype.h>
 

+ 18 - 0
apps/kcmdline.c

@@ -1,3 +1,21 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * kcmdline - Parse /proc/cmdline usefully.
+ *
+ * Parses /proc/cmdline and provides an interface for querying
+ * whether an argument was present, and its value if applicable.
+ *
+ * Also converts ASCII field separators to spaces so that cmdline
+ * arguments can have spaces in them.
+ *
+ * Useful for shell scripts.
+ *
+ * TODO: This should probably be a library we can use in other
+ *       applications...
+ */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

+ 10 - 0
apps/live-session.c

@@ -1,3 +1,13 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * live-session - Run live CD user session.
+ *
+ * Launches the general session manager as 'local', waits for the
+ * session to end, then launches the login manager.
+ */
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>

+ 14 - 0
apps/migrate.c

@@ -1,3 +1,17 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * migrate - Relocate root filesystem to tmpfs
+ *
+ * Run as part of system startup to move the ext2 root ramdisk
+ * into a flexible in-memory temporary filesystem, which allows
+ * file creation and editing and is much faster than the using
+ * the ext2 driver against the static in-memory ramdisk.
+ *
+ * Based on the original Python implementation.
+ */
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>

+ 14 - 2
apps/qemu-display-hack.c

@@ -1,5 +1,17 @@
-/*
- * Daemon to communicate resolution changes with QEMU over serial.
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * qemu-display-hack - Manage display size under QEMU
+ *
+ * Communicates with a harness on the host running QEMU to
+ * automatically update the display resolution when the
+ * QEMU window size changes, similar to how VirtualBox's
+ * display size changing works.
+ *
+ * This is automatically run at startup if the harness is
+ * detected by the 90_qemu_hack.sh startup script.
  */
 #include <stdlib.h>
 #include <stdio.h>

+ 10 - 2
apps/qemu-fwcfg.c

@@ -1,5 +1,13 @@
-/*
- * Tool for reading QEMU fwcfg values.
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * qemu-fwcfg - Read QEMU fwcfg values.
+ *
+ * Provides easy access to values and files set by QEMU's -fw_cfg
+ * flag. This is used by the QEMU harness, as well as the bootloader,
+ * and can be used to provide files directly to the guest.
  */
 
 #include <stdio.h>

+ 10 - 0
apps/session.c

@@ -1,3 +1,13 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * session - UI session manager
+ *
+ * Runs a background and panel for a single user and waits
+ * for them to exit.
+ */
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>

+ 15 - 1
apps/set-resolution.c

@@ -1,3 +1,15 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * set-resolution - Change the display resolution.
+ *
+ * Simple tool to interface with the IO_VID_SET ioctl.
+ *
+ * TODO: This is probably something we should request from the
+ *       compositor rather than a separate application...
+ */
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -13,7 +25,7 @@ int main(int argc, char * argv[]) {
 		fprintf(stderr, "Usage: %s width height\n", argv[0]);
 	}
 
-	/* This should be something we do through yutani */
+	/* Open framebuffer */
 	int fd = open("/dev/fb0", O_RDONLY);
 
 	if (fd < 0) {
@@ -21,10 +33,12 @@ int main(int argc, char * argv[]) {
 		return 1;
 	}
 
+	/* Prepare ioctl from arguments */
 	struct vid_size s;
 	s.width = atoi(argv[1]);
 	s.height = atoi(argv[2]);
 
+	/* Send ioctl */
 	if (ioctl(fd, IO_VID_SET, &s) < 0) {
 		perror("ioctl");
 		return 1;

+ 7 - 0
apps/test-conf.c

@@ -1,3 +1,10 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * test-conf - simple test app for confreader
+ */
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>

+ 18 - 17
apps/uptime.c

@@ -1,6 +1,14 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2015-2018 K. Lange
+ *
+ * uptime - Print system uptime
+ */
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 #include <time.h>
 #include <sys/time.h>
 
@@ -73,23 +81,16 @@ void show_usage(int argc, char * argv[]) {
 
 int main(int argc, char * argv[]) {
 	int just_pretty_uptime = 0;
-
-	if (argc > 1) {
-		for (int i = 1; i < argc; ++i) {
-			if (argv[i][0] == '-') {
-				char *c = &argv[i][1];
-				while (*c) {
-					switch (*c) {
-						case 'p':
-							just_pretty_uptime = 1;
-							break;
-						case '?':
-							show_usage(argc, argv);
-							return 0;
-					}
-					c++;
-				}
-			}
+	int opt;
+
+	while ((opt = getopt(argc, argv, "?p")) != -1 ) {
+		switch (opt) {
+			case 'p':
+				just_pretty_uptime = 1;
+				break;
+			case '?':
+				show_usage(argc, argv);
+				return 0;
 		}
 	}
 

+ 10 - 0
apps/write-out.c

@@ -1,3 +1,13 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * write-out - write stdin into stdout until eof
+ *
+ * Not really necessary any more. This existed before the shell
+ * had support for >output.
+ */
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>

+ 9 - 0
apps/yutani-clipboard.c

@@ -1,3 +1,12 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2018 K. Lange
+ *
+ * yutani-clipboard - Manipulate the Yutani clipboard
+ *
+ * Gets and sets clipboard values.
+ */
 #include <stdio.h>
 #include <unistd.h>
 #include <getopt.h>

+ 13 - 0
apps/yutani-query.c

@@ -1,3 +1,16 @@
+/* vim: tabstop=4 shiftwidth=4 noexpandtab
+ * This file is part of ToaruOS and is released under the terms
+ * of the NCSA / University of Illinois License - see LICENSE.md
+ * Copyright (C) 2015-2018 K. Lange
+ *
+ * yutani-query - Query display server information
+ *
+ * At the moment, this only supports querying the display
+ * resolution. An older version of this application had
+ * support for getting the default font names, but the
+ * font server is no longer part of the compositor, so
+ * that functionality doesn't make sense here.
+ */
 #include <stdio.h>
 #include <unistd.h>