Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/miscutils


Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
Location:
branches/3.2/mindi-busybox/miscutils
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/miscutils/Config.src

    r2725 r3232  
    1111    bool "adjtimex"
    1212    default y
    13     depends on PLATFORM_LINUX
     13    select PLATFORM_LINUX
    1414    help
    1515      Adjtimex reads and optionally sets adjustment parameters for
     
    4040    bool "beep"
    4141    default y
    42     depends on PLATFORM_LINUX
     42    select PLATFORM_LINUX
    4343    help
    4444      The beep applets beeps in a given freq/Hz.
     
    195195    bool "devfsd (obsolete)"
    196196    default n
    197     depends on PLATFORM_LINUX
     197    select PLATFORM_LINUX
    198198    select FEATURE_SYSLOG
    199199    help
     
    239239    bool "Use devfs names for all devices (obsolete)"
    240240    default n
    241     depends on PLATFORM_LINUX
     241    select PLATFORM_LINUX
    242242    help
    243243      This is obsolete and should NOT be used anymore.
     
    259259    bool "eject"
    260260    default y
    261     depends on PLATFORM_LINUX
     261    select PLATFORM_LINUX
    262262    help
    263263      Used to eject cdroms. (defaults to /dev/cdrom)
     
    274274    bool "fbsplash"
    275275    default y
    276     depends on PLATFORM_LINUX
     276    select PLATFORM_LINUX
    277277    help
    278278      Shows splash image and progress bar on framebuffer device.
     
    324324    bool "ionice"
    325325    default y
    326     depends on PLATFORM_LINUX
     326    select PLATFORM_LINUX
    327327    help
    328328      Set/set program io scheduling class and priority
     
    361361endchoice
    362362
    363 config LESS
    364     bool "less"
    365     default y
    366     help
    367       'less' is a pager, meaning that it displays text files. It possesses
    368       a wide array of features, and is an improvement over 'more'.
    369 
    370 config FEATURE_LESS_MAXLINES
    371     int "Max number of input lines less will try to eat"
    372     default 9999999
    373     depends on LESS
    374 
    375 config FEATURE_LESS_BRACKETS
    376     bool "Enable bracket searching"
    377     default y
    378     depends on LESS
    379     help
    380       This option adds the capability to search for matching left and right
    381       brackets, facilitating programming.
    382 
    383 config FEATURE_LESS_FLAGS
    384     bool "Enable extra flags"
    385     default y
    386     depends on LESS
    387     help
    388       The extra flags provided do the following:
    389 
    390       The -M flag enables a more sophisticated status line.
    391       The -m flag enables a simpler status line with a percentage.
    392 
    393 config FEATURE_LESS_MARKS
    394     bool "Enable marks"
    395     default y
    396     depends on LESS
    397     help
    398       Marks enable positions in a file to be stored for easy reference.
    399 
    400 config FEATURE_LESS_REGEXP
    401     bool "Enable regular expressions"
    402     default y
    403     depends on LESS
    404     help
    405       Enable regular expressions, allowing complex file searches.
    406 
    407 config FEATURE_LESS_WINCH
    408     bool "Enable automatic resizing on window size changes"
    409     default y
    410     depends on LESS
    411     help
    412       Makes less track window size changes.
    413 
    414 config FEATURE_LESS_DASHCMD
    415     bool "Enable flag changes ('-' command)"
    416     default y
    417     depends on LESS
    418     help
    419       This enables the ability to change command-line flags within
    420       less itself ('-' keyboard command).
    421 
    422 config FEATURE_LESS_LINENUMS
    423     bool "Enable dynamic switching of line numbers"
    424     default y
    425     depends on FEATURE_LESS_DASHCMD
    426     help
    427       Enables "-N" command.
    428 
    429363config HDPARM
    430364    bool "hdparm"
    431365    default y
    432     depends on PLATFORM_LINUX
     366    select PLATFORM_LINUX
    433367    help
    434368      Get/Set hard drive parameters. Primarily intended for ATA
     
    547481    bool "raidautorun"
    548482    default y
    549     depends on PLATFORM_LINUX
     483    select PLATFORM_LINUX
    550484    help
    551485      raidautorun tells the kernel md driver to
     
    555489    bool "readahead"
    556490    default y
    557     depends on LFS && PLATFORM_LINUX
     491    depends on LFS
     492    select PLATFORM_LINUX
    558493    help
    559494      Preload the files listed on the command line into RAM cache so that
     
    572507    bool "rfkill"
    573508    default n  # doesn't build on Ubuntu 9.04
    574     depends on PLATFORM_LINUX
     509    select PLATFORM_LINUX
    575510    help
    576511      Enable/disable wireless devices.
     
    584519    bool "runlevel"
    585520    default y
     521    depends on FEATURE_UTMP
    586522    help
    587523      find the current and previous system runlevel.
     
    593529    bool "rx"
    594530    default y
    595     depends on PLATFORM_LINUX
     531    select PLATFORM_LINUX
    596532    help
    597533      Receive files using the Xmodem protocol.
     
    659595    bool "wall"
    660596    default y
     597    depends on FEATURE_UTMP
    661598    help
    662599      Write a message to all users that are logged in.
     
    665602    bool "watchdog"
    666603    default y
    667     depends on PLATFORM_LINUX
     604    select PLATFORM_LINUX
    668605    help
    669606      The watchdog utility is used with hardware or software watchdog
  • branches/3.2/mindi-busybox/miscutils/adjtimex.c

    r2725 r3232  
    1212 */
    1313
     14//usage:#define adjtimex_trivial_usage
     15//usage:       "[-q] [-o OFF] [-f FREQ] [-p TCONST] [-t TICK]"
     16//usage:#define adjtimex_full_usage "\n\n"
     17//usage:       "Read and optionally set system timebase parameters. See adjtimex(2)\n"
     18//usage:     "\n    -q  Quiet"
     19//usage:     "\n    -o OFF  Time offset, microseconds"
     20//usage:     "\n    -f FREQ Frequency adjust, integer kernel units (65536 is 1ppm)"
     21//usage:     "\n        (positive values make clock run faster)"
     22//usage:     "\n    -t TICK Microseconds per tick, usually 10000"
     23//usage:     "\n    -p TCONST"
     24
    1425#include "libbb.h"
    15 #include <sys/timex.h>
     26#ifdef __BIONIC__
     27# include <linux/timex.h>
     28#else
     29# include <sys/timex.h>
     30#endif
    1631
    1732static const uint16_t statlist_bit[] = {
  • branches/3.2/mindi-busybox/miscutils/bbconfig.c

    r2725 r3232  
    22/* This file was released into the public domain by Paul Fox.
    33 */
     4
     5//usage:#define bbconfig_trivial_usage
     6//usage:       ""
     7//usage:#define bbconfig_full_usage "\n\n"
     8//usage:       "Print the config file used by busybox build"
     9
    410#include "libbb.h"
    511#include "bbconfigopts.h"
    612#if ENABLE_FEATURE_COMPRESS_BBCONFIG
    7 # include "archive.h"
     13# include "bb_archive.h"
    814# include "bbconfigopts_bz2.h"
    915#endif
  • branches/3.2/mindi-busybox/miscutils/beep.c

    r2725 r3232  
    88 *
    99 */
     10
     11//usage:#define beep_trivial_usage
     12//usage:       "-f FREQ -l LEN -d DELAY -r COUNT -n"
     13//usage:#define beep_full_usage "\n\n"
     14//usage:       "    -f  Frequency in Hz"
     15//usage:     "\n    -l  Length in ms"
     16//usage:     "\n    -d  Delay in ms"
     17//usage:     "\n    -r  Repetitions"
     18//usage:     "\n    -n  Start new tone"
     19
    1020#include "libbb.h"
    1121
  • branches/3.2/mindi-busybox/miscutils/chat.c

    r2725 r3232  
    88 * Licensed under GPLv2, see file LICENSE in this source tree.
    99 */
     10
     11//usage:#define chat_trivial_usage
     12//usage:       "EXPECT [SEND [EXPECT [SEND...]]]"
     13//usage:#define chat_full_usage "\n\n"
     14//usage:       "Useful for interacting with a modem connected to stdin/stdout.\n"
     15//usage:       "A script consists of one or more \"expect-send\" pairs of strings,\n"
     16//usage:       "each pair is a pair of arguments. Example:\n"
     17//usage:       "chat '' ATZ OK ATD123456 CONNECT '' ogin: pppuser word: ppppass '~'"
     18
    1019#include "libbb.h"
    1120
  • branches/3.2/mindi-busybox/miscutils/chrt.c

    r2725 r3232  
    66 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    77 */
     8
     9//usage:#define chrt_trivial_usage
     10//usage:       "[-prfom] [PRIO] [PID | PROG ARGS]"
     11//usage:#define chrt_full_usage "\n\n"
     12//usage:       "Change scheduling priority and class for a process\n"
     13//usage:     "\n    -p  Operate on PID"
     14//usage:     "\n    -r  Set SCHED_RR class"
     15//usage:     "\n    -f  Set SCHED_FIFO class"
     16//usage:     "\n    -o  Set SCHED_OTHER class"
     17//usage:     "\n    -m  Show min/max priorities"
     18//usage:
     19//usage:#define chrt_example_usage
     20//usage:       "$ chrt -r 4 sleep 900; x=$!\n"
     21//usage:       "$ chrt -f -p 3 $x\n"
     22//usage:       "You need CAP_SYS_NICE privileges to set scheduling attributes of a process"
     23
    824#include <sched.h>
    925#include "libbb.h"
     
    5470    int policy = SCHED_RR;
    5571
    56     /* at least 1 arg; only one policy accepted */
    57     opt_complementary = "-1:r--fo:f--ro:r--fo";
     72    /* only one policy accepted */
     73    opt_complementary = "r--fo:f--ro:o--rf";
    5874    opt = getopt32(argv, "+mprfo");
     75    if (opt & OPT_m) { /* print min/max and exit */
     76        show_min_max(SCHED_FIFO);
     77        show_min_max(SCHED_RR);
     78        show_min_max(SCHED_OTHER);
     79        fflush_stdout_and_exit(EXIT_SUCCESS);
     80    }
    5981    if (opt & OPT_r)
    6082        policy = SCHED_RR;
     
    6385    if (opt & OPT_o)
    6486        policy = SCHED_OTHER;
    65     if (opt & OPT_m) { /* print min/max */
    66         show_min_max(SCHED_FIFO);
    67         show_min_max(SCHED_RR);
    68         show_min_max(SCHED_OTHER);
    69         fflush_stdout_and_exit(EXIT_SUCCESS);
    70     }
    7187
    7288    argv += optind;
     89    if (!argv[0])
     90        bb_show_usage();
    7391    if (opt & OPT_p) {
    7492        pid_str = *argv++;
     
    91109        pol = sched_getscheduler(pid);
    92110        if (pol < 0)
    93             bb_perror_msg_and_die("can't %cet pid %d's policy", 'g', pid);
     111            bb_perror_msg_and_die("can't %cet pid %d's policy", 'g', (int)pid);
    94112        printf("pid %d's %s scheduling policy: %s\n",
    95113                pid, current_new, policies[pol].name);
    96114        if (sched_getparam(pid, &sp))
    97             bb_perror_msg_and_die("can't get pid %d's attributes", pid);
     115            bb_perror_msg_and_die("can't get pid %d's attributes", (int)pid);
    98116        printf("pid %d's %s scheduling priority: %d\n",
    99                 pid, current_new, sp.sched_priority);
     117                (int)pid, current_new, sp.sched_priority);
    100118        if (!*argv) {
    101119            /* Either it was just "-p <pid>",
     
    116134
    117135    if (sched_setscheduler(pid, policy, &sp) < 0)
    118         bb_perror_msg_and_die("can't %cet pid %d's policy", 's', pid);
     136        bb_perror_msg_and_die("can't %cet pid %d's policy", 's', (int)pid);
    119137
    120138    if (!argv[0]) /* "-p <priority> <pid> [...]" */
  • branches/3.2/mindi-busybox/miscutils/conspy.c

    r2725 r3232  
    1111 */
    1212
    13 //applet:IF_CONSPY(APPLET(conspy, _BB_DIR_BIN, _BB_SUID_DROP))
     13//applet:IF_CONSPY(APPLET(conspy, BB_DIR_BIN, BB_SUID_DROP))
    1414
    1515//kbuild:lib-$(CONFIG_CONSPY) += conspy.o
     
    1717//config:config CONSPY
    1818//config:   bool "conspy"
    19 //config:   default n
    20 //config:   depends on PLATFORM_LINUX
     19//config:   default y
     20//config:   select PLATFORM_LINUX
    2121//config:   help
    2222//config:     A text-mode VNC like program for Linux virtual terminals.
     
    2626
    2727//usage:#define conspy_trivial_usage
    28 //usage:    "[-vcsndf] [-x COL] [-y LINE] [CONSOLE_NO]"
     28//usage:    "[-vcsndfFQ] [-x COL] [-y LINE] [CONSOLE_NO]"
    2929//usage:#define conspy_full_usage "\n\n"
    3030//usage:     "A text-mode VNC like program for Linux virtual consoles."
    3131//usage:     "\nTo exit, quickly press ESC 3 times."
    3232//usage:     "\n"
    33 //usage:     "\nOptions:"
    3433//usage:     "\n    -v  Don't send keystrokes to the console"
    35 //usage:     "\n    -c  Create missing devices in /dev"
     34//usage:     "\n    -c  Create missing /dev/{tty,vcsa}N"
    3635//usage:     "\n    -s  Open a SHELL session"
    3736//usage:     "\n    -n  Black & white"
    3837//usage:     "\n    -d  Dump console to stdout"
    3938//usage:     "\n    -f  Follow cursor"
     39//usage:     "\n    -F  Assume console is on a framebuffer device"
     40//usage:     "\n    -Q  Disable exit on ESC-ESC-ESC"
    4041//usage:     "\n    -x COL  Starting column"
    4142//usage:     "\n    -y LINE Starting line"
     
    4445#include <sys/kd.h>
    4546
    46 
    4747#define ESC "\033"
     48#define CURSOR_ON   -1
     49#define CURSOR_OFF  1
     50
     51#define DEV_TTY     "/dev/tty"
     52#define DEV_VCSA    "/dev/vcsa"
    4853
    4954struct screen_info {
     
    7479    unsigned line;
    7580    smallint curoff; // unknown:0 cursor on:-1 cursor off:1
    76     char attrbuf[sizeof(ESC"[0;1;5;30;40m")];
     81    char attrbuf[sizeof("0;1;5;30;40m")];
    7782    // remote console
    7883    struct screen_info remote;
    7984    // saved local tty terminfo
    8085    struct termios term_orig;
    81     char vcsa_name[sizeof("/dev/vcsaNN")];
     86    char vcsa_name[sizeof(DEV_VCSA "NN")];
    8287};
    8388
     
    8590#define INIT_G() do { \
    8691    SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
    87     G.attrbuf[0] = '\033'; \
    88     G.attrbuf[1] = '['; \
    8992    G.width = G.height = UINT_MAX; \
    9093    G.last_attr--; \
     
    9497    FLAG_v,  // view only
    9598    FLAG_c,  // create device if need
     99    FLAG_Q,  // never exit
    96100    FLAG_s,  // session
    97101    FLAG_n,  // no colors
    98102    FLAG_d,  // dump screen
    99103    FLAG_f,  // follow cursor
     104    FLAG_F,  // framebuffer
    100105};
    101106#define FLAG(x) (1 << FLAG_##x)
    102107#define BW (option_mask32 & FLAG(n))
    103108
     109static void putcsi(const char *s)
     110{
     111    fputs(ESC"[", stdout);
     112    fputs(s, stdout);
     113}
     114
    104115static void clrscr(void)
    105116{
    106117    // Home, clear till end of screen
    107     fputs(ESC"[1;1H" ESC"[J", stdout);
     118    putcsi("1;1H" ESC"[J");
    108119    G.col = G.line = 0;
    109120}
     
    113124    if (G.curoff != state) {
    114125        G.curoff = state;
    115         fputs(ESC"[?25", stdout);
     126        putcsi("?25");
    116127        bb_putchar("h?l"[1 + state]);
    117128    }
     
    127138}
    128139
     140static void cleanup(int code) NORETURN;
    129141static void cleanup(int code)
    130142{
    131     set_cursor(-1); // cursor on
     143    set_cursor(CURSOR_ON);
    132144    tcsetattr(G.kbd_fd, TCSANOW, &G.term_orig);
    133145    if (ENABLE_FEATURE_CLEAN_UP) {
     
    136148    // Reset attributes
    137149    if (!BW)
    138         fputs(ESC"[0m", stdout);
     150        putcsi("0m");
    139151    bb_putchar('\n');
    140     if (code > 1)
     152    if (code > EXIT_FAILURE)
    141153        kill_myself_with_sig(code);
    142154    exit(code);
     
    159171        G.data = xzalloc(2 * i);
    160172    }
    161     else if (G.size != i) {
    162         cleanup(1);
     173    if (G.size != i) {
     174        cleanup(EXIT_FAILURE);
    163175    }
    164176    data = G.data + G.current;
     
    170182            unsigned y = i - G.y; // if will catch i < G.y too
    171183
    172             if (CHAR(data) < ' ')
    173                 CHAR(data) = ' ';
    174184            if (y >= G.height || x >= G.width)
    175185                DATA(data) = 0;
     186            else {
     187                uint8_t ch = CHAR(data);
     188                if (ch < ' ')
     189                    CHAR(data) = ch | 0x40;
     190                else if (ch > 0x7e)
     191                    CHAR(data) = '?';
     192            }
    176193        }
    177194    }
     
    181198{
    182199    if (!BW) {
     200        uint8_t attr_diff;
    183201        uint8_t attr = ATTR(data);
    184         //uint8_t attr = ATTR(data) >> 1; // for framebuffer console
    185         uint8_t attr_diff = G.last_attr ^ attr;
    186 
     202
     203        if (option_mask32 & FLAG(F)) {
     204            attr >>= 1;
     205        }
     206        attr_diff = G.last_attr ^ attr;
    187207        if (attr_diff) {
    188208// Attribute layout for VGA compatible text videobuffer:
     
    215235            char *ptr;
    216236
    217             ptr = G.attrbuf + 2; // skip "ESC ["
     237            ptr = G.attrbuf;
    218238
    219239            // (G.last_attr & ~attr) has 1 only where
     
    246266                *ptr++ = '4';
    247267                *ptr++ = color[(attr & bg_mask) >> 4];
    248                 *ptr++ = ';';
    249             }
    250             if (ptr != G.attrbuf + 2) {
     268                ptr++; // last attribute
     269            }
     270            if (ptr != G.attrbuf) {
    251271                ptr[-1] = 'm';
    252272                *ptr = '\0';
    253                 fputs(G.attrbuf, stdout);
     273                putcsi(G.attrbuf);
    254274            }
    255275        }
     
    294314    unsigned cx = G.remote.cursor_x - G.x;
    295315    unsigned cy = G.remote.cursor_y - G.y;
    296     int cursor = 1;
     316    int cursor = CURSOR_OFF;
    297317
    298318    if (cx < G.width && cy < G.height) {
    299319        gotoxy(cx, cy);
    300         cursor = -1;
     320        cursor = CURSOR_ON;
    301321    }
    302322    set_cursor(cursor);
     
    317337    if (pid == 0) {
    318338        struct termios termchild;
    319         char *shell = getenv("SHELL");
    320 
    321         if (!shell)
    322             shell = (char *) DEFAULT_SHELL;
     339        const char *shell = get_shell_name();
     340
    323341        signal(SIGHUP, SIG_IGN);
    324342        // set tty as a controlling tty
     
    345363int conspy_main(int argc UNUSED_PARAM, char **argv)
    346364{
    347     char tty_name[sizeof("/dev/ttyNN")];
     365    char tty_name[sizeof(DEV_TTY "NN")];
    348366#define keybuf bb_common_bufsiz1
    349367    struct termios termbuf;
     
    355373        "viewonly\0"     No_argument "v"
    356374        "createdevice\0" No_argument "c"
     375        "neverquit\0"    No_argument "Q"
    357376        "session\0"      No_argument "s"
    358377        "nocolors\0"     No_argument "n"
    359378        "dump\0"         No_argument "d"
    360379        "follow\0"       No_argument "f"
     380        "framebuffer\0"  No_argument "F"
    361381        ;
    362382
     
    364384#endif
    365385    INIT_G();
    366     strcpy(G.vcsa_name, "/dev/vcsa");
     386    strcpy(G.vcsa_name, DEV_VCSA);
    367387
    368388    opt_complementary = "x+:y+"; // numeric params
    369     opts = getopt32(argv, "vcsndfx:y:", &G.x, &G.y);
     389    opts = getopt32(argv, "vcQsndfFx:y:", &G.x, &G.y);
    370390    argv += optind;
    371391    ttynum = 0;
    372392    if (argv[0]) {
    373393        ttynum = xatou_range(argv[0], 0, 63);
    374         sprintf(G.vcsa_name + sizeof("/dev/vcsa")-1, "%u", ttynum);
    375     }
    376     sprintf(tty_name, "%s%u", "/dev/tty", ttynum);
     394        sprintf(G.vcsa_name + sizeof(DEV_VCSA)-1, "%u", ttynum);
     395    }
     396    sprintf(tty_name, "%s%u", DEV_TTY, ttynum);
    377397    if (opts & FLAG(c)) {
    378398        if ((opts & (FLAG(s)|FLAG(v))) != FLAG(v))
     
    485505        case -1:
    486506            if (errno != EINTR)
    487                 cleanup(1);
     507                goto abort;
    488508            break;
    489509        case 0:
     
    496516            bytes_read = read(G.kbd_fd, k, sizeof(keybuf) - G.key_count);
    497517            if (bytes_read < 0)
    498                 cleanup(1);
     518                goto abort;
    499519
    500520            // Do exit processing
    501             for (i = 0; i < bytes_read; i++) {
    502                 if (k[i] != '\033')
    503                     G.escape_count = 0;
    504                 else if (++G.escape_count >= 3)
    505                     cleanup(0);
     521            if (!(option_mask32 & FLAG(Q))) {
     522                for (i = 0; i < bytes_read; i++) {
     523                    if (k[i] != '\033')
     524                        G.escape_count = -1;
     525                    if (++G.escape_count >= 3)
     526                        cleanup(EXIT_SUCCESS);
     527                }
    506528            }
    507529        }
    508530        poll_timeout_ms = 250;
     531        if (option_mask32 & FLAG(v)) continue;
    509532
    510533        // Insert all keys pressed into the virtual console's input
     
    512535        // code mode - giving ASCII characters to a program expecting
    513536        // scan codes will confuse it.
    514         if (!(option_mask32 & FLAG(v)) && G.escape_count == 0) {
     537        G.key_count += bytes_read;
     538        if (G.escape_count == 0) {
    515539            int handle, result;
    516540            long kbd_mode;
    517541
    518             G.key_count += bytes_read;
    519542            handle = xopen(tty_name, O_WRONLY);
    520543            result = ioctl(handle, KDGKBMODE, &kbd_mode);
     
    522545                char *p = keybuf;
    523546
     547                G.ioerror_count = 0;
    524548                if (kbd_mode != K_XLATE && kbd_mode != K_UNICODE) {
    525549                    G.key_count = 0; // scan code mode
     
    537561                }
    538562            }
     563            // We sometimes get spurious IO errors on the TTY
     564            // as programs close and re-open it
     565            else if (errno != EIO || ++G.ioerror_count > 4) {
     566                if (ENABLE_FEATURE_CLEAN_UP)
     567                    close(handle);
     568                goto abort;
     569            }
    539570            // Close & re-open tty in case they have
    540571            // swapped virtual consoles
    541572            close(handle);
    542 
    543             // We sometimes get spurious IO errors on the TTY
    544             // as programs close and re-open it
    545             if (result >= 0)
    546                 G.ioerror_count = 0;
    547             else if (errno != EIO || ++G.ioerror_count > 4)
    548                 cleanup(1);
    549573        }
    550574    } /* while (1) */
    551 }
     575  abort:
     576    cleanup(EXIT_FAILURE);
     577}
  • branches/3.2/mindi-busybox/miscutils/crond.c

    r2725 r3232  
    1111 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1212 */
     13
     14//usage:#define crond_trivial_usage
     15//usage:       "-fbS -l N " IF_FEATURE_CROND_D("-d N ") "-L LOGFILE -c DIR"
     16//usage:#define crond_full_usage "\n\n"
     17//usage:       "    -f  Foreground"
     18//usage:     "\n    -b  Background (default)"
     19//usage:     "\n    -S  Log to syslog (default)"
     20//usage:     "\n    -l  Set log level. 0 is the most verbose, default 8"
     21//usage:    IF_FEATURE_CROND_D(
     22//usage:     "\n    -d  Set log level, log to stderr"
     23//usage:    )
     24//usage:     "\n    -L  Log to file"
     25//usage:     "\n    -c  Working dir"
    1326
    1427#include "libbb.h"
     
    849862    /* "-b after -f is ignored", and so on for every pair a-b */
    850863    opt_complementary = "f-b:b-f:S-L:L-S" IF_FEATURE_CROND_D(":d-l")
    851             ":l+:d+"; /* -l and -d have numeric param */
     864            /* -l and -d have numeric param */
     865            ":l+" IF_FEATURE_CROND_D(":d+");
    852866    opts = getopt32(argv, "l:L:fbSc:" IF_FEATURE_CROND_D("d:"),
    853867            &G.log_level, &G.log_filename, &G.crontab_dir_name
     
    872886    crondlog(LVL8 "crond (busybox "BB_VER") started, log level %d", G.log_level);
    873887    rescan_crontab_dir();
    874     write_pidfile("/var/run/crond.pid");
     888    write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid");
    875889
    876890    /* Main loop */
  • branches/3.2/mindi-busybox/miscutils/crontab.c

    r2725 r3232  
    1111 */
    1212
     13//usage:#define crontab_trivial_usage
     14//usage:       "[-c DIR] [-u USER] [-ler]|[FILE]"
     15//usage:#define crontab_full_usage "\n\n"
     16//usage:       "    -c  Crontab directory"
     17//usage:     "\n    -u  User"
     18//usage:     "\n    -l  List crontab"
     19//usage:     "\n    -e  Edit crontab"
     20//usage:     "\n    -r  Delete crontab"
     21//usage:     "\n    FILE    Replace crontab by FILE ('-': stdin)"
     22
    1323#include "libbb.h"
    1424
     
    2131{
    2232    const char *ptr;
    23     int pid = xvfork();
    24 
     33    pid_t pid;
     34
     35    pid = xvfork();
    2536    if (pid) { /* parent */
    2637        wait4pid(pid);
     
    3142    /* initgroups, setgid, setuid */
    3243    change_identity(pas);
    33     setup_environment(DEFAULT_SHELL,
     44    setup_environment(pas->pw_shell,
    3445            SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP,
    3546            pas);
     
    4253
    4354    BB_EXECLP(ptr, ptr, file, NULL);
    44     bb_perror_msg_and_die("exec %s", ptr);
     55    bb_perror_msg_and_die("can't execute '%s'", ptr);
    4556}
    4657
  • branches/3.2/mindi-busybox/miscutils/dc.c

    r2725 r3232  
    1212//usage:#define dc_full_usage "\n\n"
    1313//usage:       "Tiny RPN calculator. Operations:\n"
    14 //usage:       "+, add, -, sub, *, mul, /, div, %, mod, **, exp, and, or, not, eor,\n"
     14//usage:       "+, add, -, sub, *, mul, /, div, %, mod, "IF_FEATURE_DC_LIBM("**, exp, ")"and, or, not, xor,\n"
    1515//usage:       "p - print top of the stack (without popping),\n"
    1616//usage:       "f - print entire stack,\n"
    1717//usage:       "o - pop the value and set output radix (must be 10, 16, 8 or 2).\n"
    18 //usage:       "Examples: 'dc 2 2 add' -> 4, 'dc 8 8 * 2 2 + /' -> 16"
     18//usage:       "Examples: 'dc 2 2 add p' -> 4, 'dc 8 8 mul 2 2 + / p' -> 16"
    1919//usage:
    2020//usage:#define dc_example_usage
     
    220220    {"f", print_stack_no_pop},
    221221    {"o", set_output_base},
    222     { "", NULL }
    223222};
    224223
    225224static void stack_machine(const char *argument)
    226225{
    227     char *endPointer;
     226    char *end;
    228227    double d;
    229     const struct op *o = operators;
    230 
    231     d = strtod(argument, &endPointer);
    232 
    233     if (endPointer != argument && *endPointer == '\0') {
     228    const struct op *o;
     229
     230    d = strtod(argument, &end);
     231    if (end != argument && *end == '\0') {
    234232        push(d);
    235233        return;
    236234    }
    237235
    238     while (o->function) {
     236    o = operators;
     237    do {
    239238        if (strcmp(o->name, argument) == 0) {
    240239            o->function();
     
    242241        }
    243242        o++;
    244     }
     243    } while (o != operators + ARRAY_SIZE(operators));
     244
    245245    bb_error_msg_and_die("syntax error at '%s'", argument);
    246 }
    247 
    248 /* return pointer to next token in buffer and set *buffer to one char
    249  * past the end of the above mentioned token
    250  */
    251 static char *get_token(char **buffer)
    252 {
    253     char *current = skip_whitespace(*buffer);
    254     if (*current != '\0') {
    255         *buffer = skip_non_whitespace(current);
    256         return current;
    257     }
    258     return NULL;
    259246}
    260247
     
    273260            cursor = line;
    274261            while (1) {
    275                 token = get_token(&cursor);
    276                 if (!token)
     262                token = skip_whitespace(cursor);
     263                if (*token == '\0')
    277264                    break;
    278                 *cursor++ = '\0';
     265                cursor = skip_non_whitespace(token);
     266                if (*cursor != '\0')
     267                    *cursor++ = '\0';
    279268                stack_machine(token);
    280269            }
     
    282271        }
    283272    } else {
    284         // why? it breaks "dc -2 2 * p"
     273        // why? it breaks "dc -2 2 + p"
    285274        //if (argv[0][0] == '-')
    286275        //  bb_show_usage();
  • branches/3.2/mindi-busybox/miscutils/devfsd.c

    r2725 r3232  
    5454      Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
    5555*/
     56
     57//usage:#define devfsd_trivial_usage
     58//usage:       "mntpnt [-v]" IF_DEVFSD_FG_NP("[-fg][-np]")
     59//usage:#define devfsd_full_usage "\n\n"
     60//usage:       "Manage devfs permissions and old device name symlinks\n"
     61//usage:     "\n    mntpnt  The mount point where devfs is mounted"
     62//usage:     "\n    -v  Print the protocol version numbers for devfsd"
     63//usage:     "\n        and the kernel-side protocol version and exit"
     64//usage:    IF_DEVFSD_FG_NP(
     65//usage:     "\n    -fg Run in foreground"
     66//usage:     "\n    -np Exit after parsing the configuration file"
     67//usage:     "\n        and processing synthetic REGISTER events,"
     68//usage:     "\n        don't poll for events"
     69//usage:    )
     70
    5671#include "libbb.h"
    5772#include "xregex.h"
     
    205220static void action_modload(const struct devfsd_notify_struct *info, const struct config_entry_struct *entry);
    206221static void action_copy(const struct devfsd_notify_struct *, const struct config_entry_struct *,
    207                          const regmatch_t *, unsigned);
     222                        const regmatch_t *, unsigned);
    208223static void action_compat(const struct devfsd_notify_struct *, unsigned);
    209224static void free_config(void);
     
    215230static int make_dir_tree(const char *);
    216231static int expand_expression(char *, unsigned, const char *, const char *(*)(const char *, void *), void *,
    217                              const char *, const regmatch_t *, unsigned);
     232                            const char *, const regmatch_t *, unsigned);
    218233static void expand_regexp(char *, size_t, const char *, const char *, const regmatch_t *, unsigned);
    219234static const char *expand_variable( char *, unsigned, unsigned *, const char *,
    220235                                    const char *(*)(const char *, void *), void *);
    221236static const char *get_variable_v2(const char *, const char *(*)(const char *, void *), void *);
    222 static char get_old_ide_name(unsigned , unsigned);
     237static char get_old_ide_name(unsigned, unsigned);
    223238static char *write_old_sd_name(char *, unsigned, unsigned, const char *);
    224239
     
    566581            the device name) to the module loading  facility.  In  addition,
    567582            the /etc/modules.devfs configuration file is used.*/
    568              if (ENABLE_DEVFSD_MODLOAD)
     583            if (ENABLE_DEVFSD_MODLOAD)
    569584                new->action.what = AC_MODLOAD;
    570              break;
     585            break;
    571586        case 6: /* EXECUTE */
    572587            new->action.what = AC_EXECUTE;
     
    736751
    737752static void action_modload(const struct devfsd_notify_struct *info,
    738                 const struct config_entry_struct *entry UNUSED_PARAM)
     753            const struct config_entry_struct *entry UNUSED_PARAM)
    739754/*  [SUMMARY] Load a module.
    740755    <info> The devfs change.
     
    757772
    758773static void action_execute(const struct devfsd_notify_struct *info,
    759                 const struct config_entry_struct *entry,
    760                 const regmatch_t *regexpr, unsigned int numexpr)
     774            const struct config_entry_struct *entry,
     775            const regmatch_t *regexpr, unsigned int numexpr)
    761776/*  [SUMMARY] Execute a programme.
    762777    <info> The devfs change.
     
    789804
    790805static void action_copy(const struct devfsd_notify_struct *info,
    791              const struct config_entry_struct *entry,
    792              const regmatch_t *regexpr, unsigned int numexpr)
     806            const struct config_entry_struct *entry,
     807            const regmatch_t *regexpr, unsigned int numexpr)
    793808/*  [SUMMARY] Copy permissions.
    794809    <info> The devfs change.
     
    12451260
    12461261static int expand_expression(char *output, unsigned int outsize,
    1247                   const char *input,
    1248                   const char *(*get_variable_func)(const char *variable, void *info),
    1249                   void *info,
    1250                   const char *devname,
    1251                   const regmatch_t *ex, unsigned int numexp)
     1262            const char *input,
     1263            const char *(*get_variable_func)(const char *variable, void *info),
     1264            void *info,
     1265            const char *devname,
     1266            const regmatch_t *ex, unsigned int numexp)
    12521267/*  [SUMMARY] Expand environment variables and regular subexpressions in string.
    12531268    <output> The output expanded expression is written here.
     
    12741289
    12751290static void expand_regexp(char *output, size_t outsize, const char *input,
    1276                const char *devname,
    1277                const regmatch_t *ex, unsigned int numex)
     1291            const char *devname,
     1292            const regmatch_t *ex, unsigned int numex)
    12781293/*  [SUMMARY] Expand all occurrences of the regular subexpressions \0 to \9.
    12791294    <output> The output expanded expression is written here.
     
    13711386
    13721387const char *get_old_name(const char *devname, unsigned int namelen,
    1373               char *buffer, unsigned int major, unsigned int minor)
     1388            char *buffer, unsigned int major, unsigned int minor)
    13741389/*  [SUMMARY] Translate a kernel-supplied name into an old name.
    13751390    <devname> The device name provided by the kernel.
     
    14091424
    14101425    for (trans = translate_table; trans->match != NULL; ++trans) {
    1411          len = strlen(trans->match);
     1426        len = strlen(trans->match);
    14121427
    14131428        if (strncmp(devname, trans->match, len) == 0) {
     
    15351550
    15361551int st_expr_expand(char *output, unsigned int length, const char *input,
    1537              const char *(*get_variable_func)(const char *variable,
    1538                           void *info),
    1539              void *info)
     1552        const char *(*get_variable_func)(const char *variable,
     1553                        void *info),
     1554        void *info)
    15401555/*  [SUMMARY] Expand an expression using Borne Shell-like unquoted rules.
    15411556    <output> The output expanded expression is written here.
     
    16271642
    16281643static const char *expand_variable(char *buffer, unsigned int length,
    1629                     unsigned int *out_pos, const char *input,
    1630                     const char *(*func)(const char *variable,
    1631                              void *info),
    1632                     void *info)
     1644                unsigned int *out_pos, const char *input,
     1645                const char *(*func)(const char *variable,
     1646                            void *info),
     1647                void *info)
    16331648/*  [SUMMARY] Expand a variable.
    16341649    <buffer> The buffer to write to.
     
    17721787
    17731788static const char *get_variable_v2(const char *variable,
    1774                   const char *(*func)(const char *variable, void *info),
    1775                  void *info)
     1789                const char *(*func)(const char *variable, void *info),
     1790                void *info)
    17761791/*  [SUMMARY] Get a variable from the environment or .
    17771792    <variable> The variable name.
  • branches/3.2/mindi-busybox/miscutils/devmem.c

    r2725 r3232  
    44 *  Copyright (C) 2008, BusyBox Team. -solar 4/26/08
    55 */
     6
     7//usage:#define devmem_trivial_usage
     8//usage:    "ADDRESS [WIDTH [VALUE]]"
     9//usage:#define devmem_full_usage "\n\n"
     10//usage:       "Read/write from physical address\n"
     11//usage:     "\n    ADDRESS Address to act upon"
     12//usage:     "\n    WIDTH   Width (8/16/...)"
     13//usage:     "\n    VALUE   Data to be written"
    614
    715#include "libbb.h"
  • branches/3.2/mindi-busybox/miscutils/eject.c

    r2725 r3232  
    1313 * Most of the dirty work blatantly ripped off from cat.c =)
    1414 */
     15
     16//usage:#define eject_trivial_usage
     17//usage:       "[-t] [-T] [DEVICE]"
     18//usage:#define eject_full_usage "\n\n"
     19//usage:       "Eject DEVICE or default /dev/cdrom\n"
     20//usage:    IF_FEATURE_EJECT_SCSI(
     21//usage:     "\n    -s  SCSI device"
     22//usage:    )
     23//usage:     "\n    -t  Close tray"
     24//usage:     "\n    -T  Open/close tray (toggle)"
    1525
    1626#include <sys/mount.h>
  • branches/3.2/mindi-busybox/miscutils/fbsplash.c

    r2725 r3232  
    2222 */
    2323
     24//usage:#define fbsplash_trivial_usage
     25//usage:       "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]"
     26//usage:#define fbsplash_full_usage "\n\n"
     27//usage:       "    -s  Image"
     28//usage:     "\n    -c  Hide cursor"
     29//usage:     "\n    -d  Framebuffer device (default /dev/fb0)"
     30//usage:     "\n    -i  Config file (var=value):"
     31//usage:     "\n            BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT"
     32//usage:     "\n            BAR_R,BAR_G,BAR_B"
     33//usage:     "\n    -f  Control pipe (else exit after drawing image)"
     34//usage:     "\n            commands: 'NN' (% for progress bar) or 'exit'"
     35
    2436#include "libbb.h"
    2537#include <linux/fb.h>
     
    2739/* If you want logging messages on /tmp/fbsplash.log... */
    2840#define DEBUG 0
    29 
    30 #define BYTES_PER_PIXEL 2
    31 
    32 typedef unsigned short DATA;
    3341
    3442struct globals {
     
    4250    struct fb_var_screeninfo scr_var;
    4351    struct fb_fix_screeninfo scr_fix;
     52    unsigned bytes_per_pixel;
     53    // cached (8 - scr_var.COLOR.length):
     54    unsigned red_shift;
     55    unsigned green_shift;
     56    unsigned blue_shift;
    4457};
    4558#define G (*ptr_to_globals)
     
    6679#endif
    6780
    68 
    69 /**
    70  *  Open and initialize the framebuffer device
     81/**
     82 * Configure palette for RGB:332
     83 */
     84static void fb_setpal(int fd)
     85{
     86    struct fb_cmap cmap;
     87    /* fb colors are 16 bit */
     88    unsigned short red[256], green[256], blue[256];
     89    unsigned i;
     90
     91    /* RGB:332 */
     92    for (i = 0; i < 256; i++) {
     93        /* Color is encoded in pixel value as rrrgggbb.
     94         * 3-bit color is mapped to 16-bit one as:
     95         * 000 -> 00000000 00000000
     96         * 001 -> 00100100 10010010
     97         * ...
     98         * 011 -> 01101101 10110110
     99         * 100 -> 10010010 01001001
     100         * ...
     101         * 111 -> 11111111 11111111
     102         */
     103        red[i]   = (( i >> 5       ) * 0x9249) >> 2; // rrr * 00 10010010 01001001 >> 2
     104        green[i] = (((i >> 2) & 0x7) * 0x9249) >> 2; // ggg * 00 10010010 01001001 >> 2
     105        /* 2-bit color is easier: */
     106        blue[i]  =  ( i       & 0x3) * 0x5555; // bb * 01010101 01010101
     107    }
     108
     109    cmap.start = 0;
     110    cmap.len   = 256;
     111    cmap.red   = red;
     112    cmap.green = green;
     113    cmap.blue  = blue;
     114    cmap.transp = 0;
     115
     116    xioctl(fd, FBIOPUTCMAP, &cmap);
     117}
     118
     119/**
     120 * Open and initialize the framebuffer device
    71121 * \param *strfb_device pointer to framebuffer device
    72122 */
     
    79129    xioctl(fbfd, FBIOGET_FSCREENINFO, &G.scr_fix);
    80130
    81     if (G.scr_var.bits_per_pixel != 16)
    82         bb_error_msg_and_die("only 16 bpp is supported");
     131    switch (G.scr_var.bits_per_pixel) {
     132    case 8:
     133        fb_setpal(fbfd);
     134        break;
     135
     136    case 16:
     137    case 24:
     138    case 32:
     139        break;
     140
     141    default:
     142        bb_error_msg_and_die("unsupported %u bpp", (int)G.scr_var.bits_per_pixel);
     143        break;
     144    }
     145
     146    G.red_shift   = 8 - G.scr_var.red.length;
     147    G.green_shift = 8 - G.scr_var.green.length;
     148    G.blue_shift  = 8 - G.scr_var.blue.length;
     149    G.bytes_per_pixel = (G.scr_var.bits_per_pixel + 7) >> 3;
    83150
    84151    // map the device in memory
    85152    G.addr = mmap(NULL,
    86             G.scr_var.xres * G.scr_var.yres
    87             * BYTES_PER_PIXEL /*(G.scr_var.bits_per_pixel / 8)*/,
     153            G.scr_var.yres * G.scr_fix.line_length,
    88154            PROT_WRITE, MAP_SHARED, fbfd, 0);
    89155    if (G.addr == MAP_FAILED)
    90156        bb_perror_msg_and_die("mmap");
     157
     158    // point to the start of the visible screen
     159    G.addr += G.scr_var.yoffset * G.scr_fix.line_length + G.scr_var.xoffset * G.bytes_per_pixel;
    91160    close(fbfd);
    92161}
     
    94163
    95164/**
    96  *  Draw hollow rectangle on framebuffer
     165 * Return pixel value of the passed RGB color.
     166 * This is performance critical fn.
     167 */
     168static unsigned fb_pixel_value(unsigned r, unsigned g, unsigned b)
     169{
     170    /* We assume that the r,g,b values are <= 255 */
     171
     172    if (G.bytes_per_pixel == 1) {
     173        r = r        & 0xe0; // 3-bit red
     174        g = (g >> 3) & 0x1c; // 3-bit green
     175        b =  b >> 6;         // 2-bit blue
     176        return r + g + b;
     177    }
     178    if (G.bytes_per_pixel == 2) {
     179        // ARM PL110 on Integrator/CP has RGBA5551 bit arrangement.
     180        // We want to support bit locations like that.
     181        //
     182        // First shift out unused bits
     183        r = r >> G.red_shift;
     184        g = g >> G.green_shift;
     185        b = b >> G.blue_shift;
     186        // Then shift the remaining bits to their offset
     187        return (r << G.scr_var.red.offset) +
     188            (g << G.scr_var.green.offset) +
     189            (b << G.scr_var.blue.offset);
     190    }
     191    // RGB 888
     192    return b + (g << 8) + (r << 16);
     193}
     194
     195/**
     196 * Draw pixel on framebuffer
     197 */
     198static void fb_write_pixel(unsigned char *addr, unsigned pixel)
     199{
     200    switch (G.bytes_per_pixel) {
     201    case 1:
     202        *addr = pixel;
     203        break;
     204    case 2:
     205        *(uint16_t *)addr = pixel;
     206        break;
     207    case 4:
     208        *(uint32_t *)addr = pixel;
     209        break;
     210    default: // 24 bits per pixel
     211        addr[0] = pixel;
     212        addr[1] = pixel >> 8;
     213        addr[2] = pixel >> 16;
     214    }
     215}
     216
     217
     218/**
     219 * Draw hollow rectangle on framebuffer
    97220 */
    98221static void fb_drawrectangle(void)
    99222{
    100223    int cnt;
    101     DATA thispix;
    102     DATA *ptr1, *ptr2;
     224    unsigned thispix;
     225    unsigned char *ptr1, *ptr2;
    103226    unsigned char nred = G.nbar_colr/2;
    104227    unsigned char ngreen =  G.nbar_colg/2;
    105228    unsigned char nblue = G.nbar_colb/2;
    106229
    107     nred   >>= 3;  // 5-bit red
    108     ngreen >>= 2;  // 6-bit green
    109     nblue  >>= 3;  // 5-bit blue
    110     thispix = nblue + (ngreen << 5) + (nred << (5+6));
     230    thispix = fb_pixel_value(nred, ngreen, nblue);
    111231
    112232    // horizontal lines
    113     ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
    114     ptr2 = (DATA*)(G.addr + ((G.nbar_posy + G.nbar_height - 1) * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
     233    ptr1 = G.addr + G.nbar_posy * G.scr_fix.line_length + G.nbar_posx * G.bytes_per_pixel;
     234    ptr2 = G.addr + (G.nbar_posy + G.nbar_height - 1) * G.scr_fix.line_length + G.nbar_posx * G.bytes_per_pixel;
    115235    cnt = G.nbar_width - 1;
    116236    do {
    117         *ptr1++ = thispix;
    118         *ptr2++ = thispix;
     237        fb_write_pixel(ptr1, thispix);
     238        fb_write_pixel(ptr2, thispix);
     239        ptr1 += G.bytes_per_pixel;
     240        ptr2 += G.bytes_per_pixel;
    119241    } while (--cnt >= 0);
    120242
    121243    // vertical lines
    122     ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
    123     ptr2 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx + G.nbar_width - 1) * BYTES_PER_PIXEL);
     244    ptr1 = G.addr + G.nbar_posy * G.scr_fix.line_length + G.nbar_posx * G.bytes_per_pixel;
     245    ptr2 = G.addr + G.nbar_posy * G.scr_fix.line_length + (G.nbar_posx + G.nbar_width - 1) * G.bytes_per_pixel;
    124246    cnt = G.nbar_height - 1;
    125247    do {
    126         *ptr1 = thispix; ptr1 += G.scr_var.xres;
    127         *ptr2 = thispix; ptr2 += G.scr_var.xres;
     248        fb_write_pixel(ptr1, thispix);
     249        fb_write_pixel(ptr2, thispix);
     250        ptr1 += G.scr_fix.line_length;
     251        ptr2 += G.scr_fix.line_length;
    128252    } while (--cnt >= 0);
    129253}
     
    131255
    132256/**
    133  *  Draw filled rectangle on framebuffer
     257 * Draw filled rectangle on framebuffer
    134258 * \param nx1pos,ny1pos upper left position
    135259 * \param nx2pos,ny2pos down right position
     
    140264{
    141265    int cnt1, cnt2, nypos;
    142     DATA thispix;
    143     DATA *ptr;
    144 
    145     nred   >>= 3;  // 5-bit red
    146     ngreen >>= 2;  // 6-bit green
    147     nblue  >>= 3;  // 5-bit blue
    148     thispix = nblue + (ngreen << 5) + (nred << (5+6));
     266    unsigned thispix;
     267    unsigned char *ptr;
     268
     269    thispix = fb_pixel_value(nred, ngreen, nblue);
    149270
    150271    cnt1 = ny2pos - ny1pos;
    151272    nypos = ny1pos;
    152273    do {
    153         ptr = (DATA*)(G.addr + (nypos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL);
     274        ptr = G.addr + nypos * G.scr_fix.line_length + nx1pos * G.bytes_per_pixel;
    154275        cnt2 = nx2pos - nx1pos;
    155276        do {
    156             *ptr++ = thispix;
     277            fb_write_pixel(ptr, thispix);
     278            ptr += G.bytes_per_pixel;
    157279        } while (--cnt2 >= 0);
    158280
     
    163285
    164286/**
    165  *  Draw a progress bar on framebuffer
     287 * Draw a progress bar on framebuffer
    166288 * \param percent percentage of loading
    167289 */
    168290static void fb_drawprogressbar(unsigned percent)
    169291{
    170     int i, left_x, top_y, width, height;
     292    int left_x, top_y, pos_x;
     293    unsigned width, height;
    171294
    172295    // outer box
     
    175298    width = G.nbar_width - 1;
    176299    height = G.nbar_height - 1;
    177     if ((height | width) < 0)
     300    if ((int)(height | width) < 0)
    178301        return;
    179302    // NB: "width" of 1 actually makes rect with width of 2!
     
    185308    width -= 2;
    186309    height -= 2;
    187     if ((height | width) < 0)
     310    if ((int)(height | width) < 0)
    188311        return;
    189     fb_drawfullrectangle(
    190             left_x, top_y,
    191                     left_x + width, top_y + height,
    192             G.nbar_colr, G.nbar_colg, G.nbar_colb);
    193 
     312
     313    pos_x = left_x;
    194314    if (percent > 0) {
     315        int i, y;
     316
    195317        // actual progress bar
    196         width = width * percent / 100;
     318        pos_x += (unsigned)(width * percent) / 100;
     319
     320        y = top_y;
    197321        i = height;
    198322        if (height == 0)
     
    201325            // draw one-line thick "rectangle"
    202326            // top line will have gray lvl 200, bottom one 100
    203             unsigned gray_level = 100 + i*100/height;
     327            unsigned gray_level = 100 + (unsigned)i*100 / height;
    204328            fb_drawfullrectangle(
    205                     left_x, top_y, left_x + width, top_y,
     329                    left_x, y, pos_x, y,
    206330                    gray_level, gray_level, gray_level);
    207             top_y++;
     331            y++;
    208332            i--;
    209333        }
    210334    }
    211 }
    212 
    213 
    214 /**
    215  *  Draw image from PPM file
     335
     336    fb_drawfullrectangle(
     337            pos_x, top_y,
     338            left_x + width, top_y + height,
     339            G.nbar_colr, G.nbar_colg, G.nbar_colb);
     340}
     341
     342
     343/**
     344 * Draw image from PPM file
    216345 */
    217346static void fb_drawimage(void)
     
    274403    for (j = 0; j < height; j++) {
    275404        unsigned char *pixel;
    276         DATA *src;
     405        unsigned char *src;
    277406
    278407        if (fread(pixline, 1, line_size, theme_file) != line_size)
    279408            bb_error_msg_and_die("bad PPM file '%s'", G.image_filename);
    280409        pixel = pixline;
    281         src = (DATA *)(G.addr + j * G.scr_fix.line_length);
     410        src = G.addr + j * G.scr_fix.line_length;
    282411        for (i = 0; i < width; i++) {
    283             unsigned thispix;
    284             thispix = (((unsigned)pixel[0] << 8) & 0xf800)
    285                 | (((unsigned)pixel[1] << 3) & 0x07e0)
    286                 | (((unsigned)pixel[2] >> 3));
    287             *src++ = thispix;
     412            unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]);
     413            fb_write_pixel(src, thispix);
     414            src += G.bytes_per_pixel;
    288415            pixel += 3;
    289416        }
     
    295422
    296423/**
    297  *  Parse configuration file
     424 * Parse configuration file
    298425 * \param *cfg_filename name of the configuration file
    299426 */
  • branches/3.2/mindi-busybox/miscutils/flash_eraseall.c

    r2725 r3232  
    1010 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1111 */
     12
     13//usage:#define flash_eraseall_trivial_usage
     14//usage:       "[-jq] MTD_DEVICE"
     15//usage:#define flash_eraseall_full_usage "\n\n"
     16//usage:       "Erase an MTD device\n"
     17//usage:     "\n    -j  Format the device for jffs2"
     18//usage:     "\n    -q  Don't display progress messages"
    1219
    1320#include "libbb.h"
  • branches/3.2/mindi-busybox/miscutils/flash_lock_unlock.c

    r2725 r3232  
    44 * Licensed under GPLv2, see file LICENSE in this source tree.
    55 */
     6
     7//usage:#define flash_lock_trivial_usage
     8//usage:       "MTD_DEVICE OFFSET SECTORS"
     9//usage:#define flash_lock_full_usage "\n\n"
     10//usage:       "Lock part or all of an MTD device. If SECTORS is -1, then all sectors\n"
     11//usage:       "will be locked, regardless of the value of OFFSET"
     12//usage:
     13//usage:#define flash_unlock_trivial_usage
     14//usage:       "MTD_DEVICE"
     15//usage:#define flash_unlock_full_usage "\n\n"
     16//usage:       "Unlock an MTD device"
     17
    618#include "libbb.h"
    719#include <mtd/mtd-user.h>
  • branches/3.2/mindi-busybox/miscutils/flashcp.c

    r2725 r3232  
    77 * Licensed under GPLv2, see file LICENSE in this source tree.
    88 */
     9
     10//usage:#define flashcp_trivial_usage
     11//usage:       "-v FILE MTD_DEVICE"
     12//usage:#define flashcp_full_usage "\n\n"
     13//usage:       "Copy an image to MTD device\n"
     14//usage:     "\n    -v  Verbose"
    915
    1016#include "libbb.h"
     
    4551    int i;
    4652    uoff_t erase_count;
    47     unsigned opts;
    4853    struct mtd_info_user mtd;
    4954    struct erase_info_user e;
     
    5459
    5560    opt_complementary = "=2"; /* exactly 2 non-option args: file, dev */
    56     opts = getopt32(argv, "v");
     61    /*opts =*/ getopt32(argv, "v");
    5762    argv += optind;
    5863//  filename = *argv++;
  • branches/3.2/mindi-busybox/miscutils/hdparm.c

    r2725 r3232  
    1212 *          - by Mark Lord (C) 1994-2002 -- freely distributable
    1313 */
     14
     15//usage:#define hdparm_trivial_usage
     16//usage:       "[OPTIONS] [DEVICE]"
     17//usage:#define hdparm_full_usage "\n\n"
     18//usage:       "    -a  Get/set fs readahead"
     19//usage:     "\n    -A  Set drive read-lookahead flag (0/1)"
     20//usage:     "\n    -b  Get/set bus state (0 == off, 1 == on, 2 == tristate)"
     21//usage:     "\n    -B  Set Advanced Power Management setting (1-255)"
     22//usage:     "\n    -c  Get/set IDE 32-bit IO setting"
     23//usage:     "\n    -C  Check IDE power mode status"
     24//usage:    IF_FEATURE_HDPARM_HDIO_GETSET_DMA(
     25//usage:     "\n    -d  Get/set using_dma flag")
     26//usage:     "\n    -D  Enable/disable drive defect-mgmt"
     27//usage:     "\n    -f  Flush buffer cache for device on exit"
     28//usage:     "\n    -g  Display drive geometry"
     29//usage:     "\n    -h  Display terse usage information"
     30//usage:    IF_FEATURE_HDPARM_GET_IDENTITY(
     31//usage:     "\n    -i  Display drive identification")
     32//usage:    IF_FEATURE_HDPARM_GET_IDENTITY(
     33//usage:     "\n    -I  Detailed/current information directly from drive")
     34//usage:     "\n    -k  Get/set keep_settings_over_reset flag (0/1)"
     35//usage:     "\n    -K  Set drive keep_features_over_reset flag (0/1)"
     36//usage:     "\n    -L  Set drive doorlock (0/1) (removable harddisks only)"
     37//usage:     "\n    -m  Get/set multiple sector count"
     38//usage:     "\n    -n  Get/set ignore-write-errors flag (0/1)"
     39//usage:     "\n    -p  Set PIO mode on IDE interface chipset (0,1,2,3,4,...)"
     40//usage:     "\n    -P  Set drive prefetch count"
     41/* //usage:  "\n    -q  Change next setting quietly" - not supported ib bbox */
     42//usage:     "\n    -Q  Get/set DMA tagged-queuing depth (if supported)"
     43//usage:     "\n    -r  Get/set readonly flag (DANGEROUS to set)"
     44//usage:    IF_FEATURE_HDPARM_HDIO_SCAN_HWIF(
     45//usage:     "\n    -R  Register an IDE interface (DANGEROUS)")
     46//usage:     "\n    -S  Set standby (spindown) timeout"
     47//usage:     "\n    -t  Perform device read timings"
     48//usage:     "\n    -T  Perform cache read timings"
     49//usage:     "\n    -u  Get/set unmaskirq flag (0/1)"
     50//usage:    IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(
     51//usage:     "\n    -U  Unregister an IDE interface (DANGEROUS)")
     52//usage:     "\n    -v  Defaults; same as -mcudkrag for IDE drives"
     53//usage:     "\n    -V  Display program version and exit immediately"
     54//usage:    IF_FEATURE_HDPARM_HDIO_DRIVE_RESET(
     55//usage:     "\n    -w  Perform device reset (DANGEROUS)")
     56//usage:     "\n    -W  Set drive write-caching flag (0/1) (DANGEROUS)"
     57//usage:    IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(
     58//usage:     "\n    -x  Tristate device for hotswap (0/1) (DANGEROUS)")
     59//usage:     "\n    -X  Set IDE xfer mode (DANGEROUS)"
     60//usage:     "\n    -y  Put IDE drive in standby mode"
     61//usage:     "\n    -Y  Put IDE drive to sleep"
     62//usage:     "\n    -Z  Disable Seagate auto-powersaving mode"
     63//usage:     "\n    -z  Reread partition table"
     64
    1465#include "libbb.h"
    1566/* must be _after_ libbb.h: */
     
    383434#define hwif_ctrl          (G.hwif_ctrl              )
    384435#define hwif_irq           (G.hwif_irq               )
     436#define INIT_G() do { } while (0)
    385437
    386438
     
    9711023        if ((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) {
    9721024            /* We print out elsewhere whether the APM feature is enabled or
    973                not.  If it's not enabled, let's not repeat the info; just print
    974                nothing here. */
     1025             * not.  If it's not enabled, let's not repeat the info; just print
     1026             * nothing here. */
    9751027            printf("\tAdvancedPM level: ");
    9761028            if ((val[ADV_PWR] & 0xFF00) == 0x4000) {
     
    9871039        }
    9881040    } else {
    989          /* ATAPI */
     1041        /* ATAPI */
    9901042        if (eqpt != CDROM && (val[CAPAB_0] & SWRST_REQ))
    9911043            printf("\tATA sw reset required\n");
     
    20082060    int c;
    20092061    int flagcount = 0;
     2062
     2063    INIT_G();
    20102064
    20112065    while ((c = getopt(argc, argv, hdparm_options)) >= 0) {
  • branches/3.2/mindi-busybox/miscutils/inotifyd.c

    r2725 r3232  
    2727 * See below for mask names explanation.
    2828 */
     29
     30//usage:#define inotifyd_trivial_usage
     31//usage:    "PROG FILE1[:MASK]..."
     32//usage:#define inotifyd_full_usage "\n\n"
     33//usage:       "Run PROG on filesystem changes."
     34//usage:     "\nWhen a filesystem event matching MASK occurs on FILEn,"
     35//usage:     "\nPROG ACTUAL_EVENTS FILEn [SUBFILE] is run."
     36//usage:     "\nIf PROG is -, events are sent to stdout."
     37//usage:     "\nEvents:"
     38//usage:     "\n    a   File is accessed"
     39//usage:     "\n    c   File is modified"
     40//usage:     "\n    e   Metadata changed"
     41//usage:     "\n    w   Writable file is closed"
     42//usage:     "\n    0   Unwritable file is closed"
     43//usage:     "\n    r   File is opened"
     44//usage:     "\n    D   File is deleted"
     45//usage:     "\n    M   File is moved"
     46//usage:     "\n    u   Backing fs is unmounted"
     47//usage:     "\n    o   Event queue overflowed"
     48//usage:     "\n    x   File can't be watched anymore"
     49//usage:     "\nIf watching a directory:"
     50//usage:     "\n    m   Subfile is moved into dir"
     51//usage:     "\n    y   Subfile is moved out of dir"
     52//usage:     "\n    n   Subfile is created"
     53//usage:     "\n    d   Subfile is deleted"
     54//usage:     "\n"
     55//usage:     "\ninotifyd waits for PROG to exit."
     56//usage:     "\nWhen x event happens for all FILEs, inotifyd exits."
    2957
    3058#include "libbb.h"
     
    151179                }
    152180                *s = '\0';
    153 //              bb_error_msg("exec %s %08X\t%s\t%s\t%s", args[0],
    154 //                  ie->mask, events, watches[ie->wd], ie->len ? ie->name : "");
    155                 args[1] = events;
    156                 args[2] = watches[ie->wd];
    157                 args[3] = ie->len ? ie->name : NULL;
    158                 spawn_and_wait((char **)args);
     181                if (LONE_CHAR(args[0], '-')) {
     182                    /* "inotifyd - FILE": built-in echo */
     183                    printf(ie->len ? "%s\t%s\t%s\n" : "%s\t%s\n", events,
     184                            watches[ie->wd],
     185                            ie->name);
     186                    fflush(stdout);
     187                } else {
     188//                  bb_error_msg("exec %s %08X\t%s\t%s\t%s", args[0],
     189//                      ie->mask, events, watches[ie->wd], ie->len ? ie->name : "");
     190                    args[1] = events;
     191                    args[2] = watches[ie->wd];
     192                    args[3] = ie->len ? ie->name : NULL;
     193                    spawn_and_wait((char **)args);
     194                }
    159195                // we are done if all files got final x event
    160196                if (ie->mask & 0x8000) {
  • branches/3.2/mindi-busybox/miscutils/ionice.c

    r2725 r3232  
    77 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
     9
     10//usage:#define ionice_trivial_usage
     11//usage:    "[-c 1-3] [-n 0-7] [-p PID] [PROG]"
     12//usage:#define ionice_full_usage "\n\n"
     13//usage:       "Change I/O priority and class\n"
     14//usage:     "\n    -c  Class. 1:realtime 2:best-effort 3:idle"
     15//usage:     "\n    -n  Priority"
    916
    1017#include <sys/syscall.h>
  • branches/3.2/mindi-busybox/miscutils/last.c

    r2725 r3232  
    88 */
    99
     10//usage:#define last_trivial_usage
     11//usage:       ""IF_FEATURE_LAST_FANCY("[-HW] [-f FILE]")
     12//usage:#define last_full_usage "\n\n"
     13//usage:       "Show listing of the last users that logged into the system"
     14//usage:    IF_FEATURE_LAST_FANCY( "\n"
     15/* //usage:  "\n    -H  Show header line" */
     16//usage:     "\n    -W  Display with no host column truncation"
     17//usage:     "\n    -f FILE Read from FILE instead of /var/log/wtmp"
     18//usage:    )
     19
    1020#include "libbb.h"
    11 #include <utmp.h>
    1221
    1322/* NB: ut_name and ut_user are the same field, use only one name (ut_user)
     
    6372
    6473    printf("%-10s %-14s %-18s %-12.12s %s\n",
    65            "USER", "TTY", "HOST", "LOGIN", "TIME");
     74        "USER", "TTY", "HOST", "LOGIN", "TIME");
    6675    /* yikes. We reverse over the file and that is a not too elegant way */
    6776    pos = xlseek(file, 0, SEEK_END);
     
    123132        t_tmp = (time_t)ut.ut_tv.tv_sec;
    124133        printf("%-10s %-14s %-18s %-12.12s\n",
    125                ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4);
     134            ut.ut_user, ut.ut_line, ut.ut_host, ctime(&t_tmp) + 4);
    126135 next:
    127136        pos -= sizeof(ut);
  • branches/3.2/mindi-busybox/miscutils/last_fancy.c

    r2725 r3232  
    99
    1010#include "libbb.h"
    11 #include <utmp.h>
    1211
    1312/* NB: ut_name and ut_user are the same field, use only one name (ut_user)
     
    9594
    9695    printf(HEADER_FORMAT,
    97            ut->ut_user,
    98            ut->ut_line,
    99            show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
    100            show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
    101            ut->ut_host,
    102            login_time,
    103            logout_str,
    104            duration_str);
     96        ut->ut_user,
     97        ut->ut_line,
     98        show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
     99        show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
     100        ut->ut_host,
     101        login_time,
     102        logout_str,
     103        duration_str);
    105104}
    106105
     
    163162    time_t down_time;
    164163    int file;
    165     unsigned opt;
    166164    smallint going_down;
    167165    smallint boot_down;
    168166
    169     opt = getopt32(argv, "Wf:" /* "H" */, &filename);
     167    /*opt =*/ getopt32(argv, "Wf:" /* "H" */, &filename);
    170168#ifdef BUT_UTIL_LINUX_LAST_HAS_NO_SUCH_OPT
    171169    if (opt & LAST_OPT_H) {
  • branches/3.2/mindi-busybox/miscutils/less.c

    r2725 r3232  
    2222 */
    2323
     24//config:config LESS
     25//config:   bool "less"
     26//config:   default y
     27//config:   help
     28//config:     'less' is a pager, meaning that it displays text files. It possesses
     29//config:     a wide array of features, and is an improvement over 'more'.
     30//config:
     31//config:config FEATURE_LESS_MAXLINES
     32//config:   int "Max number of input lines less will try to eat"
     33//config:   default 9999999
     34//config:   depends on LESS
     35//config:
     36//config:config FEATURE_LESS_BRACKETS
     37//config:   bool "Enable bracket searching"
     38//config:   default y
     39//config:   depends on LESS
     40//config:   help
     41//config:     This option adds the capability to search for matching left and right
     42//config:     brackets, facilitating programming.
     43//config:
     44//config:config FEATURE_LESS_FLAGS
     45//config:   bool "Enable -m/-M"
     46//config:   default y
     47//config:   depends on LESS
     48//config:   help
     49//config:     The -M/-m flag enables a more sophisticated status line.
     50//config:
     51//config:config FEATURE_LESS_MARKS
     52//config:   bool "Enable marks"
     53//config:   default y
     54//config:   depends on LESS
     55//config:   help
     56//config:     Marks enable positions in a file to be stored for easy reference.
     57//config:
     58//config:config FEATURE_LESS_REGEXP
     59//config:   bool "Enable regular expressions"
     60//config:   default y
     61//config:   depends on LESS
     62//config:   help
     63//config:     Enable regular expressions, allowing complex file searches.
     64//config:
     65//config:config FEATURE_LESS_WINCH
     66//config:   bool "Enable automatic resizing on window size changes"
     67//config:   default y
     68//config:   depends on LESS
     69//config:   help
     70//config:     Makes less track window size changes.
     71//config:
     72//config:config FEATURE_LESS_ASK_TERMINAL
     73//config:   bool "Use 'tell me cursor position' ESC sequence to measure window"
     74//config:   default y
     75//config:   depends on FEATURE_LESS_WINCH
     76//config:   help
     77//config:     Makes less track window size changes.
     78//config:     If terminal size can't be retrieved and $LINES/$COLUMNS are not set,
     79//config:     this option makes less perform a last-ditch effort to find it:
     80//config:     position cursor to 999,999 and ask terminal to report real
     81//config:     cursor position using "ESC [ 6 n" escape sequence, then read stdin.
     82//config:
     83//config:     This is not clean but helps a lot on serial lines and such.
     84//config:
     85//config:config FEATURE_LESS_DASHCMD
     86//config:   bool "Enable flag changes ('-' command)"
     87//config:   default y
     88//config:   depends on LESS
     89//config:   help
     90//config:     This enables the ability to change command-line flags within
     91//config:     less itself ('-' keyboard command).
     92//config:
     93//config:config FEATURE_LESS_LINENUMS
     94//config:   bool "Enable dynamic switching of line numbers"
     95//config:   default y
     96//config:   depends on FEATURE_LESS_DASHCMD
     97//config:   help
     98//config:     Enables "-N" command.
     99
     100//usage:#define less_trivial_usage
     101//usage:       "[-E" IF_FEATURE_LESS_FLAGS("Mm") "Nh~I?] [FILE]..."
     102//usage:#define less_full_usage "\n\n"
     103//usage:       "View FILE (or stdin) one screenful at a time\n"
     104//usage:     "\n    -E  Quit once the end of a file is reached"
     105//usage:    IF_FEATURE_LESS_FLAGS(
     106//usage:     "\n    -M,-m   Display status line with line numbers"
     107//usage:     "\n        and percentage through the file"
     108//usage:    )
     109//usage:     "\n    -N  Prefix line number to each line"
     110//usage:     "\n    -I  Ignore case in all searches"
     111//usage:     "\n    -~  Suppress ~s displayed past EOF"
     112
    24113#include <sched.h>  /* sched_yield() */
    25114
     
    97186    regex_t pattern;
    98187    smallint pattern_valid;
     188#endif
     189#if ENABLE_FEATURE_LESS_ASK_TERMINAL
     190    smallint winsize_err;
    99191#endif
    100192    smallint terminated;
     
    618710
    619711    /* Each part of the line that matches has the HIGHLIGHT
    620        and NORMAL escape sequences placed around it.
    621        NB: we regex against line, but insert text
    622        from quarantined copy (buf[]) */
     712     * and NORMAL escape sequences placed around it.
     713     * NB: we regex against line, but insert text
     714     * from quarantined copy (buf[]) */
    623715    str = buf;
    624716    growline = NULL;
     
    629721        char *new = xasprintf("%s%.*s"HIGHLIGHT"%.*s"NORMAL,
    630722                growline ? growline : "",
    631                 match_structs.rm_so, str,
    632                 match_structs.rm_eo - match_structs.rm_so,
     723                (int)match_structs.rm_so, str,
     724                (int)(match_structs.rm_eo - match_structs.rm_so),
    633725                        str + match_structs.rm_so);
    634726        free(growline);
     
    805897    max_lineno = 0;
    806898    open_file_and_read_lines();
     899#if ENABLE_FEATURE_LESS_ASK_TERMINAL
     900    if (G.winsize_err)
     901        printf("\033[999;999H" "\033[6n");
     902#endif
    807903    buffer_fill_and_print();
    808904}
    809905
    810 static int getch_nowait(void)
     906static int64_t getch_nowait(void)
    811907{
    812908    int rd;
     909    int64_t key64;
    813910    struct pollfd pfd[2];
    814911
     
    858955    /* We have kbd_fd in O_NONBLOCK mode, read inside read_key()
    859956     * would not block even if there is no input available */
    860     rd = read_key(kbd_fd, kbd_input, /*timeout off:*/ -2);
    861     if (rd == -1) {
     957    key64 = read_key(kbd_fd, kbd_input, /*timeout off:*/ -2);
     958    if ((int)key64 == -1) {
    862959        if (errno == EAGAIN) {
    863960            /* No keyboard input available. Since poll() did return,
     
    871968    }
    872969    set_tty_cooked();
    873     return rd;
     970    return key64;
    874971}
    875972
     
    877974 * May return KEYCODE_xxx values.
    878975 * Note that this function works best with raw input. */
    879 static int less_getch(int pos)
    880 {
    881     int i;
     976static int64_t less_getch(int pos)
     977{
     978    int64_t key64;
     979    int key;
    882980
    883981 again:
    884982    less_gets_pos = pos;
    885     i = getch_nowait();
     983    key = key64 = getch_nowait();
    886984    less_gets_pos = -1;
    887985
    888     /* Discard Ctrl-something chars */
    889     if (i >= 0 && i < ' ' && i != 0x0d && i != 8)
     986    /* Discard Ctrl-something chars.
     987     * (checking only lower 32 bits is a size optimization:
     988     * upper 32 bits are used only by KEYCODE_CURSOR_POS)
     989     */
     990    if (key >= 0 && key < ' ' && key != 0x0d && key != 8)
    890991        goto again;
    891     return i;
     992
     993    return key64;
    892994}
    893995
     
    14291531#endif
    14301532    case 'r': case 'R':
     1533        /* TODO: (1) also bind ^R, ^L to this?
     1534         * (2) re-measure window size?
     1535         */
    14311536        buffer_print();
    14321537        break;
     
    15041609int less_main(int argc, char **argv)
    15051610{
    1506     int keypress;
    1507 
    15081611    INIT_G();
    15091612
     
    15481651    term_less.c_cc[VTIME] = 0;
    15491652
    1550     get_terminal_width_height(kbd_fd, &width, &max_displayed_line);
     1653    IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(kbd_fd, &width, &max_displayed_line);
    15511654    /* 20: two tabstops + 4 */
    15521655    if (width < 20 || max_displayed_line < 3)
     
    15631666    reinitialize();
    15641667    while (1) {
     1668        int64_t keypress;
     1669
    15651670#if ENABLE_FEATURE_LESS_WINCH
    15661671        while (WINCH_COUNTER) {
    15671672 again:
    15681673            winch_counter--;
    1569             get_terminal_width_height(kbd_fd, &width, &max_displayed_line);
     1674            IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(kbd_fd, &width, &max_displayed_line);
     1675 IF_FEATURE_LESS_ASK_TERMINAL(got_size:)
    15701676            /* 20: two tabstops + 4 */
    15711677            if (width < 20)
     
    15871693             * were there another SIGWINCH? */
    15881694        }
    1589 #endif
    15901695        keypress = less_getch(-1); /* -1: do not position cursor */
     1696# if ENABLE_FEATURE_LESS_ASK_TERMINAL
     1697        if ((int32_t)keypress == KEYCODE_CURSOR_POS) {
     1698            uint32_t rc = (keypress >> 32);
     1699            width = (rc & 0x7fff);
     1700            max_displayed_line = ((rc >> 16) & 0x7fff);
     1701            goto got_size;
     1702        }
     1703# endif
     1704#else
     1705        keypress = less_getch(-1); /* -1: do not position cursor */
     1706#endif
    15911707        keypress_process(keypress);
    15921708    }
  • branches/3.2/mindi-busybox/miscutils/makedevs.c

    r2725 r3232  
    77 * known bugs: can't deal with alpha ranges
    88 */
     9
     10//usage:#if ENABLE_FEATURE_MAKEDEVS_LEAF
     11//usage:#define makedevs_trivial_usage
     12//usage:       "NAME TYPE MAJOR MINOR FIRST LAST [s]"
     13//usage:#define makedevs_full_usage "\n\n"
     14//usage:       "Create a range of block or character special files"
     15//usage:     "\n"
     16//usage:     "\nTYPE is:"
     17//usage:     "\n    b   Block device"
     18//usage:     "\n    c   Character device"
     19//usage:     "\n    f   FIFO, MAJOR and MINOR are ignored"
     20//usage:     "\n"
     21//usage:     "\nFIRST..LAST specify numbers appended to NAME."
     22//usage:     "\nIf 's' is the last argument, the base device is created as well."
     23//usage:     "\n"
     24//usage:     "\nExamples:"
     25//usage:     "\n    makedevs /dev/ttyS c 4 66 2 63   ->  ttyS2-ttyS63"
     26//usage:     "\n    makedevs /dev/hda b 3 0 0 8 s    ->  hda,hda1-hda8"
     27//usage:
     28//usage:#define makedevs_example_usage
     29//usage:       "# makedevs /dev/ttyS c 4 66 2 63\n"
     30//usage:       "[creates ttyS2-ttyS63]\n"
     31//usage:       "# makedevs /dev/hda b 3 0 0 8 s\n"
     32//usage:       "[creates hda,hda1-hda8]\n"
     33//usage:#endif
     34//usage:
     35//usage:#if ENABLE_FEATURE_MAKEDEVS_TABLE
     36//usage:#define makedevs_trivial_usage
     37//usage:       "[-d device_table] rootdir"
     38//usage:#define makedevs_full_usage "\n\n"
     39//usage:       "Create a range of special files as specified in a device table.\n"
     40//usage:       "Device table entries take the form of:\n"
     41//usage:       "<name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>\n"
     42//usage:       "Where name is the file name, type can be one of:\n"
     43//usage:       "    f   Regular file\n"
     44//usage:       "    d   Directory\n"
     45//usage:       "    c   Character device\n"
     46//usage:       "    b   Block device\n"
     47//usage:       "    p   Fifo (named pipe)\n"
     48//usage:       "uid is the user id for the target file, gid is the group id for the\n"
     49//usage:       "target file. The rest of the entries (major, minor, etc) apply to\n"
     50//usage:       "to device special files. A '-' may be used for blank entries."
     51//usage:
     52//usage:#define makedevs_example_usage
     53//usage:       "For example:\n"
     54//usage:       "<name>    <type> <mode><uid><gid><major><minor><start><inc><count>\n"
     55//usage:       "/dev         d   755    0    0    -      -      -      -    -\n"
     56//usage:       "/dev/console c   666    0    0    5      1      -      -    -\n"
     57//usage:       "/dev/null    c   666    0    0    1      3      0      0    -\n"
     58//usage:       "/dev/zero    c   666    0    0    1      5      0      0    -\n"
     59//usage:       "/dev/hda     b   640    0    0    3      0      0      0    -\n"
     60//usage:       "/dev/hda     b   640    0    0    3      1      1      1    15\n\n"
     61//usage:       "Will Produce:\n"
     62//usage:       "/dev\n"
     63//usage:       "/dev/console\n"
     64//usage:       "/dev/null\n"
     65//usage:       "/dev/zero\n"
     66//usage:       "/dev/hda\n"
     67//usage:       "/dev/hda[0-15]\n"
     68//usage:#endif
    969
    1070#include "libbb.h"
  • branches/3.2/mindi-busybox/miscutils/man.c

    r2725 r3232  
    33 * Licensed under GPLv2, see file LICENSE in this source tree.
    44 */
     5
     6//usage:#define man_trivial_usage
     7//usage:       "[-aw] [MANPAGE]..."
     8//usage:#define man_full_usage "\n\n"
     9//usage:       "Format and display manual page\n"
     10//usage:     "\n    -a  Display all pages"
     11//usage:     "\n    -w  Show page locations"
    512
    613#include "libbb.h"
     
    2330
    2431*/
    25 
    26 #if ENABLE_FEATURE_SEAMLESS_LZMA
    27 #define Z_SUFFIX ".lzma"
    28 #elif ENABLE_FEATURE_SEAMLESS_BZ2
    29 #define Z_SUFFIX ".bz2"
    30 #elif ENABLE_FEATURE_SEAMLESS_GZ
    31 #define Z_SUFFIX ".gz"
    32 #else
    33 #define Z_SUFFIX ""
    34 #endif
    3532
    3633static int show_manpage(const char *pager, char *man_filename, int man, int level);
     
    9693        /* Links do not have .gz extensions, even if manpage
    9794         * is compressed */
    98         man_filename = xasprintf("%s/%s" Z_SUFFIX, man_filename, linkname);
     95        man_filename = xasprintf("%s/%s", man_filename, linkname);
    9996        free(line);
    10097        /* Note: we leak "new" man_filename string as well... */
     
    118115}
    119116
    120 /* man_filename is of the form "/dir/dir/dir/name.s" Z_SUFFIX */
     117/* man_filename is of the form "/dir/dir/dir/name.s" */
    121118static int show_manpage(const char *pager, char *man_filename, int man, int level)
    122119{
     120#if SEAMLESS_COMPRESSION
     121    /* We leak this allocation... */
     122    char *filename_with_zext = xasprintf("%s.lzma", man_filename);
     123    char *ext = strrchr(filename_with_zext, '.') + 1;
     124#endif
     125
    123126#if ENABLE_FEATURE_SEAMLESS_LZMA
    124     if (run_pipe(pager, man_filename, man, level))
    125         return 1;
    126 #endif
    127 
     127    if (run_pipe(pager, filename_with_zext, man, level))
     128        return 1;
     129#endif
     130#if ENABLE_FEATURE_SEAMLESS_XZ
     131    strcpy(ext, "xz");
     132    if (run_pipe(pager, filename_with_zext, man, level))
     133        return 1;
     134#endif
    128135#if ENABLE_FEATURE_SEAMLESS_BZ2
    129 #if ENABLE_FEATURE_SEAMLESS_LZMA
    130     strcpy(strrchr(man_filename, '.') + 1, "bz2");
    131 #endif
    132     if (run_pipe(pager, man_filename, man, level))
    133         return 1;
    134 #endif
    135 
     136    strcpy(ext, "bz2");
     137    if (run_pipe(pager, filename_with_zext, man, level))
     138        return 1;
     139#endif
    136140#if ENABLE_FEATURE_SEAMLESS_GZ
    137 #if ENABLE_FEATURE_SEAMLESS_LZMA || ENABLE_FEATURE_SEAMLESS_BZ2
    138     strcpy(strrchr(man_filename, '.') + 1, "gz");
    139 #endif
    140     if (run_pipe(pager, man_filename, man, level))
    141         return 1;
    142 #endif
    143 
    144 #if ENABLE_FEATURE_SEAMLESS_LZMA || ENABLE_FEATURE_SEAMLESS_BZ2 || ENABLE_FEATURE_SEAMLESS_GZ
    145     *strrchr(man_filename, '.') = '\0';
    146 #endif
    147     if (run_pipe(pager, man_filename, man, level))
    148         return 1;
    149 
    150     return 0;
     141    strcpy(ext, "gz");
     142    if (run_pipe(pager, filename_with_zext, man, level))
     143        return 1;
     144#endif
     145
     146    return run_pipe(pager, man_filename, man, level);
    151147}
    152148
     
    256252                while (cat0man1 < 2) {
    257253                    int found_here;
    258                     man_filename = xasprintf("%s/%s%.*s/%s.%.*s" Z_SUFFIX,
     254                    man_filename = xasprintf("%s/%s%.*s/%s.%.*s",
    259255                            cur_path,
    260256                            "cat\0man" + (cat0man1 * 4),
  • branches/3.2/mindi-busybox/miscutils/microcom.c

    r2725 r3232  
    88 * Licensed under GPLv2, see file LICENSE in this source tree.
    99 */
     10
     11//usage:#define microcom_trivial_usage
     12//usage:       "[-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY"
     13//usage:#define microcom_full_usage "\n\n"
     14//usage:       "Copy bytes for stdin to TTY and from TTY to stdout\n"
     15//usage:     "\n    -d  Wait up to DELAY ms for TTY output before sending every"
     16//usage:     "\n        next byte to it"
     17//usage:     "\n    -t  Exit if both stdin and TTY are silent for TIMEOUT ms"
     18//usage:     "\n    -s  Set serial line to SPEED"
     19//usage:     "\n    -X  Disable special meaning of NUL and Ctrl-X from stdin"
     20
    1021#include "libbb.h"
    1122
  • branches/3.2/mindi-busybox/miscutils/mountpoint.c

    r2725 r3232  
    99 * Based on sysvinit's mountpoint
    1010 */
     11
     12//usage:#define mountpoint_trivial_usage
     13//usage:       "[-q] <[-dn] DIR | -x DEVICE>"
     14//usage:#define mountpoint_full_usage "\n\n"
     15//usage:       "Check if the directory is a mountpoint\n"
     16//usage:     "\n    -q  Quiet"
     17//usage:     "\n    -d  Print major/minor device number of the filesystem"
     18//usage:     "\n    -n  Print device name of the filesystem"
     19//usage:     "\n    -x  Print major/minor device number of the blockdevice"
     20//usage:
     21//usage:#define mountpoint_example_usage
     22//usage:       "$ mountpoint /proc\n"
     23//usage:       "/proc is not a mountpoint\n"
     24//usage:       "$ mountpoint /sys\n"
     25//usage:       "/sys is a mountpoint\n"
    1126
    1227#include "libbb.h"
  • branches/3.2/mindi-busybox/miscutils/mt.c

    r2725 r3232  
    33 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    44 */
     5
     6//usage:#define mt_trivial_usage
     7//usage:       "[-f device] opcode value"
     8//usage:#define mt_full_usage "\n\n"
     9//usage:       "Control magnetic tape drive operation\n"
     10//usage:       "\n"
     11//usage:       "Available Opcodes:\n"
     12//usage:       "\n"
     13//usage:       "bsf bsfm bsr bss datacompression drvbuffer eof eom erase\n"
     14//usage:       "fsf fsfm fsr fss load lock mkpart nop offline ras1 ras2\n"
     15//usage:       "ras3 reset retension rewind rewoffline seek setblk setdensity\n"
     16//usage:       "setpart tell unload unlock weof wset"
    517
    618#include "libbb.h"
  • branches/3.2/mindi-busybox/miscutils/nandwrite.c

    r2725 r3232  
    99 */
    1010
    11 //applet:IF_NANDWRITE(APPLET(nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
    12 //applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP, nanddump))
    13 
    14 //kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o
    15 //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o
    16 
    1711//config:config NANDWRITE
    1812//config:   bool "nandwrite"
    19 //config:   default n
    20 //config:   depends on PLATFORM_LINUX
     13//config:   default y
     14//config:   select PLATFORM_LINUX
    2115//config:   help
    2216//config:     Write to the specified MTD device, with bad blocks awareness
     
    2418//config:config NANDDUMP
    2519//config:   bool "nanddump"
    26 //config:   default n
    27 //config:   depends on PLATFORM_LINUX
     20//config:   default y
     21//config:   select PLATFORM_LINUX
    2822//config:   help
    2923//config:     Dump the content of raw NAND chip
     24
     25//applet:IF_NANDWRITE(APPLET(nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP))
     26//applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP, nanddump))
     27
     28//kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o
     29//kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o
    3030
    3131//usage:#define nandwrite_trivial_usage
     
    3333//usage:#define nandwrite_full_usage "\n\n"
    3434//usage:    "Write to the specified MTD device\n"
    35 //usage:     "\nOptions:"
    3635//usage:     "\n    -p  Pad to page size"
    3736//usage:     "\n    -s ADDR Start address"
     
    4039//usage:    "[-o] [-b] [-s ADDR] [-f FILE] MTD_DEVICE"
    4140//usage:#define nanddump_full_usage "\n\n"
    42 //usage:    "Dump the sepcified MTD device\n"
    43 //usage:     "\nOptions:"
    44 //usage:     "\n    -o  Omit oob data"
     41//usage:    "Dump the specified MTD device\n"
     42//usage:     "\n    -o  Dump oob data"
    4543//usage:     "\n    -b  Omit bad block from the dump"
    4644//usage:     "\n    -s ADDR Start address"
     
    132130    }
    133131
    134     fd = xopen(argv[0], O_RDWR);
     132    fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY);
    135133    xioctl(fd, MEMGETINFO, &meminfo);
    136134
     
    165163        if (tmp != blockstart) {
    166164            /* bad block(s), advance mtdoffset */
    167             if (IS_NANDDUMP & !(opts & OPT_b)) {
     165            if (IS_NANDDUMP && !(opts & OPT_b)) {
    168166                int bad_len = MIN(tmp, end_addr) - mtdoffset;
    169                 dump_bad(&meminfo, bad_len, !(opts & OPT_o));
     167                dump_bad(&meminfo, bad_len, opts & OPT_o);
    170168            }
    171169            mtdoffset = tmp;
     
    185183            if (IS_NANDWRITE)
    186184                printf("Writing at 0x%08x\n", mtdoffset);
    187             else if (mtdoffset > blockstart) {
     185            else if (mtdoffset > blockstart && !(opts & OPT_b)) {
    188186                int bad_len = MIN(mtdoffset, limit) - blockstart;
    189                 dump_bad(&meminfo, bad_len, !(opts & OPT_o));
     187                dump_bad(&meminfo, bad_len, opts & OPT_o);
    190188            }
    191189            if (mtdoffset >= limit)
     
    213211        xwrite(output_fd, filebuf, meminfo_writesize);
    214212
    215         if (IS_NANDDUMP && !(opts & OPT_o)) {
     213        if (IS_NANDDUMP && (opts & OPT_o)) {
    216214            /* Dump OOB data */
    217215            oob.start = mtdoffset;
  • branches/3.2/mindi-busybox/miscutils/raidautorun.c

    r2725 r3232  
    88 *
    99 */
     10
     11//usage:#define raidautorun_trivial_usage
     12//usage:       "DEVICE"
     13//usage:#define raidautorun_full_usage "\n\n"
     14//usage:       "Tell the kernel to automatically search and start RAID arrays"
     15//usage:
     16//usage:#define raidautorun_example_usage
     17//usage:       "$ raidautorun /dev/md0"
    1018
    1119#include "libbb.h"
  • branches/3.2/mindi-busybox/miscutils/readahead.c

    r2725 r3232  
    1010 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1111 */
     12
     13//usage:#define readahead_trivial_usage
     14//usage:       "[FILE]..."
     15//usage:#define readahead_full_usage "\n\n"
     16//usage:       "Preload FILEs to RAM"
    1217
    1318#include "libbb.h"
  • branches/3.2/mindi-busybox/miscutils/rfkill.c

    r2725 r3232  
    77* Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88*/
     9
     10//usage:#define rfkill_trivial_usage
     11//usage:       "COMMAND [INDEX|TYPE]"
     12//usage:#define rfkill_full_usage "\n\n"
     13//usage:       "Enable/disable wireless devices\n"
     14//usage:       "\nCommands:"
     15//usage:     "\n    list [INDEX|TYPE]   List current state"
     16//usage:     "\n    block INDEX|TYPE    Disable device"
     17//usage:     "\n    unblock INDEX|TYPE  Enable device"
     18//usage:     "\n"
     19//usage:     "\n    TYPE: all, wlan(wifi), bluetooth, uwb(ultrawideband),"
     20//usage:     "\n        wimax, wwan, gps, fm"
     21
    922#include "libbb.h"
    1023#include <linux/rfkill.h>
  • branches/3.2/mindi-busybox/miscutils/runlevel.c

    r2725 r3232  
    1212 * initially busyboxified by Bernhard Reutner-Fischer
    1313 */
     14
     15//usage:#define runlevel_trivial_usage
     16//usage:       "[FILE]"
     17//usage:#define runlevel_full_usage "\n\n"
     18//usage:       "Find the current and previous system runlevel\n"
     19//usage:       "\n"
     20//usage:       "If no utmp FILE exists or if no runlevel record can be found,\n"
     21//usage:       "print \"unknown\""
     22//usage:
     23//usage:#define runlevel_example_usage
     24//usage:       "$ runlevel /var/run/utmp\n"
     25//usage:       "N 2"
     26
    1427#include "libbb.h"
    15 #include <utmp.h>
    1628
    1729int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  • branches/3.2/mindi-busybox/miscutils/rx.c

    r2725 r3232  
    1515 * This was originally written for blob and then adapted for busybox.
    1616 */
     17
     18//usage:#define rx_trivial_usage
     19//usage:       "FILE"
     20//usage:#define rx_full_usage "\n\n"
     21//usage:       "Receive a file using the xmodem protocol"
     22//usage:
     23//usage:#define rx_example_usage
     24//usage:       "$ rx /tmp/foo\n"
    1725
    1826#include "libbb.h"
     
    101109        }
    102110        /* Write previously received block */
    103         if (blockLength) {
    104             errno = 0;
    105             if (full_write(file_fd, blockBuf, blockLength) != blockLength) {
    106                 bb_perror_msg("can't write to file");
    107                 goto fatal;
    108             }
     111        errno = 0;
     112        if (full_write(file_fd, blockBuf, blockLength) != blockLength) {
     113            bb_perror_msg(bb_msg_write_error);
     114            goto fatal;
    109115        }
    110116
     
    148154        }
    149155
     156        cksum_or_crc = read_byte(TIMEOUT);
     157        if (cksum_or_crc < 0)
     158            goto timeout;
    150159        if (do_crc) {
    151             cksum_or_crc = read_byte(TIMEOUT);
    152             if (cksum_or_crc < 0)
    153                 goto timeout;
    154160            cksum_or_crc = (cksum_or_crc << 8) | read_byte(TIMEOUT);
    155             if (cksum_or_crc < 0)
    156                 goto timeout;
    157         } else {
    158             cksum_or_crc = read_byte(TIMEOUT);
    159161            if (cksum_or_crc < 0)
    160162                goto timeout;
     
    165167            /* this also ignores the initial block 0 which is */
    166168            /* meta data. */
     169            blockLength = 0;
    167170            goto next;
    168171        }
     
    191194        if (cksum_or_crc != expected) {
    192195            bb_error_msg(do_crc ? "crc error, expected 0x%04x, got 0x%04x"
    193                                : "checksum error, expected 0x%02x, got 0x%02x",
    194                     expected, cksum_or_crc);
     196                    : "checksum error, expected 0x%02x, got 0x%02x",
     197                expected, cksum_or_crc);
    195198            goto error;
    196199        }
     
    205208 error:
    206209 timeout:
     210        blockLength = 0;
    207211        errors++;
    208212        if (errors == MAXERRORS) {
  • branches/3.2/mindi-busybox/miscutils/setsid.c

    r2725 r3232  
    1414 * - busyboxed
    1515 */
     16
     17//usage:#define setsid_trivial_usage
     18//usage:       "PROG ARGS"
     19//usage:#define setsid_full_usage "\n\n"
     20//usage:       "Run PROG in a new session. PROG will have no controlling terminal\n"
     21//usage:       "and will not be affected by keyboard signals (Ctrl-C etc).\n"
     22//usage:       "See setsid(2) for details."
    1623
    1724#include "libbb.h"
  • branches/3.2/mindi-busybox/miscutils/strings.c

    r2725 r3232  
    77 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
     9
     10//usage:#define strings_trivial_usage
     11//usage:       "[-afo] [-n LEN] [FILE]..."
     12//usage:#define strings_full_usage "\n\n"
     13//usage:       "Display printable strings in a binary file\n"
     14//usage:     "\n    -a  Scan whole file (default)"
     15//usage:     "\n    -f  Precede strings with filenames"
     16//usage:     "\n    -n LEN  At least LEN characters form a string (default 4)"
     17//usage:     "\n    -o  Precede strings with decimal offsets"
    918
    1019#include "libbb.h"
  • branches/3.2/mindi-busybox/miscutils/taskset.c

    r2725 r3232  
    66 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    77 */
     8
     9//usage:#define taskset_trivial_usage
     10//usage:       "[-p] [MASK] [PID | PROG ARGS]"
     11//usage:#define taskset_full_usage "\n\n"
     12//usage:       "Set or get CPU affinity\n"
     13//usage:     "\n    -p  Operate on an existing PID"
     14//usage:
     15//usage:#define taskset_example_usage
     16//usage:       "$ taskset 0x7 ./dgemm_test&\n"
     17//usage:       "$ taskset -p 0x1 $!\n"
     18//usage:       "pid 4790's current affinity mask: 7\n"
     19//usage:       "pid 4790's new affinity mask: 1\n"
     20//usage:       "$ taskset 0x7 /bin/sh -c './taskset -p 0x1 $$'\n"
     21//usage:       "pid 6671's current affinity mask: 1\n"
     22//usage:       "pid 6671's new affinity mask: 1\n"
     23//usage:       "$ taskset -p 1\n"
     24//usage:       "pid 1's current affinity mask: 3\n"
    825
    926#include <sched.h>
  • branches/3.2/mindi-busybox/miscutils/time.c

    r2725 r3232  
    1010*/
    1111
     12//usage:#define time_trivial_usage
     13//usage:       "[-v] PROG ARGS"
     14//usage:#define time_full_usage "\n\n"
     15//usage:       "Run PROG, display resource usage when it exits\n"
     16//usage:     "\n    -v  Verbose"
     17
    1218#include "libbb.h"
     19#include <sys/resource.h> /* getrusage */
    1320
    1421/* Information on the resources used by a child process.  */
     
    6471
    6572    /* Ignore signals, but don't ignore the children.  When wait3
    66        returns the child process, set the time the command finished. */
     73     * returns the child process, set the time the command finished. */
    6774    while ((caught = wait3(&resp->waitstatus, 0, &resp->ru)) != pid) {
    6875        if (caught == -1 && errno != EINTR) {
  • branches/3.2/mindi-busybox/miscutils/timeout.c

    r2725 r3232  
    2828 * rewrite  14-11-2008 vda
    2929 */
     30
     31//usage:#define timeout_trivial_usage
     32//usage:       "[-t SECS] [-s SIG] PROG ARGS"
     33//usage:#define timeout_full_usage "\n\n"
     34//usage:       "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n"
     35//usage:       "Defaults: SECS: 10, SIG: TERM."
    3036
    3137#include "libbb.h"
     
    8490        /* Here we are grandchild. Sleep, then kill grandparent */
    8591 grandchild:
    86         /* Just sleep(NUGE_NUM); kill(parent) may kill wrong process! */
     92        /* Just sleep(HUGE_NUM); kill(parent) may kill wrong process! */
    8793        while (1) {
    8894            sleep(1);
  • branches/3.2/mindi-busybox/miscutils/ttysize.c

    r2725 r3232  
    1010 * Licensed under GPLv2, see file LICENSE in this source tree.
    1111 */
     12
     13//usage:#define ttysize_trivial_usage
     14//usage:       "[w] [h]"
     15//usage:#define ttysize_full_usage "\n\n"
     16//usage:       "Print dimension(s) of stdin's terminal, on error return 80x25"
     17
    1218#include "libbb.h"
    1319
  • branches/3.2/mindi-busybox/miscutils/volname.c

    r2725 r3232  
    2828 * Matthew Stoltenberg <d3matt@gmail.com>
    2929 */
     30
     31//usage:#define volname_trivial_usage
     32//usage:       "[DEVICE]"
     33//usage:#define volname_full_usage "\n\n"
     34//usage:       "Show CD volume name of the DEVICE (default /dev/cdrom)"
     35
    3036#include "libbb.h"
    3137
  • branches/3.2/mindi-busybox/miscutils/wall.c

    r2725 r3232  
    77 */
    88
     9//usage:#define wall_trivial_usage
     10//usage:    "[FILE]"
     11//usage:#define wall_full_usage "\n\n"
     12//usage:    "Write content of FILE or stdin to all logged-in users"
     13//usage:
     14//usage:#define wall_sample_usage
     15//usage:    "echo foo | wall\n"
     16//usage:    "wall ./mymessage"
     17
    918#include "libbb.h"
    10 #include <utmp.h>
    1119
    1220int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  • branches/3.2/mindi-busybox/miscutils/watchdog.c

    r2725 r3232  
    99 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1010 */
     11
     12//usage:#define watchdog_trivial_usage
     13//usage:       "[-t N[ms]] [-T N[ms]] [-F] DEV"
     14//usage:#define watchdog_full_usage "\n\n"
     15//usage:       "Periodically write to watchdog device DEV\n"
     16//usage:     "\n    -T N    Reboot after N seconds if not reset (default 60)"
     17//usage:     "\n    -t N    Reset every N seconds (default 30)"
     18//usage:     "\n    -F  Run in foreground"
     19//usage:     "\n"
     20//usage:     "\nUse 500ms to specify period in milliseconds"
    1121
    1222#include "libbb.h"
     
    2232    static const char V = 'V';
    2333
     34    remove_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid");
    2435    write(3, &V, 1);  /* Magic, see watchdog-api.txt in kernel */
    2536    if (ENABLE_FEATURE_CLEAN_UP)
     
    8697#endif
    8798
     99    write_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid");
     100
    88101    while (1) {
    89102        /*
Note: See TracChangeset for help on using the changeset viewer.