From ab00c0c45d74cd21129831b8d29acded19592437 Mon Sep 17 00:00:00 2001 From: Bernd Boeckmann Date: Wed, 7 Feb 2024 13:18:56 +0100 Subject: [PATCH] clang-format run --- source/fdisk/ansicon.c | 910 ++++++++++++++++++----------------- source/fdisk/ansicon.h | 17 +- source/fdisk/cmd.c | 12 +- source/fdisk/compat.c | 1 - source/fdisk/compat.h | 3 +- source/fdisk/fdiskio.c | 69 ++- source/fdisk/helpscr.c | 40 +- source/fdisk/kbdinput.c | 76 +-- source/fdisk/kbdinput.h | 24 +- source/fdisk/main.c | 628 ++++++++++++------------ source/fdisk/main.h | 6 +- source/fdisk/pcompute.c | 25 +- source/fdisk/pdiskio.c | 117 +++-- source/fdisk/pdiskio.h | 12 +- source/fdisk/printf.c | 1000 +++++++++++++++++++++------------------ source/fdisk/printf.h | 22 +- source/fdisk/userint0.c | 191 ++++---- source/fdisk/userint0.h | 4 +- source/fdisk/userint1.c | 118 ++--- source/fdisk/userint2.c | 200 ++++---- 20 files changed, 1768 insertions(+), 1707 deletions(-) diff --git a/source/fdisk/ansicon.c b/source/fdisk/ansicon.c index 7464c8f..d330625 100644 --- a/source/fdisk/ansicon.c +++ b/source/fdisk/ansicon.c @@ -22,17 +22,17 @@ * DEALINGS IN THE SOFTWARE. */ +#include +#include #include #include #include -#include -#include #ifdef __GNUC__ #include #endif #include "ansicon.h" -#define CON_MAX_ARG 4 +#define CON_MAX_ARG 4 int con_error; @@ -64,583 +64,607 @@ static void con_advance_cursor( void ); static int detect_ega( void ) { - union REGPACK r; - memset( &r, 0, sizeof(union REGPACK) ); - r.h.ah = 0x12; - r.h.bl = 0x10; - intr( 0x10, &r ); - return r.h.bl != 0x10; + union REGPACK r; + memset( &r, 0, sizeof( union REGPACK ) ); + r.h.ah = 0x12; + r.h.bl = 0x10; + intr( 0x10, &r ); + return r.h.bl != 0x10; } void con_init( int interpret_esc ) { - union REGPACK r; - unsigned char blinking_enabled; - - flag_interpret_esc = interpret_esc; - - /* detect video mode */ - memset( &r, 0, sizeof(union REGPACK) ); - r.h.ah = 0xf; - intr( 0x10, &r ); - con_is_monochrome = ( r.h.al == 7 ); - vid_mem = ( con_is_monochrome ) ? MK_FP(0xb000, 0) : MK_FP(0xb800, 0); - - /* screen size ? */ - con_width = r.h.ah; - if ( detect_ega() ) { - con_height = (*(unsigned char __far *) MK_FP(0x40, 0x84)) + 1; - blinking_enabled = (*(unsigned char __far *) MK_FP(0x40, 0x65)) & 0x20; - if ( !blinking_enabled ) { - /* set >=ega blinking bit */ - memset( &r, 0, sizeof(union REGPACK) ); - r.w.ax = 0x1003; - r.w.bx = 1; - intr( 0x10, &r ); - } - } - else { - con_height = 25; - } - con_size = con_width * con_height; - - /* are we writing to screen or file? */ - memset( &r, 0, sizeof(union REGPACK) ); - r.w.ax = 0x4400; - r.w.bx = 1; /* stdout handle */ - intr( 0x21, &r ); - con_is_device = (r.w.dx & 0x80) != 0; - - con_reset_attr(); - con_get_hw_cursor( &con_curx, &con_cury ); - cursor_sync_disabled = 0; -} - -unsigned con_get_width( void ) -{ - return con_width; -} - -unsigned con_get_height( void ) -{ - return con_height; -} + union REGPACK r; + unsigned char blinking_enabled; + + flag_interpret_esc = interpret_esc; + + /* detect video mode */ + memset( &r, 0, sizeof( union REGPACK ) ); + r.h.ah = 0xf; + intr( 0x10, &r ); + con_is_monochrome = ( r.h.al == 7 ); + vid_mem = ( con_is_monochrome ) ? MK_FP( 0xb000, 0 ) : MK_FP( 0xb800, 0 ); + + /* screen size ? */ + con_width = r.h.ah; + if ( detect_ega() ) { + con_height = ( *(unsigned char __far *)MK_FP( 0x40, 0x84 ) ) + 1; + blinking_enabled = + ( *(unsigned char __far *)MK_FP( 0x40, 0x65 ) ) & 0x20; + if ( !blinking_enabled ) { + /* set >=ega blinking bit */ + memset( &r, 0, sizeof( union REGPACK ) ); + r.w.ax = 0x1003; + r.w.bx = 1; + intr( 0x10, &r ); + } + } + else { + con_height = 25; + } + con_size = con_width * con_height; + + /* are we writing to screen or file? */ + memset( &r, 0, sizeof( union REGPACK ) ); + r.w.ax = 0x4400; + r.w.bx = 1; /* stdout handle */ + intr( 0x21, &r ); + con_is_device = ( r.w.dx & 0x80 ) != 0; + + con_reset_attr(); + con_get_hw_cursor( &con_curx, &con_cury ); + cursor_sync_disabled = 0; +} + +unsigned con_get_width( void ) { return con_width; } + +unsigned con_get_height( void ) { return con_height; } /* function to disable hardware cursor sync */ -void con_disable_cursor_sync( void ) -{ - cursor_sync_disabled++; -} +void con_disable_cursor_sync( void ) { cursor_sync_disabled++; } -int con_is_tty( void ) -{ - return con_is_device; -} +int con_is_tty( void ) { return con_is_device; } /* function to enable cursor sync */ void con_enable_cursor_sync( void ) { - if ( cursor_sync_disabled ) { - cursor_sync_disabled--; - } + if ( cursor_sync_disabled ) { + cursor_sync_disabled--; + } - if ( !cursor_sync_disabled ) { - con_set_hw_cursor( con_curx, con_cury ); - } + if ( !cursor_sync_disabled ) { + con_set_hw_cursor( con_curx, con_cury ); + } } void con_set_cursor_xy( int x, int y ) { - if ( x < 1 ) x = 1; - if ( y < 1 ) y = 1; - if ( x > con_width ) x = con_width; - if ( y > con_height ) y = con_height; + if ( x < 1 ) { + x = 1; + } + if ( y < 1 ) { + y = 1; + } + if ( x > con_width ) { + x = con_width; + } + if ( y > con_height ) { + y = con_height; + } - con_curx = x; - con_cury = y; + con_curx = x; + con_cury = y; - if ( !cursor_sync_disabled ) { - con_set_hw_cursor( con_curx, con_cury ); - } + if ( !cursor_sync_disabled ) { + con_set_hw_cursor( con_curx, con_cury ); + } } void con_set_cursor_rel( int dx, int dy ) { - int x, y; + int x, y; - x = con_curx + dx; - y = con_cury + dy; - - con_set_cursor_xy( x, y ); + x = con_curx + dx; + y = con_cury + dy; + + con_set_cursor_xy( x, y ); } void con_get_cursor_xy( int *x, int *y ) { - *x = con_curx; - *y = con_cury; + *x = con_curx; + *y = con_cury; } -int con_get_cursor_x( void ) -{ - return con_curx; -} +int con_get_cursor_x( void ) { return con_curx; } -int con_get_cursor_y( void ) -{ - return con_cury; -} +int con_get_cursor_y( void ) { return con_cury; } static int curx_save = 1, cury_save = 1; void con_save_cursor_xy( void ) { - curx_save = con_curx; - cury_save = con_cury; + curx_save = con_curx; + cury_save = con_cury; } void con_restore_cursor_xy( void ) { - con_curx = curx_save; - con_cury = cury_save; + con_curx = curx_save; + con_cury = cury_save; } static void con_get_hw_cursor( int *x, int *y ) { - union REGPACK r; + union REGPACK r; - r.x.ax = 0x0300; - r.x.bx = 0; - intr( 0x10, &r ); + r.x.ax = 0x0300; + r.x.bx = 0; + intr( 0x10, &r ); - *x = r.h.dl + 1; - *y = r.h.dh + 1; + *x = r.h.dl + 1; + *y = r.h.dh + 1; } static void con_set_hw_cursor( int x, int y ) { - union REGPACK r; - - if ( !con_is_device ) return; - - memset( &r, 0, sizeof(union REGPACK) ); - r.w.ax = 0x0200; - r.w.bx = 0; - r.h.dl = x - 1; - r.h.dh = y - 1; - intr( 0x10, &r ); + union REGPACK r; + + if ( !con_is_device ) { + return; + } + + memset( &r, 0, sizeof( union REGPACK ) ); + r.w.ax = 0x0200; + r.w.bx = 0; + r.h.dl = x - 1; + r.h.dh = y - 1; + intr( 0x10, &r ); } void con_sync_from_hw_cursor( void ) { - con_get_hw_cursor( &con_curx, &con_cury ); + con_get_hw_cursor( &con_curx, &con_cury ); } static void con_advance_cursor( void ) { - int x, y; - - x = con_curx; - y = con_cury; - - if ( x < con_width ) { - x += 1; - } - else { - x = 1; - y += 1; - } - - if ( y > con_height ) { - con_scroll( 1 ); - y = con_height; - } - - con_set_cursor_xy( x, y ); + int x, y; + + x = con_curx; + y = con_cury; + + if ( x < con_width ) { + x += 1; + } + else { + x = 1; + y += 1; + } + + if ( y > con_height ) { + con_scroll( 1 ); + y = con_height; + } + + con_set_cursor_xy( x, y ); } /* waits for a key press and returns it. * extended keys are returned ORed with 0x100 */ int con_readkey( void ) { - union REGPACK r; + union REGPACK r; - memset( &r, 0, sizeof(union REGPACK) ); - r.h.ah = 7; - intr( 0x21, &r ); - if ( r.h.al > 0 ) return r.h.al; + memset( &r, 0, sizeof( union REGPACK ) ); + r.h.ah = 7; + intr( 0x21, &r ); + if ( r.h.al > 0 ) { + return r.h.al; + } - memset( &r, 0, sizeof(union REGPACK) ); - r.h.ah = 7; - intr( 0x21, &r ); - return 0x100 | r.h.al; + memset( &r, 0, sizeof( union REGPACK ) ); + r.h.ah = 7; + intr( 0x21, &r ); + return 0x100 | r.h.al; } static void con_nl( void ) { - int x, y; + int x, y; - x = 1; - y = con_cury + 1; + x = 1; + y = con_cury + 1; - if ( y > con_height ) { - con_scroll( 1 ); - y = con_height; - } + if ( y > con_height ) { + con_scroll( 1 ); + y = con_height; + } - con_set_cursor_xy( x, y ); + con_set_cursor_xy( x, y ); } -static void con_cr( void ) { - con_set_cursor_xy( 1, con_cury ); -} +static void con_cr( void ) { con_set_cursor_xy( 1, con_cury ); } static void _con_putc_plain( char c ) { - union REGPACK r; - unsigned v; - int i, n; - - if ( con_is_device ) { - if ( (unsigned char)c >= 0x20 ) { - /* handle printable characters */ - v = ( con_textattr << 8 ) | (unsigned char)c; - vid_mem[(con_cury-1) * con_width + (con_curx-1)] = v; - - con_advance_cursor(); - } - else { - /* handle control characters */ - switch ( c ) { - case '\n': /* new line */ - con_nl(); - break; - case '\r': /* carrige return */ - con_cr(); - break; - case '\t': - n = 8 - ( con_curx & 7 ); - for ( i = 0; i <= n; i++ ) _con_putc_plain( ' ' ); - break; - } - } - } - else { - /* writing to file, use DOS calls */ - memset( &r, 0, sizeof(union REGPACK) ); - if ( c == '\n' ) { - /* hack in a CR befor NL when writing to a file */ - r.h.ah = 2; - r.h.dl = '\r'; - intr( 0x21, &r ); - } - r.h.ah = 2; - r.h.dl = c; - intr( 0x21, &r ); - } + union REGPACK r; + unsigned v; + int i, n; + + if ( con_is_device ) { + if ( (unsigned char)c >= 0x20 ) { + /* handle printable characters */ + v = ( con_textattr << 8 ) | (unsigned char)c; + vid_mem[( con_cury - 1 ) * con_width + ( con_curx - 1 )] = v; + + con_advance_cursor(); + } + else { + /* handle control characters */ + switch ( c ) { + case '\n': /* new line */ + con_nl(); + break; + case '\r': /* carrige return */ + con_cr(); + break; + case '\t': + n = 8 - ( con_curx & 7 ); + for ( i = 0; i <= n; i++ ) { + _con_putc_plain( ' ' ); + } + break; + } + } + } + else { + /* writing to file, use DOS calls */ + memset( &r, 0, sizeof( union REGPACK ) ); + if ( c == '\n' ) { + /* hack in a CR befor NL when writing to a file */ + r.h.ah = 2; + r.h.dl = '\r'; + intr( 0x21, &r ); + } + r.h.ah = 2; + r.h.dl = c; + intr( 0x21, &r ); + } } void con_scroll( int n ) { - int distance; - int last, i; - unsigned v; - - if ( !con_is_device || n == 0 ) return; - - if ( n > 0 ) { - /* scroll up */ - if ( n > con_height ) n = con_height; - last = (con_height - n) * con_width; - distance = n * con_width; - v = ( con_textattr << 8 ) | ' '; - - _fmemmove(vid_mem, vid_mem + distance, last << 1); - for ( i = last; i < con_size; i++ ) { - vid_mem[i] = v; - } - } + int distance; + int last, i; + unsigned v; + + if ( !con_is_device || n == 0 ) { + return; + } + + if ( n > 0 ) { + /* scroll up */ + if ( n > con_height ) { + n = con_height; + } + last = ( con_height - n ) * con_width; + distance = n * con_width; + v = ( con_textattr << 8 ) | ' '; + + _fmemmove( vid_mem, vid_mem + distance, last << 1 ); + for ( i = last; i < con_size; i++ ) { + vid_mem[i] = v; + } + } } void con_clrscr( void ) { - int i; - unsigned v; + int i; + unsigned v; - if ( !con_is_device ) return; + if ( !con_is_device ) { + return; + } - v = ( con_textattr << 8 ) | ' '; + v = ( con_textattr << 8 ) | ' '; - for ( i = 0; i < con_size; i++ ) { - vid_mem[i] = v; - } + for ( i = 0; i < con_size; i++ ) { + vid_mem[i] = v; + } - con_set_cursor_xy( 1, 1 ); + con_set_cursor_xy( 1, 1 ); } void con_clreol( void ) { - unsigned v; - int x; + unsigned v; + int x; - if ( !con_is_device ) return; + if ( !con_is_device ) { + return; + } - v = ( con_textattr << 8 ) | ' '; - for (x = con_curx; x <= con_width; x++ ) { - vid_mem[(con_cury-1) * con_width + (x-1)] = v; - } + v = ( con_textattr << 8 ) | ' '; + for ( x = con_curx; x <= con_width; x++ ) { + vid_mem[( con_cury - 1 ) * con_width + ( x - 1 )] = v; + } } -void con_enable_attr( int flag ) -{ - con_attributes_enabled = (char)flag; -} +void con_enable_attr( int flag ) { con_attributes_enabled = (char)flag; } -void con_reset_attr( void ) -{ - con_textattr = 7; -} +void con_reset_attr( void ) { con_textattr = 7; } void con_set_bold( int flag ) { - if ( !con_attributes_enabled ) return; - - if ( flag ) { - con_textattr |= 0x08; - } - else { - con_textattr &= 0xf7; - } -} + if ( !con_attributes_enabled ) { + return; + } -int con_get_bold( void ) -{ - return ( con_textattr & 0x08 ) != 0; + if ( flag ) { + con_textattr |= 0x08; + } + else { + con_textattr &= 0xf7; + } } +int con_get_bold( void ) { return ( con_textattr & 0x08 ) != 0; } + void con_set_textcolor( int color ) { - color &= 7; - if ( !con_attributes_enabled ) return; - if ( con_is_monochrome && color != 0 ) color = 7; - con_textattr = ( con_textattr & 0xf8 ) | color; + color &= 7; + if ( !con_attributes_enabled ) { + return; + } + if ( con_is_monochrome && color != 0 ) { + color = 7; + } + con_textattr = ( con_textattr & 0xf8 ) | color; } void con_set_backcolor( int color ) { - color &= 7; - if ( !con_attributes_enabled ) return; - if ( con_is_monochrome && color != 0 ) color = 7; - con_textattr = ( con_textattr & 0x8f ) | ( color << 4 ); + color &= 7; + if ( !con_attributes_enabled ) { + return; + } + if ( con_is_monochrome && color != 0 ) { + color = 7; + } + con_textattr = ( con_textattr & 0x8f ) | ( color << 4 ); } void con_set_blinking( int flag ) { - if ( !con_attributes_enabled ) return; - con_textattr = ( con_textattr & 0x7f ) | ( (flag & 1) << 7 ); + if ( !con_attributes_enabled ) { + return; + } + con_textattr = ( con_textattr & 0x7f ) | ( ( flag & 1 ) << 7 ); } static int handle_ansi_function( char function ) { - int i, argi; - - switch ( function ) { - case 'H': /* position cursor */ - case 'f': - if ( arg[0] < 1 ) arg[0] = 1; - if ( arg[1] < 1 ) arg[1] = 1; - - if ( con_is_device ) - con_set_cursor_xy( arg[0], arg[1] ); - return 1; - - case 'A': /* cursor up */ - if ( con_is_device ) - con_set_cursor_rel( 0, arg[0] ); - return 1; - - case 'B': /* cursor down */ - if ( arg[0] == -1 ) arg[0] = 1; - if ( con_is_device ) - con_set_cursor_rel( 0, arg[0] ); - return 1; - - case 'C': /* cursor right */ - if ( arg[0] == -1 ) arg[0] = 1; - if ( con_is_device ) - con_set_cursor_rel( arg[0], 0 ); - return 1; - - case 'D': /* cursor left */ - if ( con_is_device ) - con_set_cursor_rel( arg[0], 0 ); - return 1; - - case 'J': /* erase display */ - if ( arg_count != 1 || arg[0] != 2 ) return 0; - if ( con_is_device ) - con_clrscr(); - return 1; - - case 'K': /* erase line */ - if ( con_is_device ) - con_clreol(); - return 1; - - case 'm': /* set text attributes */ - for ( i = 0; i < arg_count; i++ ) { - argi = arg[i]; - if ( argi == 0 ) { - con_reset_attr(); - } - else if ( argi == 1 ) { - con_set_bold( 1 ); - } - else if ( argi == 5 ) { - con_set_blinking( 1 ); - } - else if ( argi == 22 ) { - con_set_bold( 0 ); - } - else if ( argi == 25 ) { - con_set_blinking( 0 ); - } - else if ( argi >= 30 && argi <= 37 ) { - con_set_textcolor( argi - 30 ); - } - else if ( argi >= 40 && argi <= 47 ) { - con_set_backcolor( argi - 40 ); - } - } - return 1; - } - - return 0; + int i, argi; + + switch ( function ) { + case 'H': /* position cursor */ + case 'f': + if ( arg[0] < 1 ) { + arg[0] = 1; + } + if ( arg[1] < 1 ) { + arg[1] = 1; + } + + if ( con_is_device ) { + con_set_cursor_xy( arg[0], arg[1] ); + } + return 1; + + case 'A': /* cursor up */ + if ( con_is_device ) { + con_set_cursor_rel( 0, arg[0] ); + } + return 1; + + case 'B': /* cursor down */ + if ( arg[0] == -1 ) { + arg[0] = 1; + } + if ( con_is_device ) { + con_set_cursor_rel( 0, arg[0] ); + } + return 1; + + case 'C': /* cursor right */ + if ( arg[0] == -1 ) { + arg[0] = 1; + } + if ( con_is_device ) { + con_set_cursor_rel( arg[0], 0 ); + } + return 1; + + case 'D': /* cursor left */ + if ( con_is_device ) { + con_set_cursor_rel( arg[0], 0 ); + } + return 1; + + case 'J': /* erase display */ + if ( arg_count != 1 || arg[0] != 2 ) { + return 0; + } + if ( con_is_device ) { + con_clrscr(); + } + return 1; + + case 'K': /* erase line */ + if ( con_is_device ) { + con_clreol(); + } + return 1; + + case 'm': /* set text attributes */ + for ( i = 0; i < arg_count; i++ ) { + argi = arg[i]; + if ( argi == 0 ) { + con_reset_attr(); + } + else if ( argi == 1 ) { + con_set_bold( 1 ); + } + else if ( argi == 5 ) { + con_set_blinking( 1 ); + } + else if ( argi == 22 ) { + con_set_bold( 0 ); + } + else if ( argi == 25 ) { + con_set_blinking( 0 ); + } + else if ( argi >= 30 && argi <= 37 ) { + con_set_textcolor( argi - 30 ); + } + else if ( argi >= 40 && argi <= 47 ) { + con_set_backcolor( argi - 40 ); + } + } + return 1; + } + + return 0; } static void _con_putc_ansi( char c ) { - static enum { - S_NONE, - S_START, - S_START2, - S_ARG, - S_FINI, - S_ERR - } state; - - int i; - - switch ( state ) { - case S_NONE: - if ( c == '\33' ) { - /* start of escape sequence, reset internal state */ - arg_count = 0; - for ( i = 0; i < CON_MAX_ARG; i++ ) arg[i] = -1; - state++; - } - else { - _con_putc_plain( c ); - return; - } - break; - case S_START: - /* skip [ following escape character */ - if ( c == '[' ) state++; - else state = S_ERR; - break; - - case S_START2: - /* if first character after [ is no letter (command), it must be a + static enum { S_NONE, S_START, S_START2, S_ARG, S_FINI, S_ERR } state; + + int i; + + switch ( state ) { + case S_NONE: + if ( c == '\33' ) { + /* start of escape sequence, reset internal state */ + arg_count = 0; + for ( i = 0; i < CON_MAX_ARG; i++ ) { + arg[i] = -1; + } + state++; + } + else { + _con_putc_plain( c ); + return; + } + break; + case S_START: + /* skip [ following escape character */ + if ( c == '[' ) { + state++; + } + else { + state = S_ERR; + } + break; + + case S_START2: + /* if first character after [ is no letter (command), it must be a (possibly empty) numeric argument */ - if ( !isalpha( c ) ) { - arg_count++; - } - state++; - /* fallthrough !! */ - case S_ARG: /* process numeric arguments and command */ - if ( isdigit( c ) ) { - /* numeric argument */ - if ( arg[arg_count-1] == -1 ) { - arg[arg_count-1] = 0; - } - arg[arg_count-1] = 10 * arg[arg_count-1] + ( c - '0' ); - } - else if ( c == ';' ) { - /* semicolon starts a new (possibly empty) numeric argument */ - if ( arg_count < CON_MAX_ARG - 1 ) { - arg_count++; - } - else { - state = S_ERR; - } - } - else if ( isalpha( c ) ) { - if ( handle_ansi_function( c ) ) state = S_FINI; - else state = S_ERR; - } - else { - state = S_ERR; - } - break; - - default: - break; - } - - switch ( state ) { - case S_ERR: - con_error = 1; - state = S_NONE; - break; - - case S_FINI: - state = S_NONE; - - default: - break; - } + if ( !isalpha( c ) ) { + arg_count++; + } + state++; + /* fallthrough !! */ + case S_ARG: /* process numeric arguments and command */ + if ( isdigit( c ) ) { + /* numeric argument */ + if ( arg[arg_count - 1] == -1 ) { + arg[arg_count - 1] = 0; + } + arg[arg_count - 1] = 10 * arg[arg_count - 1] + ( c - '0' ); + } + else if ( c == ';' ) { + /* semicolon starts a new (possibly empty) numeric argument */ + if ( arg_count < CON_MAX_ARG - 1 ) { + arg_count++; + } + else { + state = S_ERR; + } + } + else if ( isalpha( c ) ) { + if ( handle_ansi_function( c ) ) { + state = S_FINI; + } + else { + state = S_ERR; + } + } + else { + state = S_ERR; + } + break; + + default: + break; + } + + switch ( state ) { + case S_ERR: + con_error = 1; + state = S_NONE; + break; + + case S_FINI: + state = S_NONE; + + default: + break; + } } - void con_print( const char *s ) { - con_disable_cursor_sync(); - if ( flag_interpret_esc ) { - while ( *s ) { - _con_putc_ansi( *s++ ); - } - - } - else { - while ( *s ) { - _con_putc_plain( *s++ ); - } - } - con_enable_cursor_sync(); + con_disable_cursor_sync(); + if ( flag_interpret_esc ) { + while ( *s ) { + _con_putc_ansi( *s++ ); + } + } + else { + while ( *s ) { + _con_putc_plain( *s++ ); + } + } + con_enable_cursor_sync(); } void con_puts( const char *s ) { - con_disable_cursor_sync(); - con_print( s ); - con_putc( '\n' ); - con_enable_cursor_sync(); + con_disable_cursor_sync(); + con_print( s ); + con_putc( '\n' ); + con_enable_cursor_sync(); } void con_print_at( int x, int y, const char *s ) { - con_disable_cursor_sync(); - con_set_cursor_xy( x, y ); - con_print( s ); - con_enable_cursor_sync(); + con_disable_cursor_sync(); + con_set_cursor_xy( x, y ); + con_print( s ); + con_enable_cursor_sync(); } void con_putc( char c ) { - if ( flag_interpret_esc ) { - _con_putc_ansi( c ); - } - else { - _con_putc_plain( c ); - } + if ( flag_interpret_esc ) { + _con_putc_ansi( c ); + } + else { + _con_putc_plain( c ); + } } diff --git a/source/fdisk/ansicon.h b/source/fdisk/ansicon.h index c1c11b3..552bcf7 100644 --- a/source/fdisk/ansicon.h +++ b/source/fdisk/ansicon.h @@ -25,7 +25,6 @@ * DEALINGS IN THE SOFTWARE. */ - /* This library supports the interpretation of a minimal subset of ANSI * escape sequences for display output. The supported sequences as of now are: @@ -130,15 +129,14 @@ 47 White backgound (ISO 6429 standard) */ - /* some ESC strings as preprocessor definition */ -#define ESC_ATTR_OFF "\33[0m" -#define ESC_BOLD_ON "\33[1m" -#define ESC_BOLD_OFF "\33[22m" +#define ESC_ATTR_OFF "\33[0m" +#define ESC_BOLD_ON "\33[1m" +#define ESC_BOLD_OFF "\33[22m" #define ESC_BLINK_ON #define ESC_BLINK_OFF -#define ESC_CLRSCR "\33[2J" -#define ESC_CLREOL "\33[K" +#define ESC_CLRSCR "\33[2J" +#define ESC_CLREOL "\33[K" #ifdef __cplusplus extern "C" { @@ -148,7 +146,6 @@ extern "C" { * Variable must be reset to zero by user of the lib */ extern int con_error; - /* Initialize the console output routines. * interpret_esc = 0 : interpretation of escape sequences disabled * interpret_esc = 1 : interpretation of escape sequences enabled */ @@ -164,10 +161,10 @@ int con_readkey( void ); /* Display output routines. The functions interpret ANSI escape sequences * if enabled via con_init(). */ -void con_putc( char c ); +void con_putc( char c ); void con_print( const char *s ); void con_print_at( int x, int y, const char *s ); -void con_puts( const char *s ); /* like con_print with trailing new-line */ +void con_puts( const char *s ); /* like con_print with trailing new-line */ /* Clear screen and move cursor to home position. */ void con_clrscr( void ); diff --git a/source/fdisk/cmd.c b/source/fdisk/cmd.c index 8fc23f7..e162a27 100644 --- a/source/fdisk/cmd.c +++ b/source/fdisk/cmd.c @@ -3,16 +3,16 @@ #include #include +#include "ansicon.h" #include "cmd.h" #include "compat.h" #include "fdiskio.h" #include "main.h" #include "pcompute.h" #include "pdiskio.h" -#include "userint0.h" -#include "ansicon.h" #include "printf.h" #include "svarlang/svarlang.h" +#include "userint0.h" #ifndef FDISKLITE #include "userint1.h" @@ -494,12 +494,14 @@ void Command_Line_Test_Flag( void ) if ( flag == arg[0].extra_value ) { /* NLS:Flag %d is set to %d. */ - con_printf( svarlang_str( 8, 31 ), arg[0].value, arg[0].extra_value ); + con_printf( svarlang_str( 8, 31 ), arg[0].value, + arg[0].extra_value ); exit( 21 ); } else { /* NLS:Flag %d is not set to %d. */ - con_printf( svarlang_str( 8, 32 ), arg[0].value, arg[0].extra_value ); + con_printf( svarlang_str( 8, 32 ), arg[0].value, + arg[0].extra_value ); exit( 20 ); } } @@ -513,7 +515,6 @@ void Command_Line_Test_Flag( void ) } } - /* Get the command line options */ int Get_Options( char *argv[], int argc ) { @@ -550,7 +551,6 @@ int Get_Options( char *argv[], int argc ) if ( flags.using_default_drive_number ) { flags.drive_number = ( argptr[0] - '0' ) + 127; flags.using_default_drive_number = FALSE; - } else if ( flags.drive_number != ( argptr[0] - '0' ) + 127 ) { /* NLS:more than one drive specified; terminated */ diff --git a/source/fdisk/compat.c b/source/fdisk/compat.c index 694dba5..8305b81 100644 --- a/source/fdisk/compat.c +++ b/source/fdisk/compat.c @@ -27,4 +27,3 @@ char *searchpath( char *fn ) #endif #endif - diff --git a/source/fdisk/compat.h b/source/fdisk/compat.h index f47776e..503c746 100644 --- a/source/fdisk/compat.h +++ b/source/fdisk/compat.h @@ -13,14 +13,13 @@ char *searchpath( char *fn ); #if defined( __GNUC__ ) -extern char *_searchpath (const char *__file); +extern char *_searchpath( const char *__file ); #define searchpath _searchpath #ifndef stricmp #define stricmp strcasecmp #endif - extern char **environ; #endif diff --git a/source/fdisk/fdiskio.c b/source/fdisk/fdiskio.c index 6565ff6..3bba4d1 100644 --- a/source/fdisk/fdiskio.c +++ b/source/fdisk/fdiskio.c @@ -7,21 +7,19 @@ #ifdef __GNUC__ #include #endif +#include "ansicon.h" #include "compat.h" #include "fdiskio.h" #include "main.h" #include "pcompute.h" #include "pdiskio.h" -#include "ansicon.h" #include "printf.h" #include "svarlang/svarlang.h" - /* bootloader pointers */ /*extern char booteasy_code[];*/ extern char bootnormal_code[]; - /* Automatically partition the selected hard drive */ int Automatically_Partition_Hard_Drive( void ) { @@ -235,7 +233,6 @@ static int Create_BootNormal_MBR( void ) return Write_Physical_Sectors( flags.drive_number, 0, 0, 1, 1 ); } - #ifdef SMART_MBR /* Create Normal MBR */ extern void __cdecl __far BootSmart_code(); @@ -245,8 +242,7 @@ int Create_BootSmart_IPL( void ) int error_code; /* NLS:Creating Drive Smart MBR for disk %d */ - con_printf( svarlang_str( 7, 6 ), - flags.drive_number - 0x7F ); + con_printf( svarlang_str( 7, 6 ), flags.drive_number - 0x7F ); error_code = Read_Physical_Sectors( flags.drive_number, 0, 0, 1, 1 ); if ( error_code != 0 ) { @@ -298,7 +294,6 @@ int Create_MBR_If_Not_Present( void ) } */ - /* parse bool_text for "ON" or "OFF" and set integer var accordingly */ int bool_string_to_int( int *var, const char *bool_text ) { @@ -314,7 +309,6 @@ int bool_string_to_int( int *var, const char *bool_text ) return 0; } - /* Read and process the fdisk.ini file */ void Process_Fdiskini_File( void ) { @@ -360,7 +354,7 @@ void Process_Fdiskini_File( void ) ( end_of_file_marker_encountered == FALSE ) ) { /* Clear the command_buffer and setting_buffer */ - for (index = 0; index < 20; index++) { + for ( index = 0; index < 20; index++ ) { command_buffer[index] = 0x00; setting_buffer[index] = 0x00; } @@ -441,36 +435,44 @@ void Process_Fdiskini_File( void ) /* Align partitions to 4k */ if ( 0 == stricmp( command_buffer, "ALIGN_4K" ) ) { - if ( !bool_string_to_int( &flags.align_4k, setting_buffer) ) + if ( !bool_string_to_int( &flags.align_4k, setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } /* Check for the ALLOW_4GB_FAT16 statement */ if ( 0 == stricmp( command_buffer, "ALLOW_4GB_FAT16" ) ) { - if ( !bool_string_to_int( &flags.allow_4gb_fat16, setting_buffer) ) + if ( !bool_string_to_int( &flags.allow_4gb_fat16, + setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } /* Check for the ALLOW_ABORT statement */ if ( 0 == stricmp( command_buffer, "ALLOW_ABORT" ) ) { - if ( !bool_string_to_int( &flags.allow_abort, setting_buffer) ) + if ( !bool_string_to_int( &flags.allow_abort, + setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } /* Check for the AMBR statement */ if ( 0 == stricmp( command_buffer, "AMBR" ) ) { - if ( !bool_string_to_int( &flags.use_ambr, setting_buffer) ) + if ( !bool_string_to_int( &flags.use_ambr, setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } /* Check for the CHECKEXTRA statement */ if ( 0 == stricmp( command_buffer, "CHECKEXTRA" ) ) { - if ( !bool_string_to_int( &flags.check_for_extra_cylinder, setting_buffer) ) + if ( !bool_string_to_int( &flags.check_for_extra_cylinder, + setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } @@ -481,14 +483,18 @@ void Process_Fdiskini_File( void ) if ( ( number >= 0 ) && ( number <= 127 ) ) { flags.screen_color = number; } - else goto parse_error; + else { + goto parse_error; + } command_ok = TRUE; } /* Check for the DEL_ND_LOG statement */ if ( 0 == stricmp( command_buffer, "DEL_ND_LOG" ) ) { - if ( !bool_string_to_int( &flags.del_non_dos_log_drives, setting_buffer) ) + if ( !bool_string_to_int( &flags.del_non_dos_log_drives, + setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } @@ -547,7 +553,9 @@ void Process_Fdiskini_File( void ) else if ( number == 256 ) { flags.flag_sector = part_table[0].total_sect; } - else goto parse_error; + else { + goto parse_error; + } command_ok = TRUE; } @@ -558,29 +566,36 @@ void Process_Fdiskini_File( void ) /* Check for the LBA_MARKER statement */ if ( 0 == stricmp( command_buffer, "LBA_MARKER" ) ) { - if ( !bool_string_to_int( &flags.lba_marker, setting_buffer) ) + if ( !bool_string_to_int( &flags.lba_marker, + setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } /* Check for the MONO statement */ if ( 0 == stricmp( command_buffer, "MONO" ) ) { - if ( !bool_string_to_int( &flags.monochrome, setting_buffer) ) + if ( !bool_string_to_int( &flags.monochrome, + setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } /* Check for the REBOOT statement */ if ( 0 == stricmp( command_buffer, "REBOOT" ) ) { - if ( !bool_string_to_int( &flags.reboot, setting_buffer) ) + if ( !bool_string_to_int( &flags.reboot, setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } /* Check for the SET_ANY_ACT statement */ if ( 0 == stricmp( command_buffer, "SET_ANY_ACT" ) ) { - if ( !bool_string_to_int( &flags.set_any_pri_part_active, setting_buffer) ) + if ( !bool_string_to_int( &flags.set_any_pri_part_active, + setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } @@ -607,18 +622,24 @@ void Process_Fdiskini_File( void ) else if ( 0 == stricmp( setting_buffer, "FD" ) ) { flags.version = COMP_FD; } - else goto parse_error; + else { + goto parse_error; + } command_ok = TRUE; } /* Check for the XO statement */ if ( 0 == stricmp( command_buffer, "XO" ) ) { - if ( !bool_string_to_int( &flags.extended_options_flag, setting_buffer) ) + if ( !bool_string_to_int( &flags.extended_options_flag, + setting_buffer ) ) { goto parse_error; + } command_ok = TRUE; } - if ( command_ok == FALSE ) goto parse_error; + if ( command_ok == FALSE ) { + goto parse_error; + } } if ( ( 0 == strncmp( line_buffer, "999", 3 ) ) && diff --git a/source/fdisk/helpscr.c b/source/fdisk/helpscr.c index aa3b1d7..2c933e8 100644 --- a/source/fdisk/helpscr.c +++ b/source/fdisk/helpscr.c @@ -20,8 +20,8 @@ #include "pdiskio.h" #include "userint0.h" -#include "helpscr.h" #include "ansicon.h" +#include "helpscr.h" #include "printf.h" #include "svarlang/svarlang.h" @@ -53,24 +53,30 @@ void Display_Help_Screen( void ) con_printf( "%-30s %30s\n", name, version ); /* dump the entire help on screen */ - linestopause = screenh - 1; /* number of lines before screen is full */ - for (i = 0; i < 250; i++) { - const char *s = svarlang_strid(i); + linestopause = screenh - 1; /* number of lines before screen is full */ + for ( i = 0; i < 250; i++ ) { + const char *s = svarlang_strid( i ); #ifdef FDISKLITE - if (i == 1) continue; /* skip msg "no arg = launch interactive mode" */ + if ( i == 1 ) { + continue; /* skip msg "no arg = launch interactive mode" */ + } #endif - if (*s == 0) continue; - if (i == 200) { /* special case: COPYLEFT needs to be inserted */ - con_printf(s, COPYLEFT); - con_putc('\n'); - } else { - con_puts(s); - } + if ( *s == 0 ) { + continue; + } + if ( i == 200 ) { /* special case: COPYLEFT needs to be inserted */ + con_printf( s, COPYLEFT ); + con_putc( '\n' ); + } + else { + con_puts( s ); + } - /* is it time for a pause? */ - if ((flags.do_not_pause_help_information == FALSE) && (--linestopause <= 2)) { - linestopause = screenh; - Pause(); - } + /* is it time for a pause? */ + if ( ( flags.do_not_pause_help_information == FALSE ) && + ( --linestopause <= 2 ) ) { + linestopause = screenh; + Pause(); + } } } diff --git a/source/fdisk/kbdinput.c b/source/fdisk/kbdinput.c index c19deac..4199caa 100644 --- a/source/fdisk/kbdinput.c +++ b/source/fdisk/kbdinput.c @@ -106,7 +106,7 @@ unsigned long Input( int size_of_field, int x_position, int y_position, char YESchar = 'Y'; /* char that represents "yes" */ char yeschar = 'y'; - char NOchar = 'N'; /* char that represents "no" */ + char NOchar = 'N'; /* char that represents "no" */ char nochar = 'n'; if ( x_position == -1 ) { @@ -117,15 +117,16 @@ unsigned long Input( int size_of_field, int x_position, int y_position, } /* load localized version of "Y/N" if needed */ - if (type == YN) { - const char *YN_str = svarlang_str(250, 0); - const char *yn_str = svarlang_str(250, 1); - if ((YN_str[0] > 32) && (YN_str[1] > 32) && (yn_str[0] > 32) && (yn_str[1] > 32)) { - YESchar = YN_str[0]; - NOchar = YN_str[1]; - yeschar = yn_str[0]; - nochar = yn_str[1]; - } + if ( type == YN ) { + const char *YN_str = svarlang_str( 250, 0 ); + const char *yn_str = svarlang_str( 250, 1 ); + if ( ( YN_str[0] > 32 ) && ( YN_str[1] > 32 ) && ( yn_str[0] > 32 ) && + ( yn_str[1] > 32 ) ) { + YESchar = YN_str[0]; + NOchar = YN_str[1]; + yeschar = yn_str[0]; + nochar = yn_str[1]; + } } /* Clear line buffer */ @@ -166,7 +167,7 @@ unsigned long Input( int size_of_field, int x_position, int y_position, if ( return_message == ESCC ) { /* NLS:continue */ - con_print( svarlang_str( 20, 7) ); + con_print( svarlang_str( 20, 7 ) ); } /* Set the default value for NUM type, if applicable */ @@ -228,8 +229,7 @@ unsigned long Input( int size_of_field, int x_position, int y_position, /* has not been pressed, and the default value is pre-entered. */ if ( ( default_value >= 0 ) && ( type == NUMP ) && ( size_of_field > 1 ) && ( input != 8 ) && ( input != 13 ) && - ( input != 27 ) && ( default_value_preentered == TRUE ) ) - { + ( input != 27 ) && ( default_value_preentered == TRUE ) ) { line_buffer_index = 0; index = 0; @@ -248,7 +248,6 @@ unsigned long Input( int size_of_field, int x_position, int y_position, con_clreol(); con_set_cursor_xy( 5, 25 ); - /* Esc key has been hit */ if ( input == 27 ) { flags.esc = TRUE; @@ -375,7 +374,7 @@ unsigned long Input( int size_of_field, int x_position, int y_position, con_set_cursor_xy( 51, 23 ); con_clreol(); /* NLS: Input: %d */ - con_printf( svarlang_str( 20, 10 ) , input ); + con_printf( svarlang_str( 20, 10 ), input ); } #endif @@ -419,7 +418,9 @@ unsigned long Input( int size_of_field, int x_position, int y_position, } /* Process a legitimate entry if type==NUMYN. */ - if ((type == NUMYN) && ((input == YESchar) || (input == yeschar) || (input == NOchar) || (input == nochar))) { + if ( ( type == NUMYN ) && + ( ( input == YESchar ) || ( input == yeschar ) || + ( input == NOchar ) || ( input == nochar ) ) ) { type = YN; line_buffer[0] = ' '; line_buffer_index = 1; @@ -525,10 +526,11 @@ unsigned long Input( int size_of_field, int x_position, int y_position, Position_Cursor( 4, 23 ); /* NLS:Invalid entry, please enter %c-%c. */ - Color_Printf( "%s %c-%c.", svarlang_str( 20, 11 ), (char)min_range, (char)max_range ); + Color_Printf( "%s %c-%c.", svarlang_str( 20, 11 ), + (char)min_range, (char)max_range ); } - Position_Cursor( ( x_position + 1 ), y_position ); + Position_Cursor( ( x_position + 1 ), y_position ); Color_Printf( "%c", line_buffer[0] ); } @@ -544,18 +546,20 @@ unsigned long Input( int size_of_field, int x_position, int y_position, } if ( type == YN ) { - if ((input == YESchar) || (input == yeschar)) { - line_buffer[0] = YESchar; - data = TRUE; - } else if ((input == NOchar) || (input == nochar)) { - line_buffer[0] = NOchar; - data = FALSE; - } else { - proper_input_given = FALSE; - line_buffer[0] = ' '; - data = 99; - Color_Print_At(4, 23, svarlang_str(250, 2) ); - } + if ( ( input == YESchar ) || ( input == yeschar ) ) { + line_buffer[0] = YESchar; + data = TRUE; + } + else if ( ( input == NOchar ) || ( input == nochar ) ) { + line_buffer[0] = NOchar; + data = FALSE; + } + else { + proper_input_given = FALSE; + line_buffer[0] = ' '; + data = 99; + Color_Print_At( 4, 23, svarlang_str( 250, 2 ) ); + } Position_Cursor( ( x_position + 1 ), y_position ); Color_Printf( "%c", line_buffer[0] ); @@ -594,8 +598,8 @@ unsigned long Input( int size_of_field, int x_position, int y_position, ( input > 9 ) ) { proper_input_given = FALSE; - Color_Print_At( 4, 23, "%s %lu-%lu.", - svarlang_str( 20, 11 ), min_range, max_range ); + Color_Print_At( 4, 23, "%s %lu-%lu.", svarlang_str( 20, 11 ), + min_range, max_range ); invalid_input = TRUE; } @@ -605,8 +609,8 @@ unsigned long Input( int size_of_field, int x_position, int y_position, proper_input_given = FALSE; /* NLS:is not a choice, please enter */ - Color_Print_At( 4, 23, "%d %s %lu-%lu.", - input, svarlang_str( 20, 12 ), min_range, max_range ); + Color_Print_At( 4, 23, "%d %s %lu-%lu.", input, + svarlang_str( 20, 12 ), min_range, max_range ); invalid_input = TRUE; } @@ -713,8 +717,8 @@ unsigned long Input( int size_of_field, int x_position, int y_position, proper_input_given = FALSE; /* NLS:is not a choice, please enter */ - Color_Print_At( 4, 23, "%d %s %lu-%lu.", - input, svarlang_str( 20, 12 ), min_range, max_range ); + Color_Print_At( 4, 23, "%d %s %lu-%lu.", input, + svarlang_str( 20, 12 ), min_range, max_range ); invalid_input = TRUE; } diff --git a/source/fdisk/kbdinput.h b/source/fdisk/kbdinput.h index 0c2eb72..5479b88 100644 --- a/source/fdisk/kbdinput.h +++ b/source/fdisk/kbdinput.h @@ -3,18 +3,18 @@ /* Definitions for the input routine */ enum kbdinput_type { - YN = 0, - NUM = 1, - NUMP = 2, - ESC = 3, - ESCR = 4, - ESCE = 5, - ESCC = 6, - CHAR = 7, - NONE = 8, - CHARNUM = 9, - NUMCHAR = 10, - NUMYN = 11 + YN = 0, + NUM = 1, + NUMP = 2, + ESC = 3, + ESCR = 4, + ESCE = 5, + ESCC = 6, + CHAR = 7, + NONE = 8, + CHARNUM = 9, + NUMCHAR = 10, + NUMYN = 11 }; unsigned long Input( int size_of_field, int x_position, int y_position, diff --git a/source/fdisk/main.c b/source/fdisk/main.c index 7fd42ab..ff04139 100644 --- a/source/fdisk/main.c +++ b/source/fdisk/main.c @@ -34,7 +34,6 @@ static int Get_Environment_Settings( char *environment[] ); static void Initialization( char *environment[] ); /*void Re_Initialization( void );*/ - #ifndef FDISKLITE #endif @@ -149,7 +148,8 @@ static int Get_Environment_Settings( char *environment[] ) /* Check for the CHECKEXTRA statement */ if ( 0 == strcmp( command_buffer, "FFD_CHECKEXTRA" ) ) { - bool_string_to_int( &flags.check_for_extra_cylinder, setting_buffer ); + bool_string_to_int( &flags.check_for_extra_cylinder, + setting_buffer ); } /* Check for the COLORS statement */ @@ -300,27 +300,25 @@ static void InitDisks( void ) Initialize_LBA_Structures(); if ( Read_Partition_Tables() != 0 ) { - con_puts( svarlang_str(255, 0) ); + con_puts( svarlang_str( 255, 0 ) ); exit( 1 ); } if ( flags.maximum_drive_number == 0 ) { - con_puts( svarlang_str(255, 1) ); + con_puts( svarlang_str( 255, 1 ) ); exit( 6 ); - } + } } - /* Reboot the PC */ void Reboot_PC( void ) { /* Note: Reboot is a cold start. */ - void __far ( *fp )(void) = MK_FP( 0xffff, 0 ); + void __far ( *fp )( void ) = MK_FP( 0xffff, 0 ); *(int __far *)( MK_FP( 0x0040, 0x0072 ) ) = 0; - (*fp)(); + ( *fp )(); } - /* if the C: drive has not been formatted, and fdisk is (re)started, it will generate a couple of @@ -330,8 +328,8 @@ void Reboot_PC( void ) */ const unsigned char __far int24_handler[3] = { - 0x31, 0xc0, /* xor ax,ax */ - 0xcf /* iret */ + 0x31, 0xc0, /* xor ax,ax */ + 0xcf /* iret */ }; void __interrupt __far ( *old_int24 )( void ); @@ -342,14 +340,14 @@ static void int24_init( void ) { old_int24 = _dos_getvect( 0x24 ); - _dos_setvect( 0x24, (void __interrupt __far (*)())int24_handler ); + _dos_setvect( 0x24, (void __interrupt __far ( * )())int24_handler ); atexit( restore_int24 ); } static void Ensure_Drive_Number( void ) { if ( flags.using_default_drive_number == TRUE ) { - con_puts( svarlang_str( 255, 2) ); + con_puts( svarlang_str( 255, 2 ) ); exit( 9 ); } } @@ -379,10 +377,11 @@ int main( int argc, char *argv[] ) * first try to load strings from the same directory where FDISK.EXE * resides, and if this fails then try to load them from within the * FreeDOS-style %NLSPATH% directory. */ - if (svarlang_autoload_exepath( argv[0], getenv("LANG") ) != 0) { + if ( svarlang_autoload_exepath( argv[0], getenv( "LANG" ) ) != 0 ) { /* if this fails as well it is no big deal, svarlang is still * operational and will fall back to its default strings */ - svarlang_autoload_pathlist( "FDISK", getenv("NLSPATH"), getenv("LANG") ); + svarlang_autoload_pathlist( "FDISK", getenv( "NLSPATH" ), + getenv( "LANG" ) ); } Determine_DOS_Version(); @@ -453,12 +452,12 @@ int main( int argc, char *argv[] ) else { path[0] = 0; } - + InitOptions( environ ); - + /* Check if LBA is forbidden by the user before trying to query LBA BIOS capabilities. Some 8088 BIOSes crash otherwise. */ - argp = argv+1; + argp = argv + 1; while ( *argp ) { if ( !strcmp( *argp, "/x" ) || !strcmp( *argp, "/X" ) ) { flags.use_extended_int_13 = FALSE; @@ -478,390 +477,389 @@ int main( int argc, char *argv[] ) /* If "FDISK" is typed without any options */ number_of_command_line_options = Get_Options( &*argv, argc ); - while ( number_of_command_line_options > 0 ) { - command_ok = FALSE; - - if ( 0 == strcmp( arg[0].choice, "ACTIVATE" ) || - 0 == strcmp( arg[0].choice, "ACT" ) ) { - flags.use_iui = FALSE; - if ( ( arg[0].value < 1 ) || ( arg[0].value > 4 ) ) { - con_puts( svarlang_str(255, 3) ); - exit( 9 ); - } - - if ( !Set_Active_Partition( (int)( arg[0].value - 1 ) ) ) { - con_puts( svarlang_str(255, 4) ); - exit( 9 ); - } - command_ok = TRUE; - Shift_Command_Line_Options( 1 ); - } + while ( number_of_command_line_options > 0 ) { + command_ok = FALSE; - if ( 0 == strcmp( arg[0].choice, "ACTOK" ) ) { - /* ignored */ - command_ok = TRUE; - Shift_Command_Line_Options( 1 ); + if ( 0 == strcmp( arg[0].choice, "ACTIVATE" ) || + 0 == strcmp( arg[0].choice, "ACT" ) ) { + flags.use_iui = FALSE; + if ( ( arg[0].value < 1 ) || ( arg[0].value > 4 ) ) { + con_puts( svarlang_str( 255, 3 ) ); + exit( 9 ); } - if ( 0 == strcmp( arg[0].choice, "AUTO" ) ) { - flags.use_iui = FALSE; - if ( Automatically_Partition_Hard_Drive() ) { - con_puts( svarlang_str(255, 5) ); - exit( 9 ); - } - command_ok = TRUE; - Shift_Command_Line_Options( 1 ); + if ( !Set_Active_Partition( (int)( arg[0].value - 1 ) ) ) { + con_puts( svarlang_str( 255, 4 ) ); + exit( 9 ); } + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "CLEARMBR" ) || - 0 == strcmp( arg[0].choice, "CLEARALL" ) ) { - flags.use_iui = FALSE; - Ensure_Drive_Number(); + if ( 0 == strcmp( arg[0].choice, "ACTOK" ) ) { + /* ignored */ + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); + } - if ( Clear_Entire_Sector_Zero() != 0 ) { - con_puts( svarlang_str(255,6) ); - exit( 8 ); - } - command_ok = TRUE; - Read_Partition_Tables(); - Shift_Command_Line_Options( 1 ); + if ( 0 == strcmp( arg[0].choice, "AUTO" ) ) { + flags.use_iui = FALSE; + if ( Automatically_Partition_Hard_Drive() ) { + con_puts( svarlang_str( 255, 5 ) ); + exit( 9 ); } + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); + } + + if ( 0 == strcmp( arg[0].choice, "CLEARMBR" ) || + 0 == strcmp( arg[0].choice, "CLEARALL" ) ) { + flags.use_iui = FALSE; + Ensure_Drive_Number(); - if ( 0 == strcmp( arg[0].choice, "CLEARFLAG" ) ) { - flags.use_iui = FALSE; - Command_Line_Clear_Flag(); - command_ok = TRUE; + if ( Clear_Entire_Sector_Zero() != 0 ) { + con_puts( svarlang_str( 255, 6 ) ); + exit( 8 ); } + command_ok = TRUE; + Read_Partition_Tables(); + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "CLEARIPL" ) ) { - flags.use_iui = FALSE; - Ensure_Drive_Number(); + if ( 0 == strcmp( arg[0].choice, "CLEARFLAG" ) ) { + flags.use_iui = FALSE; + Command_Line_Clear_Flag(); + command_ok = TRUE; + } - if ( Remove_IPL() != 0 ) { - con_puts( svarlang_str(255, 7) ); - exit( 8 ); - } - command_ok = TRUE; + if ( 0 == strcmp( arg[0].choice, "CLEARIPL" ) ) { + flags.use_iui = FALSE; + Ensure_Drive_Number(); - Shift_Command_Line_Options( 1 ); + if ( Remove_IPL() != 0 ) { + con_puts( svarlang_str( 255, 7 ) ); + exit( 8 ); } + command_ok = TRUE; - if ( 0 == strcmp( arg[0].choice, "CMBR" ) ) { - flags.use_iui = FALSE; - if ( Create_MBR() != 0 ) { - con_puts( svarlang_str(255, 11) ); - exit( 8 ); - } - command_ok = TRUE; - Shift_Command_Line_Options( 1 ); + Shift_Command_Line_Options( 1 ); + } + + if ( 0 == strcmp( arg[0].choice, "CMBR" ) ) { + flags.use_iui = FALSE; + if ( Create_MBR() != 0 ) { + con_puts( svarlang_str( 255, 11 ) ); + exit( 8 ); } + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "DEACTIVATE" ) || - 0 == strcmp( arg[0].choice, "DEACT" ) ) { - flags.use_iui = FALSE; - if ( Deactivate_Active_Partition() != 0 || - Write_Partition_Tables() != 0 ) { - con_puts( svarlang_str(255, 9) ); - exit( 9 ); - } - command_ok = TRUE; - Shift_Command_Line_Options( 1 ); + if ( 0 == strcmp( arg[0].choice, "DEACTIVATE" ) || + 0 == strcmp( arg[0].choice, "DEACT" ) ) { + flags.use_iui = FALSE; + if ( Deactivate_Active_Partition() != 0 || + Write_Partition_Tables() != 0 ) { + con_puts( svarlang_str( 255, 9 ) ); + exit( 9 ); } + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "DELETE" ) || - 0 == strcmp( arg[0].choice, "DEL" ) ) { - flags.use_iui = FALSE; - Ensure_Drive_Number(); + if ( 0 == strcmp( arg[0].choice, "DELETE" ) || + 0 == strcmp( arg[0].choice, "DEL" ) ) { + flags.use_iui = FALSE; + Ensure_Drive_Number(); - Command_Line_Delete(); - command_ok = TRUE; - } + Command_Line_Delete(); + command_ok = TRUE; + } - if ( 0 == strcmp( arg[0].choice, "DELETEALL" ) || - 0 == strcmp( arg[0].choice, "DELALL" ) || - 0 == strcmp( arg[0].choice, "CLEAR" ) ) { - flags.use_iui = FALSE; - Ensure_Drive_Number(); + if ( 0 == strcmp( arg[0].choice, "DELETEALL" ) || + 0 == strcmp( arg[0].choice, "DELALL" ) || + 0 == strcmp( arg[0].choice, "CLEAR" ) ) { + flags.use_iui = FALSE; + Ensure_Drive_Number(); - if ( Clear_Partition_Table() != 0 ) { - con_puts( svarlang_str(255, 10) ); - exit( 9 ); - } - command_ok = TRUE; - Read_Partition_Tables(); - Shift_Command_Line_Options( 1 ); + if ( Clear_Partition_Table() != 0 ) { + con_puts( svarlang_str( 255, 10 ) ); + exit( 9 ); } + command_ok = TRUE; + Read_Partition_Tables(); + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "DUMP" ) ) { - flags.use_iui = FALSE; - Dump_Partition_Information(); - command_ok = TRUE; + if ( 0 == strcmp( arg[0].choice, "DUMP" ) ) { + flags.use_iui = FALSE; + Dump_Partition_Information(); + command_ok = TRUE; - Shift_Command_Line_Options( 1 ); - } + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "EXT" ) ) { - flags.use_iui = FALSE; - Command_Line_Create_Extended_Partition(); - command_ok = TRUE; - } + if ( 0 == strcmp( arg[0].choice, "EXT" ) ) { + flags.use_iui = FALSE; + Command_Line_Create_Extended_Partition(); + command_ok = TRUE; + } - if ( 0 == strcmp( arg[0].choice, "FPRMT" ) ) { - if ( flags.version >= COMP_W95B ) { - flags.fprmt = TRUE; - } + if ( 0 == strcmp( arg[0].choice, "FPRMT" ) ) { + if ( flags.version >= COMP_W95B ) { + flags.fprmt = TRUE; } + } - if ( 0 == strcmp( arg[0].choice, "IFEMPTY" ) ) { - /* only execute the following commands if part tbl is empty */ - if ( !Is_Pri_Tbl_Empty() ) { - exit( 0 ); - } - Shift_Command_Line_Options( 1 ); - command_ok = TRUE; + if ( 0 == strcmp( arg[0].choice, "IFEMPTY" ) ) { + /* only execute the following commands if part tbl is empty */ + if ( !Is_Pri_Tbl_Empty() ) { + exit( 0 ); } + Shift_Command_Line_Options( 1 ); + command_ok = TRUE; + } - if ( 0 == strcmp( arg[0].choice, "INFO" ) ) { - flags.use_iui = FALSE; - Command_Line_Info(); - command_ok = TRUE; - } + if ( 0 == strcmp( arg[0].choice, "INFO" ) ) { + flags.use_iui = FALSE; + Command_Line_Info(); + command_ok = TRUE; + } - if ( 0 == strcmp( arg[0].choice, "IPL" ) ) { - flags.use_iui = FALSE; - Ensure_Drive_Number(); + if ( 0 == strcmp( arg[0].choice, "IPL" ) ) { + flags.use_iui = FALSE; + Ensure_Drive_Number(); - if ( Create_MBR() != 0 ) { - con_puts( svarlang_str(255, 11) ); - exit( 8 ); - } - command_ok = TRUE; - Shift_Command_Line_Options( 1 ); + if ( Create_MBR() != 0 ) { + con_puts( svarlang_str( 255, 11 ) ); + exit( 8 ); } + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "LOADIPL" ) || - 0 == strcmp( arg[0].choice, "AMBR" ) ) { - flags.use_iui = FALSE; - Ensure_Drive_Number(); + if ( 0 == strcmp( arg[0].choice, "LOADIPL" ) || + 0 == strcmp( arg[0].choice, "AMBR" ) ) { + flags.use_iui = FALSE; + Ensure_Drive_Number(); - if ( Load_MBR( 1 ) != 0 ) { - con_puts( svarlang_str(255, 12) ); - exit( 8 ); - } - command_ok = TRUE; - Shift_Command_Line_Options( 1 ); + if ( Load_MBR( 1 ) != 0 ) { + con_puts( svarlang_str( 255, 12 ) ); + exit( 8 ); } + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "LOADMBR" ) ) { - flags.use_iui = FALSE; - Ensure_Drive_Number(); - - if ( Load_MBR( 0 ) != 0 ) { - con_puts( svarlang_str(255,13) ); - exit( 8 ); - } - command_ok = TRUE; - Shift_Command_Line_Options( 1 ); - } + if ( 0 == strcmp( arg[0].choice, "LOADMBR" ) ) { + flags.use_iui = FALSE; + Ensure_Drive_Number(); - if ( 0 == strcmp( arg[0].choice, "LOG" ) ) { - flags.use_iui = FALSE; - Command_Line_Create_Logical_DOS_Drive(); - command_ok = TRUE; + if ( Load_MBR( 0 ) != 0 ) { + con_puts( svarlang_str( 255, 13 ) ); + exit( 8 ); } + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "LOGO" ) ) { - flags.use_iui = FALSE; - fat32_temp = flags.fat32; - flags.fat32 = FALSE; - Command_Line_Create_Logical_DOS_Drive(); - flags.fat32 = fat32_temp; - command_ok = TRUE; - } + if ( 0 == strcmp( arg[0].choice, "LOG" ) ) { + flags.use_iui = FALSE; + Command_Line_Create_Logical_DOS_Drive(); + command_ok = TRUE; + } - if ( 0 == strcmp( arg[0].choice, "MBR" ) ) { - flags.use_iui = FALSE; - if ( Create_MBR() != 0 ) { - con_puts( svarlang_str(255, 14) ); - exit( 8 ); - } - command_ok = TRUE; + if ( 0 == strcmp( arg[0].choice, "LOGO" ) ) { + flags.use_iui = FALSE; + fat32_temp = flags.fat32; + flags.fat32 = FALSE; + Command_Line_Create_Logical_DOS_Drive(); + flags.fat32 = fat32_temp; + command_ok = TRUE; + } - Shift_Command_Line_Options( 1 ); + if ( 0 == strcmp( arg[0].choice, "MBR" ) ) { + flags.use_iui = FALSE; + if ( Create_MBR() != 0 ) { + con_puts( svarlang_str( 255, 14 ) ); + exit( 8 ); } + command_ok = TRUE; - if ( 0 == strcmp( arg[0].choice, "MODIFY" ) ) { - flags.use_iui = FALSE; - Command_Line_Modify(); - command_ok = TRUE; - } + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "MONO" ) ) { - flags.monochrome = TRUE; - con_enable_attr( !flags.monochrome ); - command_ok = TRUE; + if ( 0 == strcmp( arg[0].choice, "MODIFY" ) ) { + flags.use_iui = FALSE; + Command_Line_Modify(); + command_ok = TRUE; + } - Shift_Command_Line_Options( 1 ); - } + if ( 0 == strcmp( arg[0].choice, "MONO" ) ) { + flags.monochrome = TRUE; + con_enable_attr( !flags.monochrome ); + command_ok = TRUE; - if ( 0 == strcmp( arg[0].choice, "MOVE" ) ) { - flags.use_iui = FALSE; - Command_Line_Move(); - command_ok = TRUE; - } + Shift_Command_Line_Options( 1 ); + } - if ( 0 == strcmp( arg[0].choice, "PRI" ) ) { - flags.use_iui = FALSE; - Command_Line_Create_Primary_Partition(); - command_ok = TRUE; - } + if ( 0 == strcmp( arg[0].choice, "MOVE" ) ) { + flags.use_iui = FALSE; + Command_Line_Move(); + command_ok = TRUE; + } - if ( 0 == strcmp( arg[0].choice, "PRIO" ) ) { - flags.use_iui = FALSE; - fat32_temp = flags.fat32; - flags.fat32 = FALSE; - Command_Line_Create_Primary_Partition(); - flags.fat32 = fat32_temp; - command_ok = TRUE; - } + if ( 0 == strcmp( arg[0].choice, "PRI" ) ) { + flags.use_iui = FALSE; + Command_Line_Create_Primary_Partition(); + command_ok = TRUE; + } + + if ( 0 == strcmp( arg[0].choice, "PRIO" ) ) { + flags.use_iui = FALSE; + fat32_temp = flags.fat32; + flags.fat32 = FALSE; + Command_Line_Create_Primary_Partition(); + flags.fat32 = fat32_temp; + command_ok = TRUE; + } #ifndef FDISKLITE - if ( 0 == strcmp( arg[0].choice, "Q" ) ) { - flags.reboot = FALSE; + if ( 0 == strcmp( arg[0].choice, "Q" ) ) { + flags.reboot = FALSE; - if ( flags.version >= COMP_W95B ) { - Ask_User_About_FAT32_Support(); - } + if ( flags.version >= COMP_W95B ) { + Ask_User_About_FAT32_Support(); } + } #endif - if ( 0 == strcmp( arg[0].choice, "REBOOT" ) ) { - flags.use_iui = FALSE; - if ( Write_Partition_Tables() != 0 ) { - con_puts( svarlang_str(255, 15) ); - exit( 8 ); - } - Reboot_PC(); - } - - if ( 0 == strcmp( arg[0].choice, "SETFLAG" ) ) { - flags.use_iui = FALSE; - Command_Line_Set_Flag(); - command_ok = TRUE; + if ( 0 == strcmp( arg[0].choice, "REBOOT" ) ) { + flags.use_iui = FALSE; + if ( Write_Partition_Tables() != 0 ) { + con_puts( svarlang_str( 255, 15 ) ); + exit( 8 ); } + Reboot_PC(); + } - if ( 0 == strcmp( arg[0].choice, "SAVEMBR" ) || - 0 == strcmp( arg[0].choice, "SMBR" ) ) { - flags.use_iui = FALSE; - Ensure_Drive_Number(); + if ( 0 == strcmp( arg[0].choice, "SETFLAG" ) ) { + flags.use_iui = FALSE; + Command_Line_Set_Flag(); + command_ok = TRUE; + } - if ( Save_MBR() != 0 ) { - con_puts( svarlang_str(255, 16) ); - exit( 8 ); - } - command_ok = TRUE; + if ( 0 == strcmp( arg[0].choice, "SAVEMBR" ) || + 0 == strcmp( arg[0].choice, "SMBR" ) ) { + flags.use_iui = FALSE; + Ensure_Drive_Number(); - Shift_Command_Line_Options( 1 ); + if ( Save_MBR() != 0 ) { + con_puts( svarlang_str( 255, 16 ) ); + exit( 8 ); } + command_ok = TRUE; -#ifdef SMART_MBR - if ( 0 == strcmp( arg[0].choice, "SMARTIPL" ) ) { - flags.use_iui = FALSE; - Ensure_Drive_Number(); + Shift_Command_Line_Options( 1 ); + } - if ( Create_BootSmart_IPL() != 0 ) { - con_puts( svarlang_str(255, 17) ); - exit( 8 ); - } - command_ok = TRUE; +#ifdef SMART_MBR + if ( 0 == strcmp( arg[0].choice, "SMARTIPL" ) ) { + flags.use_iui = FALSE; + Ensure_Drive_Number(); - Shift_Command_Line_Options( 1 ); + if ( Create_BootSmart_IPL() != 0 ) { + con_puts( svarlang_str( 255, 17 ) ); + exit( 8 ); } + command_ok = TRUE; + + Shift_Command_Line_Options( 1 ); + } #endif - if ( 0 == strcmp( arg[0].choice, "STATUS" ) ) { - flags.use_iui = FALSE; - Command_Line_Status(); - command_ok = TRUE; - } + if ( 0 == strcmp( arg[0].choice, "STATUS" ) ) { + flags.use_iui = FALSE; + Command_Line_Status(); + command_ok = TRUE; + } - if ( 0 == strcmp( arg[0].choice, "SWAP" ) ) { - flags.use_iui = FALSE; - Command_Line_Swap(); - command_ok = TRUE; - } + if ( 0 == strcmp( arg[0].choice, "SWAP" ) ) { + flags.use_iui = FALSE; + Command_Line_Swap(); + command_ok = TRUE; + } - if ( 0 == strcmp( arg[0].choice, "TESTFLAG" ) ) { - flags.use_iui = FALSE; - Command_Line_Test_Flag(); - command_ok = TRUE; - } + if ( 0 == strcmp( arg[0].choice, "TESTFLAG" ) ) { + flags.use_iui = FALSE; + Command_Line_Test_Flag(); + command_ok = TRUE; + } #ifndef FDISKLITE - if ( 0 == strcmp( arg[0].choice, "UI" ) ) { - flags.use_iui = TRUE; - command_ok = TRUE; + if ( 0 == strcmp( arg[0].choice, "UI" ) ) { + flags.use_iui = TRUE; + command_ok = TRUE; - Shift_Command_Line_Options( 1 ); - } + Shift_Command_Line_Options( 1 ); + } #endif - if ( 0 == strcmp( arg[0].choice, "X" ) ) { - /* handled above, but still have to check to not misdetect + if ( 0 == strcmp( arg[0].choice, "X" ) ) { + /* handled above, but still have to check to not misdetect it as invalid parameter */ - Shift_Command_Line_Options( 1 ); - command_ok = TRUE; - } - - if ( 0 == strcmp( arg[0].choice, "XO" ) ) { - flags.extended_options_flag = TRUE; - flags.allow_abort = TRUE; - flags.del_non_dos_log_drives = TRUE; - flags.set_any_pri_part_active = TRUE; - command_ok = TRUE; - Shift_Command_Line_Options( 1 ); - } + Shift_Command_Line_Options( 1 ); + command_ok = TRUE; + } - if ( arg[0].choice[0] == '?' ) { - flags.use_iui = FALSE; - if ( strcmp( arg[1].choice, "NOPAUSE" ) ) { - flags.do_not_pause_help_information = TRUE; - Shift_Command_Line_Options( 1 ); - } - Display_Help_Screen(); - command_ok = TRUE; + if ( 0 == strcmp( arg[0].choice, "XO" ) ) { + flags.extended_options_flag = TRUE; + flags.allow_abort = TRUE; + flags.del_non_dos_log_drives = TRUE; + flags.set_any_pri_part_active = TRUE; + command_ok = TRUE; + Shift_Command_Line_Options( 1 ); + } - exit( 0 ); + if ( arg[0].choice[0] == '?' ) { + flags.use_iui = FALSE; + if ( strcmp( arg[1].choice, "NOPAUSE" ) ) { + flags.do_not_pause_help_information = TRUE; + Shift_Command_Line_Options( 1 ); } + Display_Help_Screen(); + command_ok = TRUE; - if ( command_ok == FALSE ) { - con_puts(svarlang_str(255, 18) ); - exit( 1 ); - } + exit( 0 ); + } + if ( command_ok == FALSE ) { + con_puts( svarlang_str( 255, 18 ) ); + exit( 1 ); } + } #ifndef FDISKLITE - if ( flags.use_iui == TRUE ) { - Interactive_User_Interface(); - } + if ( flags.use_iui == TRUE ) { + Interactive_User_Interface(); + } #else - if ( argc == 1 ) { - Display_Help_Screen(); - } + if ( argc == 1 ) { + Display_Help_Screen(); + } #endif - result = Write_Partition_Tables(); - if ( result != 0 ) { - con_print( svarlang_str( 255, 15 ) ); - con_print( "\n" ); - exit( 8 ); - } + result = Write_Partition_Tables(); + if ( result != 0 ) { + con_print( svarlang_str( 255, 15 ) ); + con_print( "\n" ); + exit( 8 ); + } #ifndef FDISKLITE - if ( flags.use_iui == TRUE ) { - Exit_Screen(); - } + if ( flags.use_iui == TRUE ) { + Exit_Screen(); + } #endif return 0; diff --git a/source/fdisk/main.h b/source/fdisk/main.h index bb467af..3462b7f 100644 --- a/source/fdisk/main.h +++ b/source/fdisk/main.h @@ -1,7 +1,7 @@ #ifdef FDISKLITE - #define FD_NAME "Free FDISK (command line only)" +#define FD_NAME "Free FDISK (command line only)" #else - #define FD_NAME "Free FDISK" +#define FD_NAME "Free FDISK" #endif #define VERSION "1.3.14" @@ -178,7 +178,6 @@ typedef struct flags_structure { unsigned char screen_color; } Flags; - /* User Defined C/H/S Settings Structure */ typedef struct user_defined_chs_settings_structure { int defined; @@ -194,4 +193,3 @@ MEXTERN User_Defined_CHS_Settings user_defined_chs_settings[MAX_DISKS]; int Get_Options( char *arguments[], int number_of_arguments ); void Reboot_PC( void ); - diff --git a/source/fdisk/pcompute.c b/source/fdisk/pcompute.c index d2d29bb..3584246 100644 --- a/source/fdisk/pcompute.c +++ b/source/fdisk/pcompute.c @@ -14,10 +14,8 @@ #include "pdiskio.h" #include "userint1.h" - static unsigned long Number_Of_Cylinders( unsigned long size ); - /* Clear the Active Partition */ int Deactivate_Active_Partition( void ) { @@ -365,7 +363,8 @@ int Delete_Primary_Partition( int partition_number ) return 0; } -static void Sort_Primary_Partitions( Partition_Table *pDrive, int drive_order[] ) +static void Sort_Primary_Partitions( Partition_Table *pDrive, + int drive_order[] ) { int index, sub_index, swap; @@ -423,7 +422,8 @@ static void Determine_Log_Free_Space( Partition_Table *pDrive ) pDrive->log_free_loc = 0; if ( ( pDrive->num_of_log_drives > 0 ) && - !(( pDrive->num_of_log_drives == 1 ) && ( pDrive->log_drive[0].num_type == 0 )) ) { + !( ( pDrive->num_of_log_drives == 1 ) && + ( pDrive->log_drive[0].num_type == 0 ) ) ) { /* If there are logical drives in the extended partition first find */ /* the largest free space between the logical drives...if it exists. */ @@ -527,7 +527,7 @@ static void Determine_Log_Free_Space( Partition_Table *pDrive ) pDrive->ext_free_space -= 1; } } - } + } } /* Determine the locations of free space in the partition table */ @@ -551,7 +551,7 @@ void Determine_Free_Space( void ) /* Reset the physical order to default */ for ( index = 0; index < 4; index++ ) { - drive_order[index] = index; + drive_order[index] = index; } /* 1. Sort the primary partitions based upon starting cylinder and their*/ @@ -747,8 +747,8 @@ unsigned long Max_Log_Part_Size_In_MB( void ) if ( ( flags.version <= COMP_W95 ) && ( max_size_mb > MAXFAT16NORM ) ) { max_size_mb = MAXFAT16NORM; } - if ( ( flags.version >= COMP_W95B ) && - ( flags.fat32 == FALSE ) && ( max_size_mb > MAXFAT16NORM ) ) { + if ( ( flags.version >= COMP_W95B ) && ( flags.fat32 == FALSE ) && + ( max_size_mb > MAXFAT16NORM ) ) { max_size_mb = MAXFAT16NORM; } if ( ( flags.fat32 == FALSE ) && ( flags.allow_4gb_fat16 == TRUE ) && @@ -785,8 +785,7 @@ unsigned long Max_Pri_Part_Size_In_MB( int type ) max_size_mb = MAXFAT16NORM; } - if ( ( type != EXTENDED ) && - ( flags.version >= COMP_W95B ) && + if ( ( type != EXTENDED ) && ( flags.version >= COMP_W95B ) && ( flags.fat32 == FALSE ) && ( max_size_mb > MAXFAT16NORM ) ) { max_size_mb = MAXFAT16NORM; } @@ -925,14 +924,12 @@ int Partition_Type_To_Create( unsigned long size_in_mb, } /* FAT 32 */ - if ( ( size_in_mb > 128 ) && - ( flags.version >= COMP_W95B ) && + if ( ( size_in_mb > 128 ) && ( flags.version >= COMP_W95B ) && ( flags.fat32 == TRUE ) && ( flags.fprmt == TRUE ) ) { numeric_type = 0x0b; } - if ( ( size_in_mb > 512 ) && - ( flags.version >= COMP_W95B ) && + if ( ( size_in_mb > 512 ) && ( flags.version >= COMP_W95B ) && ( flags.fat32 == TRUE ) ) { numeric_type = 0x0b; } diff --git a/source/fdisk/pdiskio.c b/source/fdisk/pdiskio.c index 5767438..b084b5f 100644 --- a/source/fdisk/pdiskio.c +++ b/source/fdisk/pdiskio.c @@ -9,9 +9,9 @@ #include #include +#include "ansicon.h" #include "compat.h" #include "pdiskio.h" -#include "ansicon.h" #include "printf.h" #define MAX_RETRIES 3 @@ -51,7 +51,7 @@ static int Read_Primary_Table( int drive, Partition_Table *pDrive, static int Read_Extended_Table( int drive, Partition_Table *pDrive ); static void Clear_Partition_Tables( Partition_Table *pDrive ); static int Clear_Boot_Sector( int drive, unsigned long cylinder, - unsigned long head, unsigned long sector ); + unsigned long head, unsigned long sector ); static unsigned long combine_cs( unsigned long cylinder, unsigned long sector ); static void extract_chs( unsigned char *p, unsigned long *cyl, @@ -68,7 +68,6 @@ int os_version = 0; int os_version_minor = 0; int os_gui_running = 0; - void Determine_DOS_Version( void ) { union REGPACK r; @@ -99,7 +98,6 @@ void Determine_DOS_Version( void ) } } - /* Check for interrupt 0x13 extensions */ void Check_For_INT13_Extensions( void ) { @@ -109,7 +107,7 @@ void Check_For_INT13_Extensions( void ) pDrive = part_table; - memset( &r, 0, sizeof(r) ); + memset( &r, 0, sizeof( r ) ); for ( drive = 0x80; drive < 0x88; drive++, pDrive++ ) { pDrive->ext_int_13 = FALSE; pDrive->ext_int_13_version = 0; @@ -119,10 +117,10 @@ void Check_For_INT13_Extensions( void ) r.w.bx = 0x55aa; r.h.dl = drive; intr( 0x13, &r ); - + if ( ( ( r.w.flags & INTR_CF ) == 0 ) && ( r.w.bx == 0xaa55 ) ) { pDrive->ext_int_13_version = r.h.ah; - + if ( ( r.w.cx & 1 ) == 1 ) { /* ext INT 13 functions 42, 43 and 48 actually usable? */ pDrive->ext_int_13 = TRUE; @@ -143,8 +141,7 @@ int Is_Dos_Part( int num_type ) int Is_Supp_Ext_Part( int num_type ) { return ( num_type == 5 ) || - ( num_type == 0x0f && - ( flags.version >= COMP_W95 ) ); + ( num_type == 0x0f && ( flags.version >= COMP_W95 ) ); } int Is_Pri_Tbl_Empty( void ) @@ -192,22 +189,23 @@ int Lock_Unlock_Drive( int drive_num, int lock ) union REGPACK r; /* do not try to lock drive when running under plain DOS */ - if ( ( !os_gui_running ) || (os_version < OS_DOS7) ) return 1; + if ( ( !os_gui_running ) || ( os_version < OS_DOS7 ) ) { + return 1; + } r.w.ax = 0x440d; - r.w.cx = ( lock ) ? 0x084b : 0x086b; /* lock / unlock physical device */ + r.w.cx = ( lock ) ? 0x084b : 0x086b; /* lock / unlock physical device */ r.h.bl = drive_num; - r.h.bh = 1; /* lock level */ + r.h.bh = 1; /* lock level */ r.w.dx = 0; intr( 0x21, &r ); - return (r.w.flags & INTR_CF) == 0; + return ( r.w.flags & INTR_CF ) == 0; } - /* Clear the Boot Sector of a partition */ int Clear_Boot_Sector( int drive, unsigned long cylinder, unsigned long head, - unsigned long sector ) + unsigned long sector ) { unsigned char stored_sector_buffer[SECT_SIZE]; long index; @@ -220,7 +218,8 @@ int Clear_Boot_Sector( int drive, unsigned long cylinder, unsigned long head, memset( sector_buffer, 0xf6, SECT_SIZE ); for ( index = 0; index < 16; index++ ) { - error_code = Write_Physical_Sectors( drive, cylinder, head, ( sector + index ), 1 ); + error_code = Write_Physical_Sectors( drive, cylinder, head, + ( sector + index ), 1 ); if ( error_code != 0 ) { return error_code; @@ -249,7 +248,7 @@ static unsigned long combine_cs( unsigned long cylinder, unsigned short c = cylinder; unsigned short s = sector; - return (s & 0x3f) | ((c & 0x0300) >> 2) | ((c & 0xff) << 8); + return ( s & 0x3f ) | ( ( c & 0x0300 ) >> 2 ) | ( ( c & 0xff ) << 8 ); } int Num_Ext_Part( Partition_Table *pDrive ) @@ -286,9 +285,8 @@ int Determine_Drive_Letters( void ) /* Set all active_part_found[] values to 0. */ memset( active_part_found, 0, sizeof( active_part_found ) ); - /* assign up to one drive letter to an active or non-active partition - per disk */ + per disk */ for ( index = 0; index < MAX_DISKS; index++ ) { Partition_Table *pDrive = &part_table[index]; if ( !pDrive->usable ) { @@ -311,13 +309,13 @@ int Determine_Drive_Letters( void ) if ( !active_part_found[index] ) { for ( sub_index = 0; sub_index < 4; sub_index++ ) { if ( drive_lettering_buffer[index][sub_index] == 0 && - ( IsRecognizedFatPartition( + ( IsRecognizedFatPartition( brief_partition_table[index][sub_index] ) ) ) { drive_lettering_buffer[index][sub_index] = current_letter; current_letter++; break; } - } + } } } @@ -366,7 +364,7 @@ int Determine_Drive_Letters( void ) pDrive->num_of_non_dos_log_drives = 0; non_dos_partition_counter = '1'; - for (sub_index = 4; sub_index < 27; sub_index++ ) { + for ( sub_index = 4; sub_index < 27; sub_index++ ) { if ( brief_partition_table[index][sub_index] > 0 ) { non_dos_partition = TRUE; @@ -389,7 +387,6 @@ int Determine_Drive_Letters( void ) return ( current_letter - 1 ); } - void Clear_Partition( Partition *p ) { memset( p, 0, sizeof( Partition ) ); @@ -484,7 +481,7 @@ static int Get_Hard_Drive_Parameters( int physical_drive ) total_number_hard_disks = r.h.dl; total_heads = r.h.dh; total_sectors = r.h.cl & 0x3f; - total_cylinders = r.h.ch | ( (r.h.cl & 0xc0 ) << 2 ); + total_cylinders = r.h.ch | ( ( r.h.cl & 0xc0 ) << 2 ); if ( flags.total_number_hard_disks == 255 ) { flags.total_number_hard_disks = total_number_hard_disks; @@ -527,7 +524,9 @@ static int Get_Hard_Drive_Parameters( int physical_drive ) error_code = 0; } - if ( error_code > 0 ) return ( error_code ); + if ( error_code > 0 ) { + return ( error_code ); + } /* Compute the total number of logical cylinders based upon the number */ /* of physical sectors returned from service 0x48. */ @@ -625,8 +624,8 @@ static void Get_Partition_Information( void ) if ( flags.verbose ) { con_printf( "primary %d sect %lu label %11.11s\n", partnum, - pDrive->pri_part[partnum].rel_sect, - sector_buffer + label_offset ); + pDrive->pri_part[partnum].rel_sect, + sector_buffer + label_offset ); } if ( sector_buffer[label_offset + 10] >= 32 && @@ -881,9 +880,8 @@ static void Read_Table_Entry( unsigned char *buf, Partition_Table *pDrive, p->end_cyl = pDrive->total_cyl; } - p->size_in_MB = - Convert_Sect_To_MB( p->num_sect ); - /*Convert_Cyl_To_MB( p->end_cyl - p->start_cyl + 1, + p->size_in_MB = Convert_Sect_To_MB( p->num_sect ); + /*Convert_Cyl_To_MB( p->end_cyl - p->start_cyl + 1, pDrive->total_head + 1, pDrive->total_sect );*/ } @@ -1078,9 +1076,9 @@ void Clear_Extended_Partition_Table( Partition_Table *pDrive ) static void Reset_Drive( int drive ) { union REGPACK r; - memset( &r, 0, sizeof(union REGPACK) ); + memset( &r, 0, sizeof( union REGPACK ) ); r.h.dl = drive; - intr( 0x13, &r ); + intr( 0x13, &r ); } /* Read_Physical_Sector */ @@ -1117,17 +1115,19 @@ static int Read_Physical_Sectors_CHS( int drive, long cylinder, long head, } if ( number_of_sectors == 1 ) { do { - memset( &r, 0, sizeof(union REGPACK) ); + memset( &r, 0, sizeof( union REGPACK ) ); r.w.ax = 0x0201; r.h.dh = head; r.h.dl = drive; r.h.ch = cylinder; - r.h.cl = sector | ((cylinder >> 2) & 0xC0); + r.h.cl = sector | ( ( cylinder >> 2 ) & 0xC0 ); r.w.bx = FP_OFF( sector_buffer ); r.w.es = FP_SEG( sector_buffer ); intr( 0x13, &r ); - error_code = ( r.w.flags & INTR_CF ) ? r.h.ah : 0; - if ( error_code ) Reset_Drive( drive ); + error_code = ( r.w.flags & INTR_CF ) ? r.h.ah : 0; + if ( error_code ) { + Reset_Drive( drive ); + } } while ( error_code && ++try < MAX_RETRIES ); } else { @@ -1160,14 +1160,14 @@ static int Read_Physical_Sectors_LBA_only( int drive, ulong LBA_address, /* Transfer LBA_address to disk_address_packet */ *(_u32 *)( disk_address_packet + 8 ) = LBA_address; - - memset( &r, 0, sizeof(union REGPACK) ); + + memset( &r, 0, sizeof( union REGPACK ) ); r.w.ax = 0x4200; r.h.dl = drive; r.w.si = FP_OFF( disk_address_packet ); r.w.ds = FP_SEG( disk_address_packet ); intr( 0x13, &r ); - + if ( r.w.flags & INTR_CF ) { error_code = ( r.h.ah ) ? r.h.ah : 1; Reset_Drive( drive ); @@ -1180,7 +1180,6 @@ static int Read_Physical_Sectors_LBA_only( int drive, ulong LBA_address, return ( error_code ); } - /* Read a physical sector using LBA values */ static int Read_Physical_Sectors_LBA( int drive, long cylinder, long head, long sector, int number_of_sectors ) @@ -1222,7 +1221,7 @@ int Write_Partition_Tables( void ) Partition_Table *pDrive = &part_table[drive_index]; error_code = 0; - + if ( ( pDrive->part_values_changed != TRUE && flags.partitions_have_changed != TRUE ) || !pDrive->usable ) { @@ -1252,10 +1251,10 @@ int Write_Partition_Tables( void ) for ( index = 0; index < 4; index++ ) { /* If this partition was just created, clear its boot sector. */ if ( pDrive->pri_part_created[index] == TRUE ) { - error_code = Clear_Boot_Sector( ( drive_index + 128 ), - pDrive->pri_part[index].start_cyl, - pDrive->pri_part[index].start_head, - pDrive->pri_part[index].start_sect ); + error_code = Clear_Boot_Sector( + ( drive_index + 128 ), pDrive->pri_part[index].start_cyl, + pDrive->pri_part[index].start_head, + pDrive->pri_part[index].start_sect ); if ( error_code != 0 ) { goto drive_error; } @@ -1296,10 +1295,10 @@ int Write_Partition_Tables( void ) Pause(); } - error_code = Clear_Boot_Sector( ( drive_index + 0x80 ), - pDrive->log_drive[index].start_cyl, - pDrive->log_drive[index].start_head, - pDrive->log_drive[index].start_sect ); + error_code = Clear_Boot_Sector( + ( drive_index + 0x80 ), pDrive->log_drive[index].start_cyl, + pDrive->log_drive[index].start_head, + pDrive->log_drive[index].start_sect ); if ( error_code != 0 ) { goto drive_error; } @@ -1380,18 +1379,20 @@ static int Write_Physical_Sectors_CHS( int drive, long cylinder, long head, if ( number_of_sectors == 1 ) { do { - memset( &r, 0, sizeof(union REGPACK) ); + memset( &r, 0, sizeof( union REGPACK ) ); r.w.ax = 0x0301; r.h.dh = head; r.h.dl = drive; r.h.ch = cylinder; - r.h.cl = sector | ((cylinder >> 2) & 0xC0); + r.h.cl = sector | ( ( cylinder >> 2 ) & 0xC0 ); r.w.bx = FP_OFF( sector_buffer ); r.w.es = FP_SEG( sector_buffer ); intr( 0x13, &r ); error_code = ( r.w.flags & INTR_CF ) ? r.h.ah : 0; - if ( error_code ) Reset_Drive( drive ); - } while (error_code && ++try < MAX_RETRIES); + if ( error_code ) { + Reset_Drive( drive ); + } + } while ( error_code && ++try < MAX_RETRIES ); } else { con_print( "sector != 1\n" ); @@ -1413,7 +1414,6 @@ static int Write_Physical_Sectors_LBA( int drive, long cylinder, long head, unsigned long LBA_address = chs_to_lba( &part_table[drive - 128], cylinder, head, sector ); - /* Determine the location of sector_buffer[512] */ /* and place the address of sector_buffer[512] into the DAP */ @@ -1428,17 +1428,17 @@ static int Write_Physical_Sectors_LBA( int drive, long cylinder, long head, do { /* Add number_of_sectors to disk_address_packet */ disk_address_packet[2] = number_of_sectors; - + /* Transfer LBA_address to disk_address_packet */ *(_u32 *)( disk_address_packet + 8 ) = LBA_address; - - memset( &r, 0, sizeof(union REGPACK) ); + + memset( &r, 0, sizeof( union REGPACK ) ); r.w.ax = 0x4300; r.h.dl = drive; r.w.si = FP_OFF( disk_address_packet ); r.w.ds = FP_SEG( disk_address_packet ); intr( 0x13, &r ); - + if ( r.w.flags & INTR_CF ) { error_code = ( r.h.ah ) ? r.h.ah : 1; Reset_Drive( drive ); @@ -1488,7 +1488,6 @@ static void StorePartitionInSectorBuffer( unsigned char *sector_buffer, *(_u32 *)( sector_buffer + 0x0c ) = pPart->num_sect; } - /* convert cylinder count to MB and do overflow checking */ unsigned long Convert_Cyl_To_MB( unsigned long num_cyl, unsigned long total_heads, diff --git a/source/fdisk/pdiskio.h b/source/fdisk/pdiskio.h index 5834f73..fb528b0 100644 --- a/source/fdisk/pdiskio.h +++ b/source/fdisk/pdiskio.h @@ -1,16 +1,16 @@ #ifndef PDISKIO_H #define PDISKIO_H -#define MAX_DISKS 8 +#define MAX_DISKS 8 #define MAX_LOGICAL_DRIVES 23 #define SECT_SIZE 512 -#define OS_UNKNOWN 0 -#define OS_DOS5 5 -#define OS_DOS7 7 -#define OS_WIN_ME 8 -#define OS_WIN_NT 32 +#define OS_UNKNOWN 0 +#define OS_DOS5 5 +#define OS_DOS7 7 +#define OS_WIN_ME 8 +#define OS_WIN_NT 32 extern int os_version; extern int os_version_minor; diff --git a/source/fdisk/printf.c b/source/fdisk/printf.c index ba215de..06437ef 100644 --- a/source/fdisk/printf.c +++ b/source/fdisk/printf.c @@ -33,577 +33,645 @@ #include #include -#include "printf.h" #include "ansicon.h" - +#include "printf.h" // 'ntoa' conversion buffer size, this must be big enough to hold one converted // numeric number including padded zeros (dynamically created on stack) // default: 32 byte #ifndef PRINTF_NTOA_BUFFER_SIZE -#define PRINTF_NTOA_BUFFER_SIZE 32U +#define PRINTF_NTOA_BUFFER_SIZE 32U #endif - /////////////////////////////////////////////////////////////////////////////// // internal flag definitions -#define FLAGS_ZEROPAD (1U << 0U) -#define FLAGS_LEFT (1U << 1U) -#define FLAGS_PLUS (1U << 2U) -#define FLAGS_SPACE (1U << 3U) -#define FLAGS_HASH (1U << 4U) -#define FLAGS_UPPERCASE (1U << 5U) -#define FLAGS_CHAR (1U << 6U) -#define FLAGS_SHORT (1U << 7U) -#define FLAGS_LONG (1U << 8U) -#define FLAGS_LONG_LONG (1U << 9U) -#define FLAGS_PRECISION (1U << 10U) -#define FLAGS_ADAPT_EXP (1U << 11U) - +#define FLAGS_ZEROPAD ( 1U << 0U ) +#define FLAGS_LEFT ( 1U << 1U ) +#define FLAGS_PLUS ( 1U << 2U ) +#define FLAGS_SPACE ( 1U << 3U ) +#define FLAGS_HASH ( 1U << 4U ) +#define FLAGS_UPPERCASE ( 1U << 5U ) +#define FLAGS_CHAR ( 1U << 6U ) +#define FLAGS_SHORT ( 1U << 7U ) +#define FLAGS_LONG ( 1U << 8U ) +#define FLAGS_LONG_LONG ( 1U << 9U ) +#define FLAGS_PRECISION ( 1U << 10U ) +#define FLAGS_ADAPT_EXP ( 1U << 11U ) // output function type -typedef void (*out_fct_type)(char character, void* buffer, size_t idx, size_t maxlen); - +typedef void ( *out_fct_type )( char character, void *buffer, size_t idx, + size_t maxlen ); // wrapper (used as buffer) for output function type typedef struct { - void (*fct)(char character, void* arg); - void* arg; + void ( *fct )( char character, void *arg ); + void *arg; } out_fct_wrap_type; - // internal buffer output -static void _out_buffer(char character, void* buffer, size_t idx, size_t maxlen) +static void _out_buffer( char character, void *buffer, size_t idx, + size_t maxlen ) { - if (idx < maxlen) { - ((char*)buffer)[idx] = character; - } + if ( idx < maxlen ) { + ( (char *)buffer )[idx] = character; + } } - // internal null output -static void _out_null(char character, void* buffer, size_t idx, size_t maxlen) +static void _out_null( char character, void *buffer, size_t idx, + size_t maxlen ) { - (void)character; (void)buffer; (void)idx; (void)maxlen; + (void)character; + (void)buffer; + (void)idx; + (void)maxlen; } - // internal _putchar wrapper -static void _out_char(char character, void* buffer, size_t idx, size_t maxlen) +static void _out_char( char character, void *buffer, size_t idx, + size_t maxlen ) { - (void)buffer; (void)idx; (void)maxlen; - if (character) { - con_putc(character); - } + (void)buffer; + (void)idx; + (void)maxlen; + if ( character ) { + con_putc( character ); + } } - // internal output function wrapper -static void _out_fct(char character, void* buffer, size_t idx, size_t maxlen) +static void _out_fct( char character, void *buffer, size_t idx, + size_t maxlen ) { - (void)idx; (void)maxlen; - if (character) { - // buffer is the output fct pointer - ((out_fct_wrap_type*)buffer)->fct(character, ((out_fct_wrap_type*)buffer)->arg); - } + (void)idx; + (void)maxlen; + if ( character ) { + // buffer is the output fct pointer + ( (out_fct_wrap_type *)buffer ) + ->fct( character, ( (out_fct_wrap_type *)buffer )->arg ); + } } - // internal secure strlen // \return The length of the string (excluding the terminating 0) limited by 'maxsize' -static unsigned int _strnlen_s(const char* str, size_t maxsize) +static unsigned int _strnlen_s( const char *str, size_t maxsize ) { - const char* s; - for (s = str; *s && maxsize--; ++s); - return (unsigned int)(s - str); + const char *s; + for ( s = str; *s && maxsize--; ++s ) + ; + return (unsigned int)( s - str ); } - // internal test if char is a digit (0-9) // \return true if char is a digit -static bool _is_digit(char ch) -{ - return (ch >= '0') && (ch <= '9'); -} - +static bool _is_digit( char ch ) { return ( ch >= '0' ) && ( ch <= '9' ); } // internal ASCII string to unsigned int conversion -static unsigned int _atoi(const char** str) +static unsigned int _atoi( const char **str ) { - unsigned int i = 0U; - while (_is_digit(**str)) { - i = i * 10U + (unsigned int)(*((*str)++) - '0'); - } - return i; + unsigned int i = 0U; + while ( _is_digit( **str ) ) { + i = i * 10U + (unsigned int)( *( ( *str )++ ) - '0' ); + } + return i; } - // output the specified string in reverse, taking care of any zero-padding -static size_t _out_rev(out_fct_type out, char* buffer, size_t idx, size_t maxlen, const char* buf, size_t len, unsigned int width, unsigned int flags) +static size_t _out_rev( out_fct_type out, char *buffer, size_t idx, + size_t maxlen, const char *buf, size_t len, + unsigned int width, unsigned int flags ) { - const size_t start_idx = idx; - size_t i; - // pad spaces up to given width - if (!(flags & FLAGS_LEFT) && !(flags & FLAGS_ZEROPAD)) { - for (i = len; i < width; i++) { - out(' ', buffer, idx++, maxlen); - } - } - - // reverse string - while (len) { - out(buf[--len], buffer, idx++, maxlen); - } - - // append pad spaces up to given width - if (flags & FLAGS_LEFT) { - while (idx - start_idx < width) { - out(' ', buffer, idx++, maxlen); - } - } - - return idx; -} + const size_t start_idx = idx; + size_t i; + // pad spaces up to given width + if ( !( flags & FLAGS_LEFT ) && !( flags & FLAGS_ZEROPAD ) ) { + for ( i = len; i < width; i++ ) { + out( ' ', buffer, idx++, maxlen ); + } + } + // reverse string + while ( len ) { + out( buf[--len], buffer, idx++, maxlen ); + } + + // append pad spaces up to given width + if ( flags & FLAGS_LEFT ) { + while ( idx - start_idx < width ) { + out( ' ', buffer, idx++, maxlen ); + } + } + + return idx; +} // internal itoa format -static size_t _ntoa_format(out_fct_type out, char* buffer, size_t idx, size_t maxlen, char* buf, size_t len, bool negative, unsigned int base, unsigned int prec, unsigned int width, unsigned int flags) +static size_t _ntoa_format( out_fct_type out, char *buffer, size_t idx, + size_t maxlen, char *buf, size_t len, + bool negative, unsigned int base, + unsigned int prec, unsigned int width, + unsigned int flags ) { - // pad leading zeros - if (!(flags & FLAGS_LEFT)) { - if (width && (flags & FLAGS_ZEROPAD) && (negative || (flags & (FLAGS_PLUS | FLAGS_SPACE)))) { - width--; - } - while ((len < prec) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = '0'; - } - while ((flags & FLAGS_ZEROPAD) && (len < width) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = '0'; - } - } - - // handle hash - if (flags & FLAGS_HASH) { - if (!(flags & FLAGS_PRECISION) && len && ((len == prec) || (len == width))) { - len--; - if (len && (base == 16U)) { - len--; + // pad leading zeros + if ( !( flags & FLAGS_LEFT ) ) { + if ( width && ( flags & FLAGS_ZEROPAD ) && + ( negative || ( flags & ( FLAGS_PLUS | FLAGS_SPACE ) ) ) ) { + width--; } - } - if ((base == 16U) && !(flags & FLAGS_UPPERCASE) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = 'x'; - } - else if ((base == 16U) && (flags & FLAGS_UPPERCASE) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = 'X'; - } - else if ((base == 2U) && (len < PRINTF_NTOA_BUFFER_SIZE)) { - buf[len++] = 'b'; - } - if (len < PRINTF_NTOA_BUFFER_SIZE) { - buf[len++] = '0'; - } - } - - if (len < PRINTF_NTOA_BUFFER_SIZE) { - if (negative) { - buf[len++] = '-'; - } - else if (flags & FLAGS_PLUS) { - buf[len++] = '+'; // ignore the space if the '+' exists - } - else if (flags & FLAGS_SPACE) { - buf[len++] = ' '; - } - } - - return _out_rev(out, buffer, idx, maxlen, buf, len, width, flags); -} + while ( ( len < prec ) && ( len < PRINTF_NTOA_BUFFER_SIZE ) ) { + buf[len++] = '0'; + } + while ( ( flags & FLAGS_ZEROPAD ) && ( len < width ) && + ( len < PRINTF_NTOA_BUFFER_SIZE ) ) { + buf[len++] = '0'; + } + } + + // handle hash + if ( flags & FLAGS_HASH ) { + if ( !( flags & FLAGS_PRECISION ) && len && + ( ( len == prec ) || ( len == width ) ) ) { + len--; + if ( len && ( base == 16U ) ) { + len--; + } + } + if ( ( base == 16U ) && !( flags & FLAGS_UPPERCASE ) && + ( len < PRINTF_NTOA_BUFFER_SIZE ) ) { + buf[len++] = 'x'; + } + else if ( ( base == 16U ) && ( flags & FLAGS_UPPERCASE ) && + ( len < PRINTF_NTOA_BUFFER_SIZE ) ) { + buf[len++] = 'X'; + } + else if ( ( base == 2U ) && ( len < PRINTF_NTOA_BUFFER_SIZE ) ) { + buf[len++] = 'b'; + } + if ( len < PRINTF_NTOA_BUFFER_SIZE ) { + buf[len++] = '0'; + } + } + if ( len < PRINTF_NTOA_BUFFER_SIZE ) { + if ( negative ) { + buf[len++] = '-'; + } + else if ( flags & FLAGS_PLUS ) { + buf[len++] = '+'; // ignore the space if the '+' exists + } + else if ( flags & FLAGS_SPACE ) { + buf[len++] = ' '; + } + } + + return _out_rev( out, buffer, idx, maxlen, buf, len, width, flags ); +} // internal itoa for 'long' type -static size_t _ntoa_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long value, bool negative, unsigned long base, unsigned int prec, unsigned int width, unsigned int flags) +static size_t _ntoa_long( out_fct_type out, char *buffer, size_t idx, + size_t maxlen, unsigned long value, bool negative, + unsigned long base, unsigned int prec, + unsigned int width, unsigned int flags ) { - char buf[PRINTF_NTOA_BUFFER_SIZE]; - size_t len = 0U; - - // no hash for 0 values - if (!value) { - flags &= ~FLAGS_HASH; - } - - // write if precision != 0 and value is != 0 - if (!(flags & FLAGS_PRECISION) || value) { - do { - const char digit = (char)(value % base); - buf[len++] = digit < 10 ? '0' + digit : (flags & FLAGS_UPPERCASE ? 'A' : 'a') + digit - 10; - value /= base; - } while (value && (len < PRINTF_NTOA_BUFFER_SIZE)); - } - - return _ntoa_format(out, buffer, idx, maxlen, buf, len, negative, (unsigned int)base, prec, width, flags); + char buf[PRINTF_NTOA_BUFFER_SIZE]; + size_t len = 0U; + + // no hash for 0 values + if ( !value ) { + flags &= ~FLAGS_HASH; + } + + // write if precision != 0 and value is != 0 + if ( !( flags & FLAGS_PRECISION ) || value ) { + do { + const char digit = (char)( value % base ); + buf[len++] = + digit < 10 ? '0' + digit + : ( flags & FLAGS_UPPERCASE ? 'A' : 'a' ) + digit - 10; + value /= base; + } while ( value && ( len < PRINTF_NTOA_BUFFER_SIZE ) ); + } + + return _ntoa_format( out, buffer, idx, maxlen, buf, len, negative, + (unsigned int)base, prec, width, flags ); } - // internal itoa for 'long long' type -#if defined(PRINTF_SUPPORT_LONG_LONG) -static size_t _ntoa_long_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long long value, bool negative, unsigned long long base, unsigned int prec, unsigned int width, unsigned int flags) +#if defined( PRINTF_SUPPORT_LONG_LONG ) +static size_t _ntoa_long_long( out_fct_type out, char *buffer, size_t idx, + size_t maxlen, unsigned long long value, + bool negative, unsigned long long base, + unsigned int prec, unsigned int width, + unsigned int flags ) { - char buf[PRINTF_NTOA_BUFFER_SIZE]; - size_t len = 0U; - - // no hash for 0 values - if (!value) { - flags &= ~FLAGS_HASH; - } - - // write if precision != 0 and value is != 0 - if (!(flags & FLAGS_PRECISION) || value) { - do { - const char digit = (char)(value % base); - buf[len++] = digit < 10 ? '0' + digit : (flags & FLAGS_UPPERCASE ? 'A' : 'a') + digit - 10; - value /= base; - } while (value && (len < PRINTF_NTOA_BUFFER_SIZE)); - } - - return _ntoa_format(out, buffer, idx, maxlen, buf, len, negative, (unsigned int)base, prec, width, flags); + char buf[PRINTF_NTOA_BUFFER_SIZE]; + size_t len = 0U; + + // no hash for 0 values + if ( !value ) { + flags &= ~FLAGS_HASH; + } + + // write if precision != 0 and value is != 0 + if ( !( flags & FLAGS_PRECISION ) || value ) { + do { + const char digit = (char)( value % base ); + buf[len++] = + digit < 10 ? '0' + digit + : ( flags & FLAGS_UPPERCASE ? 'A' : 'a' ) + digit - 10; + value /= base; + } while ( value && ( len < PRINTF_NTOA_BUFFER_SIZE ) ); + } + + return _ntoa_format( out, buffer, idx, maxlen, buf, len, negative, + (unsigned int)base, prec, width, flags ); } -#endif // PRINTF_SUPPORT_LONG_LONG - +#endif // PRINTF_SUPPORT_LONG_LONG // internal vsnprintf -static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const char* format, va_list va) +static int _vsnprintf( out_fct_type out, char *buffer, const size_t maxlen, + const char *format, va_list va ) { - unsigned int flags, width, precision, n; - size_t idx = 0U; - - if (!buffer) { - // use null output function - out = _out_null; - } - - while (*format) - { - // format specifier? %[flags][width][.precision][length] - if (*format != '%') { - // no - out(*format, buffer, idx++, maxlen); - format++; - continue; - } - else { - // yes, evaluate it - format++; - } - - // evaluate flags - flags = 0U; - do { - switch (*format) { - case '0': flags |= FLAGS_ZEROPAD; format++; n = 1U; break; - case '-': flags |= FLAGS_LEFT; format++; n = 1U; break; - case '+': flags |= FLAGS_PLUS; format++; n = 1U; break; - case ' ': flags |= FLAGS_SPACE; format++; n = 1U; break; - case '#': flags |= FLAGS_HASH; format++; n = 1U; break; - default : n = 0U; break; - } - } while (n); - - // evaluate width field - width = 0U; - if (_is_digit(*format)) { - width = _atoi(&format); - } - else if (*format == '*') { - const int w = va_arg(va, int); - if (w < 0) { - flags |= FLAGS_LEFT; // reverse padding - width = (unsigned int)-w; + unsigned int flags, width, precision, n; + size_t idx = 0U; + + if ( !buffer ) { + // use null output function + out = _out_null; + } + + while ( *format ) { + // format specifier? %[flags][width][.precision][length] + if ( *format != '%' ) { + // no + out( *format, buffer, idx++, maxlen ); + format++; + continue; } else { - width = (unsigned int)w; + // yes, evaluate it + format++; + } + + // evaluate flags + flags = 0U; + do { + switch ( *format ) { + case '0': + flags |= FLAGS_ZEROPAD; + format++; + n = 1U; + break; + case '-': + flags |= FLAGS_LEFT; + format++; + n = 1U; + break; + case '+': + flags |= FLAGS_PLUS; + format++; + n = 1U; + break; + case ' ': + flags |= FLAGS_SPACE; + format++; + n = 1U; + break; + case '#': + flags |= FLAGS_HASH; + format++; + n = 1U; + break; + default: + n = 0U; + break; + } + } while ( n ); + + // evaluate width field + width = 0U; + if ( _is_digit( *format ) ) { + width = _atoi( &format ); } - format++; - } - - // evaluate precision field - precision = 0U; - if (*format == '.') { - flags |= FLAGS_PRECISION; - format++; - if (_is_digit(*format)) { - precision = _atoi(&format); + else if ( *format == '*' ) { + const int w = va_arg( va, int ); + if ( w < 0 ) { + flags |= FLAGS_LEFT; // reverse padding + width = (unsigned int)-w; + } + else { + width = (unsigned int)w; + } + format++; } - else if (*format == '*') { - const int prec = (int)va_arg(va, int); - precision = prec > 0 ? (unsigned int)prec : 0U; - format++; + + // evaluate precision field + precision = 0U; + if ( *format == '.' ) { + flags |= FLAGS_PRECISION; + format++; + if ( _is_digit( *format ) ) { + precision = _atoi( &format ); + } + else if ( *format == '*' ) { + const int prec = (int)va_arg( va, int ); + precision = prec > 0 ? (unsigned int)prec : 0U; + format++; + } } - } - - // evaluate length field - switch (*format) { - case 'l' : - flags |= FLAGS_LONG; - format++; - if (*format == 'l') { - flags |= FLAGS_LONG_LONG; - format++; - } - break; - case 'h' : - flags |= FLAGS_SHORT; - format++; - if (*format == 'h') { - flags |= FLAGS_CHAR; - format++; - } - break; -#if defined(PRINTF_SUPPORT_PTRDIFF_T) - case 't' : - flags |= (sizeof(ptrdiff_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); - format++; - break; + + // evaluate length field + switch ( *format ) { + case 'l': + flags |= FLAGS_LONG; + format++; + if ( *format == 'l' ) { + flags |= FLAGS_LONG_LONG; + format++; + } + break; + case 'h': + flags |= FLAGS_SHORT; + format++; + if ( *format == 'h' ) { + flags |= FLAGS_CHAR; + format++; + } + break; +#if defined( PRINTF_SUPPORT_PTRDIFF_T ) + case 't': + flags |= ( sizeof( ptrdiff_t ) == sizeof( long ) ? FLAGS_LONG + : FLAGS_LONG_LONG ); + format++; + break; #endif - case 'j' : - flags |= (sizeof(intmax_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); - format++; - break; - case 'z' : - flags |= (sizeof(size_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); - format++; - break; - default : - break; - } - - // evaluate specifier - switch (*format) { - case 'd' : - case 'i' : - case 'u' : - case 'x' : - case 'X' : - case 'o' : - case 'b' : { - // set the base - unsigned int base; - if (*format == 'x' || *format == 'X') { - base = 16U; - } - else if (*format == 'o') { - base = 8U; - } - else if (*format == 'b') { - base = 2U; - } - else { - base = 10U; - flags &= ~FLAGS_HASH; // no hash for dec format - } - // uppercase - if (*format == 'X') { - flags |= FLAGS_UPPERCASE; - } - - // no plus or space flag for u, x, X, o, b - if ((*format != 'i') && (*format != 'd')) { - flags &= ~(FLAGS_PLUS | FLAGS_SPACE); - } - - // ignore '0' flag when precision is given - if (flags & FLAGS_PRECISION) { - flags &= ~FLAGS_ZEROPAD; - } - - // convert the integer - if ((*format == 'i') || (*format == 'd')) { - // signed - if (flags & FLAGS_LONG_LONG) { -#if defined(PRINTF_SUPPORT_LONG_LONG) - const long long value = va_arg(va, long long); - idx = _ntoa_long_long(out, buffer, idx, maxlen, (unsigned long long)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags); + case 'j': + flags |= ( sizeof( intmax_t ) == sizeof( long ) ? FLAGS_LONG + : FLAGS_LONG_LONG ); + format++; + break; + case 'z': + flags |= ( sizeof( size_t ) == sizeof( long ) ? FLAGS_LONG + : FLAGS_LONG_LONG ); + format++; + break; + default: + break; + } + + // evaluate specifier + switch ( *format ) { + case 'd': + case 'i': + case 'u': + case 'x': + case 'X': + case 'o': + case 'b': { + // set the base + unsigned int base; + if ( *format == 'x' || *format == 'X' ) { + base = 16U; + } + else if ( *format == 'o' ) { + base = 8U; + } + else if ( *format == 'b' ) { + base = 2U; + } + else { + base = 10U; + flags &= ~FLAGS_HASH; // no hash for dec format + } + // uppercase + if ( *format == 'X' ) { + flags |= FLAGS_UPPERCASE; + } + + // no plus or space flag for u, x, X, o, b + if ( ( *format != 'i' ) && ( *format != 'd' ) ) { + flags &= ~( FLAGS_PLUS | FLAGS_SPACE ); + } + + // ignore '0' flag when precision is given + if ( flags & FLAGS_PRECISION ) { + flags &= ~FLAGS_ZEROPAD; + } + + // convert the integer + if ( ( *format == 'i' ) || ( *format == 'd' ) ) { + // signed + if ( flags & FLAGS_LONG_LONG ) { +#if defined( PRINTF_SUPPORT_LONG_LONG ) + const long long value = va_arg( va, long long ); + idx = _ntoa_long_long( + out, buffer, idx, maxlen, + (unsigned long long)( value > 0 ? value : 0 - value ), + value < 0, base, precision, width, flags ); #endif - } - else if (flags & FLAGS_LONG) { - const long value = va_arg(va, long); - idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags); - } - else { - const int value = (flags & FLAGS_CHAR) ? (char)va_arg(va, int) : (flags & FLAGS_SHORT) ? (short int)va_arg(va, int) : va_arg(va, int); - idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned int)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags); - } - } - else { - // unsigned - if (flags & FLAGS_LONG_LONG) { -#if defined(PRINTF_SUPPORT_LONG_LONG) - idx = _ntoa_long_long(out, buffer, idx, maxlen, va_arg(va, unsigned long long), false, base, precision, width, flags); + } + else if ( flags & FLAGS_LONG ) { + const long value = va_arg( va, long ); + idx = _ntoa_long( + out, buffer, idx, maxlen, + (unsigned long)( value > 0 ? value : 0 - value ), value < 0, + base, precision, width, flags ); + } + else { + const int value = + ( flags & FLAGS_CHAR ) ? (char)va_arg( va, int ) + : ( flags & FLAGS_SHORT ) ? (short int)va_arg( va, int ) + : va_arg( va, int ); + idx = + _ntoa_long( out, buffer, idx, maxlen, + (unsigned int)( value > 0 ? value : 0 - value ), + value < 0, base, precision, width, flags ); + } + } + else { + // unsigned + if ( flags & FLAGS_LONG_LONG ) { +#if defined( PRINTF_SUPPORT_LONG_LONG ) + idx = _ntoa_long_long( out, buffer, idx, maxlen, + va_arg( va, unsigned long long ), false, + base, precision, width, flags ); #endif - } - else if (flags & FLAGS_LONG) { - idx = _ntoa_long(out, buffer, idx, maxlen, va_arg(va, unsigned long), false, base, precision, width, flags); - } - else { - const unsigned int value = (flags & FLAGS_CHAR) ? (unsigned char)va_arg(va, unsigned int) : (flags & FLAGS_SHORT) ? (unsigned short int)va_arg(va, unsigned int) : va_arg(va, unsigned int); - idx = _ntoa_long(out, buffer, idx, maxlen, value, false, base, precision, width, flags); - } - } - format++; - break; + } + else if ( flags & FLAGS_LONG ) { + idx = _ntoa_long( out, buffer, idx, maxlen, + va_arg( va, unsigned long ), false, base, + precision, width, flags ); + } + else { + const unsigned int value = + ( flags & FLAGS_CHAR ) + ? (unsigned char)va_arg( va, unsigned int ) + : ( flags & FLAGS_SHORT ) + ? (unsigned short int)va_arg( va, unsigned int ) + : va_arg( va, unsigned int ); + idx = _ntoa_long( out, buffer, idx, maxlen, value, false, base, + precision, width, flags ); + } + } + format++; + break; } - case 'c' : { - unsigned int l = 1U; - // pre padding - if (!(flags & FLAGS_LEFT)) { - while (l++ < width) { - out(' ', buffer, idx++, maxlen); - } - } - // char output - out((char)va_arg(va, int), buffer, idx++, maxlen); - // post padding - if (flags & FLAGS_LEFT) { - while (l++ < width) { - out(' ', buffer, idx++, maxlen); - } - } - format++; - break; + case 'c': { + unsigned int l = 1U; + // pre padding + if ( !( flags & FLAGS_LEFT ) ) { + while ( l++ < width ) { + out( ' ', buffer, idx++, maxlen ); + } + } + // char output + out( (char)va_arg( va, int ), buffer, idx++, maxlen ); + // post padding + if ( flags & FLAGS_LEFT ) { + while ( l++ < width ) { + out( ' ', buffer, idx++, maxlen ); + } + } + format++; + break; } - case 's' : { - const char* p = va_arg(va, char*); - unsigned int l = _strnlen_s(p, precision ? precision : (size_t)-1); - // pre padding - if (flags & FLAGS_PRECISION) { - l = (l < precision ? l : precision); - } - if (!(flags & FLAGS_LEFT)) { - while (l++ < width) { - out(' ', buffer, idx++, maxlen); - } - } - // string output - while ((*p != 0) && (!(flags & FLAGS_PRECISION) || precision--)) { - out(*(p++), buffer, idx++, maxlen); - } - // post padding - if (flags & FLAGS_LEFT) { - while (l++ < width) { - out(' ', buffer, idx++, maxlen); - } - } - format++; - break; + case 's': { + const char *p = va_arg( va, char * ); + unsigned int l = _strnlen_s( p, precision ? precision : (size_t)-1 ); + // pre padding + if ( flags & FLAGS_PRECISION ) { + l = ( l < precision ? l : precision ); + } + if ( !( flags & FLAGS_LEFT ) ) { + while ( l++ < width ) { + out( ' ', buffer, idx++, maxlen ); + } + } + // string output + while ( ( *p != 0 ) && + ( !( flags & FLAGS_PRECISION ) || precision-- ) ) { + out( *( p++ ), buffer, idx++, maxlen ); + } + // post padding + if ( flags & FLAGS_LEFT ) { + while ( l++ < width ) { + out( ' ', buffer, idx++, maxlen ); + } + } + format++; + break; } - case 'p' : { - width = sizeof(void*) * 2U; - flags |= FLAGS_ZEROPAD | FLAGS_UPPERCASE; -#if defined(PRINTF_SUPPORT_LONG_LONG) - const bool is_ll = sizeof(uintptr_t) == sizeof(long long); - if (is_ll) { - idx = _ntoa_long_long(out, buffer, idx, maxlen, (uintptr_t)va_arg(va, void*), false, 16U, precision, width, flags); - } - else { + case 'p': { + width = sizeof( void * ) * 2U; + flags |= FLAGS_ZEROPAD | FLAGS_UPPERCASE; +#if defined( PRINTF_SUPPORT_LONG_LONG ) + const bool is_ll = sizeof( uintptr_t ) == sizeof( long long ); + if ( is_ll ) { + idx = _ntoa_long_long( out, buffer, idx, maxlen, + (uintptr_t)va_arg( va, void * ), false, + 16U, precision, width, flags ); + } + else { #endif - idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)((uintptr_t)va_arg(va, void*)), false, 16U, precision, width, flags); -#if defined(PRINTF_SUPPORT_LONG_LONG) - } + idx = + _ntoa_long( out, buffer, idx, maxlen, + (unsigned long)( (uintptr_t)va_arg( va, void * ) ), + false, 16U, precision, width, flags ); +#if defined( PRINTF_SUPPORT_LONG_LONG ) + } #endif - format++; - break; + format++; + break; } - case '%' : - out('%', buffer, idx++, maxlen); - format++; - break; + case '%': + out( '%', buffer, idx++, maxlen ); + format++; + break; - default : - out(*format, buffer, idx++, maxlen); - format++; - break; - } - } + default: + out( *format, buffer, idx++, maxlen ); + format++; + break; + } + } - // termination - out((char)0, buffer, idx < maxlen ? idx : maxlen - 1U, maxlen); + // termination + out( (char)0, buffer, idx < maxlen ? idx : maxlen - 1U, maxlen ); - // return written chars without terminating \0 - return (int)idx; + // return written chars without terminating \0 + return (int)idx; } - /////////////////////////////////////////////////////////////////////////////// -int con_printf(const char* format, ...) +int con_printf( const char *format, ... ) { - va_list va; - char buffer[1]; - int ret; - - con_disable_cursor_sync(); - va_start(va, format); - ret = _vsnprintf(_out_char, buffer, (size_t)-1, format, va); - va_end(va); - con_enable_cursor_sync(); - - return ret; -} + va_list va; + char buffer[1]; + int ret; + con_disable_cursor_sync(); + va_start( va, format ); + ret = _vsnprintf( _out_char, buffer, (size_t)-1, format, va ); + va_end( va ); + con_enable_cursor_sync(); -int con_sprintf(char* buffer, const char* format, ...) -{ - va_list va; - int ret; - va_start(va, format); - ret = _vsnprintf(_out_buffer, buffer, (size_t)-1, format, va); - va_end(va); - return ret; + return ret; } - -int con_snprintf(char* buffer, size_t count, const char* format, ...) +int con_sprintf( char *buffer, const char *format, ... ) { - va_list va; - int ret; - va_start(va, format); - ret = _vsnprintf(_out_buffer, buffer, count, format, va); - va_end(va); - return ret; + va_list va; + int ret; + va_start( va, format ); + ret = _vsnprintf( _out_buffer, buffer, (size_t)-1, format, va ); + va_end( va ); + return ret; } - -int con_vprintf(const char* format, va_list va) +int con_snprintf( char *buffer, size_t count, const char *format, ... ) { - char buffer[1]; - return _vsnprintf(_out_char, buffer, (size_t)-1, format, va); + va_list va; + int ret; + va_start( va, format ); + ret = _vsnprintf( _out_buffer, buffer, count, format, va ); + va_end( va ); + return ret; } +int con_vprintf( const char *format, va_list va ) +{ + char buffer[1]; + return _vsnprintf( _out_char, buffer, (size_t)-1, format, va ); +} -int con_vsnprintf(char* buffer, size_t count, const char* format, va_list va) +int con_vsnprintf( char *buffer, size_t count, const char *format, + va_list va ) { - int res; + int res; - con_disable_cursor_sync(); - res = _vsnprintf(_out_buffer, buffer, count, format, va); - con_enable_cursor_sync(); + con_disable_cursor_sync(); + res = _vsnprintf( _out_buffer, buffer, count, format, va ); + con_enable_cursor_sync(); - return res; + return res; } - -int fctprintf(void (*out)(char character, void* arg), void* arg, const char* format, ...) +int fctprintf( void ( *out )( char character, void *arg ), void *arg, + const char *format, ... ) { - va_list va; - out_fct_wrap_type out_fct_wrap; - int ret; - va_start(va, format); - out_fct_wrap.fct = out; - out_fct_wrap.arg = arg; - ret = _vsnprintf(_out_fct, (char*)(uintptr_t)&out_fct_wrap, (size_t)-1, format, va); - va_end(va); - return ret; + va_list va; + out_fct_wrap_type out_fct_wrap; + int ret; + va_start( va, format ); + out_fct_wrap.fct = out; + out_fct_wrap.arg = arg; + ret = _vsnprintf( _out_fct, (char *)(uintptr_t)&out_fct_wrap, (size_t)-1, + format, va ); + va_end( va ); + return ret; } diff --git a/source/fdisk/printf.h b/source/fdisk/printf.h index d7ab457..b54a766 100644 --- a/source/fdisk/printf.h +++ b/source/fdisk/printf.h @@ -11,10 +11,10 @@ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -36,7 +36,6 @@ #include #include - #ifdef __cplusplus extern "C" { #endif @@ -49,8 +48,7 @@ extern "C" { * \param format A string that specifies the format of the output * \return The number of characters that are written into the array, not counting the terminating null character */ -int con_printf(const char* format, ...); - +int con_printf( const char *format, ... ); /** * Tiny sprintf implementation @@ -59,8 +57,7 @@ int con_printf(const char* format, ...); * \param format A string that specifies the format of the output * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character */ -int con_sprintf(char* buffer, const char* format, ...); - +int con_sprintf( char *buffer, const char *format, ... ); /** * Tiny snprintf/vsnprintf implementation @@ -72,9 +69,9 @@ int con_sprintf(char* buffer, const char* format, ...); * null character. A value equal or larger than count indicates truncation. Only when the returned value * is non-negative and less than count, the string has been completely written. */ -int con_snprintf(char* buffer, size_t count, const char* format, ...); -int con_vsnprintf(char* buffer, size_t count, const char* format, va_list va); - +int con_snprintf( char *buffer, size_t count, const char *format, ... ); +int con_vsnprintf( char *buffer, size_t count, const char *format, + va_list va ); /** * Tiny vprintf implementation @@ -82,11 +79,10 @@ int con_vsnprintf(char* buffer, size_t count, const char* format, va_list va); * \param va A value identifying a variable arguments list * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character */ -int con_vprintf(const char* format, va_list va); +int con_vprintf( const char *format, va_list va ); #ifdef __cplusplus } #endif - -#endif // _PRINTF_H_ +#endif // _PRINTF_H_ diff --git a/source/fdisk/userint0.c b/source/fdisk/userint0.c index a297429..70bca46 100644 --- a/source/fdisk/userint0.c +++ b/source/fdisk/userint0.c @@ -13,21 +13,19 @@ #include "userint0.h" - /* Pause Routine */ void Pause( void ) { - con_putc('\n'); - con_print(svarlang_str(250,3)); + con_putc( '\n' ); + con_print( svarlang_str( 250, 3 ) ); /* wait for keypress */ con_readkey(); - con_putc('\r'); + con_putc( '\r' ); con_clreol(); } - /* Display Information */ void Display_Information( void ) { @@ -99,13 +97,12 @@ void Display_Information( void ) con_print( "DEBUG" ); if ( debug.write == FALSE ) { - con_set_cursor_xy(70, 1); + con_set_cursor_xy( 70, 1 ); con_print( "RO" ); } #endif } - /* Print Centered Text */ void Print_Centered( int y, const char *text, int style ) { @@ -118,22 +115,18 @@ void Print_Centered( int y, const char *text, int style ) con_set_bold( 1 ); } con_print( text ); - con_set_bold(was_bold); + con_set_bold( was_bold ); } - /* Print 7 Digit Unsigned Long Values */ -void Print_UL( unsigned long number ) { - con_printf( "%7lu", number ); -} - +void Print_UL( unsigned long number ) { con_printf( "%7lu", number ); } /* Print 7 Digit Unsigned Long Values in bold print */ -void Print_UL_B( unsigned long number ) { +void Print_UL_B( unsigned long number ) +{ con_printf( "\33[1m%7lu\33[22m", number ); } - /* Dump the partition tables from all drives to screen */ void Dump_Partition_Information( void ) { @@ -147,7 +140,6 @@ void Dump_Partition_Information( void ) } while ( index + 128 <= flags.maximum_drive_number ); } - void Display_CL_Partition_Table( void ) { int index = 0; @@ -159,11 +151,12 @@ void Display_CL_Partition_Table( void ) Determine_Drive_Letters(); /* NLS:Current fixed disk drive: */ - con_printf( "\n%s %1d", svarlang_str( 9, 0 ), ( flags.drive_number - 127 ) ); + con_printf( "\n%s %1d", svarlang_str( 9, 0 ), + ( flags.drive_number - 127 ) ); - con_printf( " %lu %s %lu/%03lu/%02lu", pDrive->disk_size_sect, svarlang_str( 9, 3 ), - pDrive->total_cyl + 1, pDrive->total_head + 1, - pDrive->total_sect ); + con_printf( " %lu %s %lu/%03lu/%02lu", pDrive->disk_size_sect, + svarlang_str( 9, 3 ), pDrive->total_cyl + 1, + pDrive->total_head + 1, pDrive->total_sect ); if ( !Is_Pri_Tbl_Empty() ) { /* NLS:Partition Status Mbytes Description [...] */ @@ -171,9 +164,9 @@ void Display_CL_Partition_Table( void ) } else { /*NLS:No partitions defined. */ - con_print("\n\n"); + con_print( "\n\n" ); con_print( svarlang_str( 9, 4 ) ); - con_print("\n"); + con_print( "\n" ); } index = 0; @@ -209,32 +202,27 @@ void Display_CL_Partition_Table( void ) Print_UL( p->size_in_MB ); /* Description */ - con_printf( " %-15s", part_type_descr( p->num_type )); + con_printf( " %-15s", part_type_descr( p->num_type ) ); /* Usage */ - usage = Convert_To_Percentage( p->size_in_MB, - pDrive->disk_size_mb ); + usage = Convert_To_Percentage( p->size_in_MB, pDrive->disk_size_mb ); con_printf( " %3lu%%", usage ); /* Starting Cylinder */ - con_printf( "%6lu/%03lu/%02lu", p->start_cyl, - p->start_head, - p->start_sect ); + con_printf( "%6lu/%03lu/%02lu", p->start_cyl, p->start_head, + p->start_sect ); /* Ending Cylinder */ - con_printf( " %6lu/%03lu/%02lu", p->end_cyl, - p->end_head, - p->end_sect ); - con_putc('\n'); + con_printf( " %6lu/%03lu/%02lu", p->end_cyl, p->end_head, + p->end_sect ); + con_putc( '\n' ); } index++; } while ( index < 4 ); /* NLS:Largest continious free space for primary partition */ - con_printf( - svarlang_str( 9, 5 ), - Max_Pri_Free_Space_In_MB() ); + con_printf( svarlang_str( 9, 5 ), Max_Pri_Free_Space_In_MB() ); /* Check to see if there are any drives to display */ if ( ( brief_partition_table[( flags.drive_number - 128 )][4] > 0 ) || @@ -253,8 +241,8 @@ void Display_CL_Partition_Table( void ) if ( IsRecognizedFatPartition( brief_partition_table[( flags.drive_number - 128 )][index] ) ) { /* Display drive letter */ - con_printf( " %1c:", drive_lettering_buffer[( flags.drive_number - - 128 )][index] ); + con_printf( " %1c:", drive_lettering_buffer[( + flags.drive_number - 128 )][index] ); /* Display volume label */ con_printf( " %11s", p->vol_label ); @@ -268,27 +256,22 @@ void Display_CL_Partition_Table( void ) Print_UL( p->size_in_MB ); /* Display file system type */ - con_printf( " %-15s", - part_type_descr( - p->num_type )); + con_printf( " %-15s", part_type_descr( p->num_type ) ); /* Display usage in % */ - usage = Convert_To_Percentage( - p->num_sect, pDrive->ext_num_sect ); + usage = + Convert_To_Percentage( p->num_sect, pDrive->ext_num_sect ); con_printf( " %3lu%%", usage ); /* Starting Cylinder */ - con_printf( "%6lu/%03lu/%02lu", - p->start_cyl, - p->start_head, - p->start_sect ); + con_printf( "%6lu/%03lu/%02lu", p->start_cyl, p->start_head, + p->start_sect ); /* Ending Cylinder */ - con_printf( " %6lu/%03lu/%02lu", p->end_cyl, - p->end_head, - p->end_sect ); - con_putc('\n'); + con_printf( " %6lu/%03lu/%02lu", p->end_cyl, p->end_head, + p->end_sect ); + con_putc( '\n' ); } index++; @@ -296,10 +279,9 @@ void Display_CL_Partition_Table( void ) /*NLS:Largest continious free space in extended partition [...] */ con_printf( svarlang_str( 9, 7 ), Max_Log_Free_Space_In_MB() ); } - con_putc('\n'); + con_putc( '\n' ); } - /* Display information for all hard drives */ void Display_All_Drives( void ) { @@ -337,8 +319,9 @@ void Display_All_Drives( void ) space_used_on_drive_in_MB = 0; /* Print drive number */ - con_set_cursor_xy( current_column_offset_of_general_drive_information + 1, - current_line + 1 ); + con_set_cursor_xy( current_column_offset_of_general_drive_information + + 1, + current_line + 1 ); con_printf( ESC_BOLD_ON "%d" ESC_BOLD_OFF, drive ); /* Print size of drive */ @@ -352,7 +335,7 @@ void Display_All_Drives( void ) con_set_cursor_xy( ( current_column_offset_of_general_drive_information + 11 ), - current_line +1 ); + current_line + 1 ); Print_UL( part_table[drive - 1].disk_size_mb ); /* Get space_used_on_drive_in_MB */ @@ -393,17 +376,20 @@ void Display_All_Drives( void ) ( drive_lettering_buffer[drive - 1][drive_letter_index] <= 'Z' ) ) || ( flags.del_non_dos_log_drives == TRUE ) ) { - con_set_cursor_xy( ( current_column_offset + 7 ), current_line + 1 ); + con_set_cursor_xy( ( current_column_offset + 7 ), + current_line + 1 ); con_printf( "%c:", drive_lettering_buffer[drive - 1][drive_letter_index] ); } else { - con_set_cursor_xy( ( current_column_offset + 9 ), current_line + 1); + con_set_cursor_xy( ( current_column_offset + 9 ), + current_line + 1 ); } /* Print size of logical drive */ - con_set_cursor_xy( ( current_column_offset + 11 ), current_line + 1); + con_set_cursor_xy( ( current_column_offset + 11 ), + current_line + 1 ); if ( drive_letter_index < 4 ) { Print_UL( part_table[drive - 1] @@ -425,7 +411,7 @@ void Display_All_Drives( void ) if ( part_table[drive - 1].disk_size_mb > space_used_on_drive_in_MB ) { con_set_cursor_xy( ( current_column_offset_of_general_drive_information + 19 ), - current_line_of_general_drive_information + 1); + current_line_of_general_drive_information + 1 ); Print_UL( part_table[drive - 1].disk_size_mb - space_used_on_drive_in_MB ); } @@ -441,7 +427,7 @@ void Display_All_Drives( void ) con_set_cursor_xy( ( current_column_offset_of_general_drive_information + 29 ), - current_line_of_general_drive_information + 1); + current_line_of_general_drive_information + 1 ); con_printf( "%3d%%", usage ); current_line++; @@ -454,55 +440,56 @@ void Display_All_Drives( void ) static struct { int id; - const char *descr; /* 17 characters max. */ - const char *descr_short; /* 9 characters max. */ -} pt_descr[] = { - { 0x00, "Unused"}, - { 0x01, "FAT-12", "FAT12"}, - { 0x04, "FAT-16 <32M", "FAT16"}, - { 0x05, "Extended", "Ext"}, - { 0x06, "FAT-16", "FAT16"}, - { 0x07, "NTFS / HPFS", "NTFS"}, - { 0x0b, "FAT-32", "FAT32"}, - { 0x0c, "FAT-32 LBA", "FAT32 LBA"}, - { 0x0e, "FAT-16 LBA", "FAT32 LBA"}, - { 0x0f, "Extended LBA", "Ext LBA"}, - - { 0x11, "Hid. FAT-12", "H FAT12"}, - { 0x14, "Hid. FAT-16<32M", "H FAT16"}, - { 0x15, "Hid. Extended", "H Ext"}, - { 0x16, "Hid. FAT-16", "H FAT16"}, - { 0x17, "Hid. NTFS/HPFS", "H NTFS"}, - { 0x1b, "Hid. FAT-32", "H FAT32"}, - { 0x1c, "Hid. FAT-32 LBA", "H FAT32 L"}, - { 0x1e, "Hid. FAT-16 LBA", "H FAT16 L"}, - { 0x1f, "Hid. Ext. LBA", "H Ext L"}, - - { 0x82, "Linux Swap", "LinuxSwap"}, - { 0x83, "Linux"}, - - { 0xa5, "BSD"}, - { 0xa6, "OpenBSD"}, - { 0xa9, "NetBSD"}, - - { 0xee, "GPT protective", "GPTprot"}, - { 0xeb, "EFI"}, - - { -1, "Unknown" } -}; - -const char *part_type_descr(int id) + const char *descr; /* 17 characters max. */ + const char *descr_short; /* 9 characters max. */ +} pt_descr[] = { { 0x00, "Unused" }, + { 0x01, "FAT-12", "FAT12" }, + { 0x04, "FAT-16 <32M", "FAT16" }, + { 0x05, "Extended", "Ext" }, + { 0x06, "FAT-16", "FAT16" }, + { 0x07, "NTFS / HPFS", "NTFS" }, + { 0x0b, "FAT-32", "FAT32" }, + { 0x0c, "FAT-32 LBA", "FAT32 LBA" }, + { 0x0e, "FAT-16 LBA", "FAT32 LBA" }, + { 0x0f, "Extended LBA", "Ext LBA" }, + + { 0x11, "Hid. FAT-12", "H FAT12" }, + { 0x14, "Hid. FAT-16<32M", "H FAT16" }, + { 0x15, "Hid. Extended", "H Ext" }, + { 0x16, "Hid. FAT-16", "H FAT16" }, + { 0x17, "Hid. NTFS/HPFS", "H NTFS" }, + { 0x1b, "Hid. FAT-32", "H FAT32" }, + { 0x1c, "Hid. FAT-32 LBA", "H FAT32 L" }, + { 0x1e, "Hid. FAT-16 LBA", "H FAT16 L" }, + { 0x1f, "Hid. Ext. LBA", "H Ext L" }, + + { 0x82, "Linux Swap", "LinuxSwap" }, + { 0x83, "Linux" }, + + { 0xa5, "BSD" }, + { 0xa6, "OpenBSD" }, + { 0xa9, "NetBSD" }, + + { 0xee, "GPT protective", "GPTprot" }, + { 0xeb, "EFI" }, + + { -1, "Unknown" } }; + +const char *part_type_descr( int id ) { int i; - for ( i = 0; pt_descr[i].id != id && pt_descr[i].id >= 0; i++); + for ( i = 0; pt_descr[i].id != id && pt_descr[i].id >= 0; i++ ) + ; return pt_descr[i].descr; } -const char *part_type_descr_short(int id) +const char *part_type_descr_short( int id ) { int i; - for ( i = 0; pt_descr[i].id != id && pt_descr[i].id >= 0; i++); - return (pt_descr[i].descr_short) ? pt_descr[i].descr_short : pt_descr[i].descr; + for ( i = 0; pt_descr[i].id != id && pt_descr[i].id >= 0; i++ ) + ; + return ( pt_descr[i].descr_short ) ? pt_descr[i].descr_short + : pt_descr[i].descr; } diff --git a/source/fdisk/userint0.h b/source/fdisk/userint0.h index dc7d69c..6ac041e 100644 --- a/source/fdisk/userint0.h +++ b/source/fdisk/userint0.h @@ -12,7 +12,7 @@ void Print_Centered( int y, const char *text, int style ); void Display_All_Drives( void ); void Pause( void ); -const char *part_type_descr(int id); -const char *part_type_descr_short(int id); +const char *part_type_descr( int id ); +const char *part_type_descr_short( int id ); #endif diff --git a/source/fdisk/userint1.c b/source/fdisk/userint1.c index 6481ae6..f2e511d 100644 --- a/source/fdisk/userint1.c +++ b/source/fdisk/userint1.c @@ -5,26 +5,25 @@ #include #endif #include +#include #include #include #include -#include +#include "ansicon.h" #include "compat.h" #include "fdiskio.h" #include "kbdinput.h" #include "main.h" #include "pcompute.h" #include "pdiskio.h" +#include "printf.h" #include "userint0.h" #include "userint1.h" #include "userint2.h" -#include "ansicon.h" -#include "printf.h" #include "svarlang/svarlang.h" - void Clear_Screen( int type ) { con_clrscr(); @@ -36,9 +35,9 @@ void Clear_Screen( int type ) void Color_Print( const char *text ) { int was_bold = con_get_bold(); - con_set_bold(1); - con_print(text); - con_set_bold(was_bold); + con_set_bold( 1 ); + con_print( text ); + con_set_bold( was_bold ); } void Color_Printf( const char *format, ... ) @@ -46,16 +45,15 @@ void Color_Printf( const char *format, ... ) va_list arglist; int was_bold = con_get_bold(); - con_set_bold(1); + con_set_bold( 1 ); va_start( arglist, format ); con_vprintf( format, arglist ); va_end( arglist ); - con_set_bold(was_bold); + con_set_bold( was_bold ); } - void Print_At( int column, int row, const char *format, ... ) { va_list arglist; @@ -121,15 +119,22 @@ void Exit_Screen( void ) { if ( flags.partitions_have_changed == TRUE ) { if ( flags.reboot == FALSE ) { - Print_At(4, 11, svarlang_str(2,0)); /* You must restart your system */ - Print_At(4, 12, svarlang_str(2,1)); /* Any drives created must be formatted AFTER restart */ + Print_At( 4, 11, + svarlang_str( 2, 0 ) ); /* You must restart your system */ + Print_At( + 4, 12, + svarlang_str( + 2, + 1 ) ); /* Any drives created must be formatted AFTER restart */ Input( 0, 0, 0, ESC, 0, 0, ESCE, 0, 0, '\0', '\0' ); Clear_Screen( NOEXTRAS ); } else { - Color_Print_At(4, 13, svarlang_str(2,2)); /* System will now restart */ - Print_At(4, 15, svarlang_str(2,3)); /* Press key when ready... */ + Color_Print_At( 4, 13, + svarlang_str( 2, 2 ) ); /* System will now restart */ + Print_At( 4, 15, + svarlang_str( 2, 3 ) ); /* Press key when ready... */ /* Wait for a keypress. */ con_readkey(); @@ -146,7 +151,7 @@ void Warn_Incompatible_Ext( void ) { Clear_Screen( NOEXTRAS ); - Color_Print_At( 38, 4, svarlang_str(250, 4)); /* ERROR */ + Color_Print_At( 38, 4, svarlang_str( 250, 4 ) ); /* ERROR */ Position_Cursor( 0, 7 ); con_print( svarlang_str( 30, 20 ) ); @@ -431,15 +436,12 @@ void Interactive_User_Interface( void ) } if ( !file_pointer ) { - Color_Print_At( - 4, 22, - svarlang_str( 11, 0 ) ); + Color_Print_At( 4, 22, svarlang_str( 11, 0 ) ); } else { - fclose(file_pointer); + fclose( file_pointer ); Load_MBR( 0 ); - Color_Print_At( 4, 22, - svarlang_str( 11, 1 ) ); + Color_Print_At( 4, 22, svarlang_str( 11, 1 ) ); Read_Partition_Tables(); } Input( 0, 0, 0, ESC, 0, 0, ESCC, 0, 0, '\0', '\0' ); @@ -476,7 +478,6 @@ void Interactive_User_Interface( void ) Position_Cursor( 0, 0 ); } - /* Standard Menu Routine */ /* Displays the menus laid out in a standard format and returns the */ /* selection chosen by the user. */ @@ -505,34 +506,41 @@ int Standard_Menu( int menu ) if ( menu == MM ) { maximum_number_of_options = 4; - title = svarlang_str(3, 0); /* "FDISK Options" */ - option_1 = svarlang_str(3, 1); /* "Create DOS part or Logical Drive" */ - option_2 = svarlang_str(3, 2); /* Set Active partition */ - option_3 = svarlang_str(3, 3); /* Del part or Logical DOS Drive */ - - if (flags.extended_options_flag == FALSE) { - option_4 = svarlang_str(3,4); /* Display partition information */ - } else { - option_4 = svarlang_str(3,5); /* Display/Modify partition info */ + title = svarlang_str( 3, 0 ); /* "FDISK Options" */ + option_1 = + svarlang_str( 3, 1 ); /* "Create DOS part or Logical Drive" */ + option_2 = svarlang_str( 3, 2 ); /* Set Active partition */ + option_3 = svarlang_str( 3, 3 ); /* Del part or Logical DOS Drive */ + + if ( flags.extended_options_flag == FALSE ) { + option_4 = + svarlang_str( 3, 4 ); /* Display partition information */ + } + else { + option_4 = + svarlang_str( 3, 5 ); /* Display/Modify partition info */ } } if ( menu == CP ) { maximum_number_of_options = 3; - title = svarlang_str(4, 0); /* Create DOS Partition or Logical DOS Drive */ - option_1 = svarlang_str(4, 1); /* Create Primary DOS Partition */ - option_2 = svarlang_str(4, 2); /* Create Extended DOS Partition */ - option_3 = svarlang_str(4, 3); /* Create Log DOS Drive in Ext Part */ + title = svarlang_str( + 4, 0 ); /* Create DOS Partition or Logical DOS Drive */ + option_1 = svarlang_str( 4, 1 ); /* Create Primary DOS Partition */ + option_2 = svarlang_str( 4, 2 ); /* Create Extended DOS Partition */ + option_3 = + svarlang_str( 4, 3 ); /* Create Log DOS Drive in Ext Part */ option_4 = ""; } if ( menu == DP ) { maximum_number_of_options = 4; - title = svarlang_str(5, 0); /* Del DOS Part or Logical DOS Drive */ - option_1 = svarlang_str(5, 1); /* Delete Primary DOS Partition */ - option_2 = svarlang_str(5, 2); /* Delete Extended DOS Partition */ - option_3 = svarlang_str(5, 3); /* Del Log DOS Drive in Ext DOS Part */ - option_4 = svarlang_str(5, 4); /* Delete Non-DOS Partition */ + title = svarlang_str( 5, 0 ); /* Del DOS Part or Logical DOS Drive */ + option_1 = svarlang_str( 5, 1 ); /* Delete Primary DOS Partition */ + option_2 = svarlang_str( 5, 2 ); /* Delete Extended DOS Partition */ + option_3 = + svarlang_str( 5, 3 ); /* Del Log DOS Drive in Ext DOS Part */ + option_4 = svarlang_str( 5, 4 ); /* Delete Non-DOS Partition */ if ( flags.version == COMP_FOUR ) { maximum_number_of_options = 3; } @@ -540,15 +548,15 @@ int Standard_Menu( int menu ) if ( menu == MBR ) { maximum_number_of_options = 4; - title = svarlang_str(6, 0); /* MBR Maintenance */ - option_1 = svarlang_str(6, 1); /* Create BootEasy MBR (disabled) */ - option_2 = svarlang_str(6, 2); /* Load MBR from saved file */ - option_3 = svarlang_str(6, 3); /* Save MBR to a file */ - option_4 = svarlang_str(6, 4); /* Remove boot code from the MBR */ + title = svarlang_str( 6, 0 ); /* MBR Maintenance */ + option_1 = svarlang_str( 6, 1 ); /* Create BootEasy MBR (disabled) */ + option_2 = svarlang_str( 6, 2 ); /* Load MBR from saved file */ + option_3 = svarlang_str( 6, 3 ); /* Save MBR to a file */ + option_4 = svarlang_str( 6, 4 ); /* Remove boot code from the MBR */ } /* Display Program Name and Copyright Information */ - Clear_Screen(0); + Clear_Screen( 0 ); if ( ( flags.extended_options_flag == TRUE ) && ( menu == MM ) ) { /* */ @@ -564,14 +572,15 @@ int Standard_Menu( int menu ) flags.display_name_description_copyright = FALSE; /* Display Menu Title(s) */ - Print_Centered(4, title, BOLD); + Print_Centered( 4, title, BOLD ); /* NLS:Current fixed disk drive: */ Print_At( 4, 6, svarlang_str( 9, 0 ) ); Color_Printf( " %d", ( flags.drive_number - 127 ) ); if ( part_table[flags.drive_number - 128].usable ) { - con_printf( svarlang_str( 9, 23 ), part_table[flags.drive_number - 128].disk_size_mb); + con_printf( svarlang_str( 9, 23 ), + part_table[flags.drive_number - 128].disk_size_mb ); } else { con_putc( ' ' ); @@ -608,27 +617,28 @@ int Standard_Menu( int menu ) if ( minimum_option <= 1 ) { Color_Print_At( 4, 10, "1. " ); - con_print(option_1); + con_print( option_1 ); } if ( maximum_number_of_options > 1 && minimum_option <= 2 ) { Color_Print_At( 4, 11, "2. " ); - con_print(option_2); + con_print( option_2 ); } if ( maximum_number_of_options > 2 && minimum_option <= 3 ) { Color_Print_At( 4, 12, "3. " ); - con_print(option_3); + con_print( option_3 ); } if ( maximum_number_of_options > 3 && minimum_option <= 4 ) { Color_Print_At( 4, 13, "4. " ); - con_print(option_4); + con_print( option_4 ); } if ( ( menu == MM ) && ( flags.more_than_one_drive == TRUE ) ) { maximum_number_of_options = 5; Color_Print_At( 4, 14, "5. " ); - con_print(svarlang_str(3, 6)); /* Change current fixed disk drive */ + con_print( + svarlang_str( 3, 6 ) ); /* Change current fixed disk drive */ } if ( menu == MM && flags.extended_options_flag == TRUE && @@ -671,7 +681,7 @@ int Standard_Menu( int menu ) /* NLS:Enter choice: */ Print_At( 4, 17, svarlang_str( 9, 1 ) ); - con_print(" "); + con_print( " " ); if ( menu == MM ) { input = (int)Input( 1, -1, -1, NUM, minimum_option, diff --git a/source/fdisk/userint2.c b/source/fdisk/userint2.c index 73cba1e..db35bb1 100644 --- a/source/fdisk/userint2.c +++ b/source/fdisk/userint2.c @@ -9,19 +9,18 @@ #include #include +#include "ansicon.h" #include "compat.h" #include "fdiskio.h" #include "kbdinput.h" #include "main.h" #include "pcompute.h" #include "pdiskio.h" +#include "printf.h" +#include "svarlang/svarlang.h" #include "userint0.h" #include "userint1.h" #include "userint2.h" -#include "ansicon.h" -#include "printf.h" -#include "svarlang/svarlang.h" - /* Ask user if they want to use large disk support (FAT 32) */ void Ask_User_About_FAT32_Support( void ) @@ -35,17 +34,17 @@ void Ask_User_About_FAT32_Support( void ) con_clrscr(); - con_puts( svarlang_str(1, 0) ); - con_puts( svarlang_str(1, 1) ); - con_puts( svarlang_str(1, 2) ); - con_puts( svarlang_str(1, 3) ); - con_puts(""); - con_puts( svarlang_str(1, 4) ); - con_puts( svarlang_str(1, 5) ); - con_puts( svarlang_str(1, 6) ); + con_puts( svarlang_str( 1, 0 ) ); + con_puts( svarlang_str( 1, 1 ) ); + con_puts( svarlang_str( 1, 2 ) ); + con_puts( svarlang_str( 1, 3 ) ); + con_puts( "" ); + con_puts( svarlang_str( 1, 4 ) ); + con_puts( svarlang_str( 1, 5 ) ); + con_puts( svarlang_str( 1, 6 ) ); /* "do you want to use large disk (FAT32) support (Y/N)...?" */ - con_print( svarlang_str(1, 7) ); + con_print( svarlang_str( 1, 7 ) ); con_print( " " ); flags.fat32 = (int)Input( 1, -1, -1, YN, 0, 0, NONE, 1, 0, '\0', '\0' ); } @@ -87,7 +86,7 @@ void Change_Current_Fixed_Disk_Drive( void ) con_set_cursor_xy( 5, 22 ); con_printf( svarlang_str( 10, 190 ), - ( flags.maximum_drive_number - 127 ) ); + ( flags.maximum_drive_number - 127 ) ); con_print( " " ); new_drive_number = (int)Input( 1, -1, -1, NUM, 1, ( flags.maximum_drive_number - 127 ), @@ -129,12 +128,10 @@ int Create_DOS_Partition_Interface( int type ) /* ask, if all space should be reserverd */ if ( ( flags.drive_number - 128 ) == 0 ) { - Print_At( - 4, 8, svarlang_str( 10, 60 ) ); + Print_At( 4, 8, svarlang_str( 10, 60 ) ); } else { - Print_At( - 4, 8, svarlang_str( 10, 61 ) ); + Print_At( 4, 8, svarlang_str( 10, 61 ) ); } con_print( " " ); @@ -258,7 +255,6 @@ int Create_DOS_Partition_Interface( int type ) Print_Centered( 4, svarlang_str( 4, 2 ), BOLD ); } - /* NLS:Current fixed disk drive: */ Print_At( 4, 6, svarlang_str( 9, 0 ) ); Color_Printf( " %d", ( flags.drive_number - 127 ) ); @@ -323,9 +319,7 @@ int Create_Logical_Drive_Interface( void ) con_print( svarlang_str( 30, 11 ) ); con_print( svarlang_str( 30, 12 ) ); - Print_At( - 4, 21, - svarlang_str( 30, 13) ); + Print_At( 4, 21, svarlang_str( 30, 13 ) ); con_print( " " ); yn = (int)Input( 1, -1, -1, YN, 0, 0, NONE, 1, 0, 0, 0 ); if ( yn ) { @@ -361,8 +355,7 @@ int Create_Logical_Drive_Interface( void ) con_clreol(); /* maximum number of Logical DOS Drives installed */ - Color_Print_At( - 4, 22, svarlang_str( 10, 71 ) ); + Color_Print_At( 4, 22, svarlang_str( 10, 71 ) ); Input( 0, 0, 0, ESC, 0, 0, ESCC, 0, 0, '\0', '\0' ); if ( flags.fprmt == TRUE ) { flags.fat32 = FALSE; @@ -377,7 +370,8 @@ int Create_Logical_Drive_Interface( void ) Print_At( 4, 17, svarlang_str( 10, 6 ), pDrive->ext_size_mb ); /* print maximum partition size */ - Print_At( 4, 18, svarlang_str( 10, 63 ), maximum_partition_size_in_MB ); + Print_At( 4, 18, svarlang_str( 10, 63 ), + maximum_partition_size_in_MB ); maximum_possible_percentage = (int)Convert_To_Percentage( maximum_partition_size_in_MB, pDrive->ext_size_mb ); @@ -385,9 +379,7 @@ int Create_Logical_Drive_Interface( void ) con_printf( " (\33[1m%d%%\33[22m)", maximum_possible_percentage ); /* enter partition size */ - Print_At( - 4, 20, - svarlang_str( 10, 72 ) ); + Print_At( 4, 20, svarlang_str( 10, 72 ) ); con_print( " " ); flags.esc = FALSE; @@ -411,14 +403,14 @@ int Create_Logical_Drive_Interface( void ) return ( 1 ); } - if ( input == 0 ) continue; + if ( input == 0 ) { + continue; + } if ( ( flags.fprmt == TRUE ) && ( input >= 128 ) && ( input <= 2048 ) ) { /* switch th FAT-16? */ - Print_At( - 4, 21, - svarlang_str( 10, 62 ) ); + Print_At( 4, 21, svarlang_str( 10, 62 ) ); con_print( " " ); flags.fat32 = !Input( 1, -1, -1, YN, 0, 0, NONE, 1, 0, '\0', '\0' ); @@ -504,7 +496,7 @@ int Delete_Logical_Drive_Interface( void ) Clear_Screen( 0 ); /* NLS:Delete Logical DOS Drive[...] */ - Print_Centered( 1, svarlang_str( 5, 3 ) , BOLD ); + Print_Centered( 1, svarlang_str( 5, 3 ), BOLD ); Display_Extended_Partition_Information_SS(); @@ -518,7 +510,7 @@ int Delete_Logical_Drive_Interface( void ) do { con_set_cursor_xy( 5, 20 ); /* NLS:WARNING! Data in a deleted Logical[...] */ - con_print( svarlang_str( 10, 30 ) ); + con_print( svarlang_str( 10, 30 ) ); con_print( " " ); flags.esc = FALSE; @@ -571,7 +563,7 @@ int Delete_Logical_Drive_Interface( void ) drive_to_delete = input; /* NLS:Are you sure (Y/N)? */ - Normal_Print_At( 4, 22, svarlang_str( 10, 200) ); + Normal_Print_At( 4, 22, svarlang_str( 10, 200 ) ); con_print( " " ); flags.esc = FALSE; input = (int)Input( 1, -1, -1, YN, 0, 0, ESCR, 0, 0, '\0', '\0' ); @@ -607,7 +599,7 @@ void Delete_N_DOS_Partition_Interface( void ) Clear_Screen( 0 ); /* NLS:Delete Non-DOS Partition */ - Print_Centered( 4, svarlang_str( 5, 4 ) , BOLD ); + Print_Centered( 4, svarlang_str( 5, 4 ), BOLD ); Display_Primary_Partition_Information_SS(); @@ -632,7 +624,7 @@ void Delete_N_DOS_Partition_Interface( void ) if ( p->num_type == 0 ) { /* NLS:Not a partition! */ Display_Primary_Partition_Information_SS(); - Color_Print_At( 4, 21, svarlang_str( 10, 1 ) ); + Color_Print_At( 4, 21, svarlang_str( 10, 1 ) ); } else if ( Is_Dos_Part( p->num_type ) ) { /* NLS:Refusing to delete DOS partition! */ @@ -641,9 +633,9 @@ void Delete_N_DOS_Partition_Interface( void ) } else { error_code = Delete_Primary_Partition( input - 1 ); - + Display_Primary_Partition_Information_SS(); - + if ( !error_code ) { /* NLS:Non-DOS Partition deleted */ Color_Print_At( 4, 21, svarlang_str( 10, 3 ) ); @@ -679,7 +671,7 @@ void Delete_Primary_DOS_Partition_Interface( void ) Display_Primary_Partition_Information_SS(); con_set_cursor_xy( 5, 20 ); - /* NLS:WARNING! Data in the deleted [...] */ + /* NLS:WARNING! Data in the deleted [...] */ con_printf( svarlang_str( 10, 40 ) ); con_print( " " ); @@ -735,7 +727,6 @@ void Delete_Primary_DOS_Partition_Interface( void ) } } - /* Display Extended Partition Information Sub Screen */ void Display_Extended_Partition_Information_SS( void ) { @@ -797,11 +788,11 @@ void Display_Extended_Partition_Information_SS( void ) /* Display file system type */ Print_At( column_index + 25, print_index, "%-9s", - part_type_descr_short(p->num_type) ); + part_type_descr_short( p->num_type ) ); /* Display usage in % */ - usage = Convert_To_Percentage( - p->num_sect, pDrive->ext_num_sect ); + usage = + Convert_To_Percentage( p->num_sect, pDrive->ext_num_sect ); Print_At( column_index + 35, print_index, "%3lu%%", usage ); print_index++; @@ -817,8 +808,8 @@ void Display_Extended_Partition_Information_SS( void ) con_set_cursor_xy( 5, 18 ); con_clreol(); /* NLS:Total Extended Partition size is [...] */ - con_printf( svarlang_str( 10, 6 ), part_table[flags.drive_number - 128].ext_size_mb ); - + con_printf( svarlang_str( 10, 6 ), + part_table[flags.drive_number - 128].ext_size_mb ); } /* Display Or Modify Logical Drive Information in the extended partition */ @@ -847,10 +838,8 @@ void Display_Or_Modify_Logical_Drive_Information( void ) Input( 0, 0, 0, ESC, 0, 0, ESCC, 0, 0, '\0', '\0' ); } else { - Print_At( - 4, 18, - svarlang_str( 10, 84 ) ); - con_print( " "); + Print_At( 4, 18, svarlang_str( 10, 84 ) ); + con_print( " " ); Determine_Drive_Letters(); @@ -929,8 +918,7 @@ void Display_Partition_Information( void ) con_print( " " ); con_save_cursor_xy(); if ( flags.extended_options_flag == TRUE ) { - Print_At( - 4, 20, svarlang_str( 10, 81 ) ); + Print_At( 4, 20, svarlang_str( 10, 81 ) ); con_restore_cursor_xy(); input = (int)Input( 1, -1, -1, YN, 0, 0, ESCR, 1, 0, '1', '4' ); @@ -956,9 +944,7 @@ void Display_Partition_Information( void ) Input( 0, 0, 0, ESC, 0, 0, ESCC, 0, 0, '\0', '\0' ); } else { - Print_At( - 4, 18, - svarlang_str( 10, 82 ) ); + Print_At( 4, 18, svarlang_str( 10, 82 ) ); con_print( " " ); flags.esc = FALSE; @@ -1002,8 +988,7 @@ void Display_Primary_Partition_Information_SS( void ) if ( p->num_type > 0 ) { /* Drive Letter of Partition */ - if ( IsRecognizedFatPartition( - p->num_type ) ) { + if ( IsRecognizedFatPartition( p->num_type ) ) { Print_At( 5, ( cursor_offset + 9 ), "%c:", drive_lettering_buffer[( flags.drive_number - 128 )][index] ); @@ -1015,13 +1000,13 @@ void Display_Primary_Partition_Information_SS( void ) /* Status */ if ( p->active_status > 0 ) { - Print_At( 15, ( cursor_offset + 9 ), svarlang_str( 250, 6 ) ); + Print_At( 15, ( cursor_offset + 9 ), + svarlang_str( 250, 6 ) ); } /* Type */ type = "Non-DOS"; - if ( IsRecognizedFatPartition( - p->num_type ) ) { + if ( IsRecognizedFatPartition( p->num_type ) ) { type = "PRI DOS"; } else if ( p->num_type == 5 ) { @@ -1041,13 +1026,12 @@ void Display_Primary_Partition_Information_SS( void ) Print_UL( p->size_in_MB ); /* System */ - Print_At( - 55, ( cursor_offset + 9 ), "%-15s ", - part_type_descr(p->num_type) ); + Print_At( 55, ( cursor_offset + 9 ), "%-15s ", + part_type_descr( p->num_type ) ); /* Usage */ - usage = Convert_To_Percentage( - p->size_in_MB, pDrive->disk_size_mb ); + usage = Convert_To_Percentage( p->size_in_MB, + pDrive->disk_size_mb ); con_printf( "%3d%%", usage ); @@ -1057,14 +1041,13 @@ void Display_Primary_Partition_Information_SS( void ) } else { /* NLS:Partition Status Mbytes Description Usage Start Cyl End Cyl*/ - Print_At(4, 8, svarlang_str( 10, 11 ) ); + Print_At( 4, 8, svarlang_str( 10, 11 ) ); for ( index = 0; index < 4; index++ ) { p = &pDrive->pri_part[index]; if ( p->num_type > 0 ) { /* Drive Letter of Partition */ - if ( IsRecognizedFatPartition( - p->num_type ) ) { + if ( IsRecognizedFatPartition( p->num_type ) ) { Print_At( 5, ( cursor_offset + 9 ), "%c:", drive_lettering_buffer[flags.drive_number - 128] [index] ); @@ -1074,8 +1057,7 @@ void Display_Primary_Partition_Information_SS( void ) Color_Print_At( 8, ( cursor_offset + 9 ), "%d", index + 1 ); /* Partition Type */ - Print_At( 10, ( cursor_offset + 9 ), "%3d", - p->num_type ); + Print_At( 10, ( cursor_offset + 9 ), "%3d", p->num_type ); /* Status */ if ( p->active_status > 0 ) { @@ -1087,23 +1069,20 @@ void Display_Primary_Partition_Information_SS( void ) Print_UL( p->size_in_MB ); /* Description */ - Print_At( - 33, ( cursor_offset + 9 ), "%-15s", - part_type_descr( p->num_type ) ); + Print_At( 33, ( cursor_offset + 9 ), "%-15s", + part_type_descr( p->num_type ) ); /* Usage */ - usage = Convert_To_Percentage( - p->size_in_MB, pDrive->disk_size_mb ); + usage = Convert_To_Percentage( p->size_in_MB, + pDrive->disk_size_mb ); Print_At( 51, ( cursor_offset + 9 ), "%3d%%", usage ); /* Starting Cylinder */ - Print_At( 60, ( cursor_offset + 9 ), "%6lu", - p->start_cyl ); + Print_At( 60, ( cursor_offset + 9 ), "%6lu", p->start_cyl ); /* Ending Cylinder */ - Print_At( 69, ( cursor_offset + 9 ), "%6lu", - p->end_cyl ); + Print_At( 69, ( cursor_offset + 9 ), "%6lu", p->end_cyl ); cursor_offset++; } @@ -1120,7 +1099,6 @@ void Display_Primary_Partition_Information_SS( void ) con_set_cursor_xy( 5, 15 ); con_clreol(); con_printf( svarlang_str( 10, 8 ), pDrive->disk_size_mb ); - } /* List the Partition Types */ @@ -1133,7 +1111,7 @@ void List_Partition_Types( void ) if ( ( index == 0 ) || ( index == 64 ) || ( index == 128 ) || ( index == 192 ) ) { Clear_Screen( 0 ); - Print_Centered( 1, svarlang_str( 10, 90) , BOLD ); + Print_Centered( 1, svarlang_str( 10, 90 ), BOLD ); row = 4; column = 0; } @@ -1144,7 +1122,7 @@ void List_Partition_Types( void ) } Color_Print_At( column, row, "%3d ", index ); - con_printf( "%s", part_type_descr(index) ); + con_printf( "%s", part_type_descr( index ) ); if ( ( index == 63 ) || ( index == 127 ) || ( index == 191 ) || ( index == 255 ) ) { @@ -1179,13 +1157,10 @@ void Modify_Extended_Partition_Information( int logical_drive_number ) Print_At( 4, 6, svarlang_str( 9, 0 ) ); Color_Printf( " %d", ( flags.drive_number - 127 ) ); - Print_At( - 4, 8, - svarlang_str( 10, 101 ) ); + Print_At( 4, 8, svarlang_str( 10, 101 ) ); /* Drive Letter of Partition */ - if ( IsRecognizedFatPartition( - p->num_type ) ) { + if ( IsRecognizedFatPartition( p->num_type ) ) { Color_Print_At( 5, 9, "%c:", drive_lettering_buffer[( flags.drive_number - 128 )] @@ -1196,30 +1171,25 @@ void Modify_Extended_Partition_Information( int logical_drive_number ) Print_At( 8, 9, "%d", ( logical_drive_number + 1 ) ); /* Partition Type */ - Print_At( 10, 9, "%3d", - ( p->num_type ) ); + Print_At( 10, 9, "%3d", ( p->num_type ) ); /* Mbytes */ Position_Cursor( 24, 9 ); Print_UL( p->size_in_MB ); /* Description */ - Print_At( 33, 9, "%-15s", part_type_descr(p->num_type) ); + Print_At( 33, 9, "%-15s", part_type_descr( p->num_type ) ); /* Usage */ - usage = Convert_To_Percentage( - p->size_in_MB, - pDrive->ext_size_mb ); + usage = Convert_To_Percentage( p->size_in_MB, pDrive->ext_size_mb ); Print_At( 51, 9, "%3d%%", usage ); /* Starting Cylinder */ - Print_At( 60, 9, "%6lu", - p->start_cyl ); + Print_At( 60, 9, "%6lu", p->start_cyl ); /* Ending Cylinder */ - Print_At( 69, 9, "%6lu", - p->end_cyl ); + Print_At( 69, 9, "%6lu", p->end_cyl ); /* NLS:"Choose one of the following: */ Print_At( 4, 12, svarlang_str( 9, 2 ) ); @@ -1236,7 +1206,7 @@ void Modify_Extended_Partition_Information( int logical_drive_number ) */ /* NLS:Enter choice: */ Print_At( 4, 18, svarlang_str( 9, 1 ) ); - con_print(" "); + con_print( " " ); flags.esc = FALSE; input = (int)Input( 1, -1, -1, NUM, 1, 3, ESCC, -1, 0, '\0', '\0' ); @@ -1247,9 +1217,7 @@ void Modify_Extended_Partition_Information( int logical_drive_number ) if ( input == 1 ) { /* Change partition type */ - Print_At( - 4, 20, - svarlang_str( 10, 105 ) ); + Print_At( 4, 20, svarlang_str( 10, 105 ) ); con_print( " " ); flags.esc = FALSE; @@ -1312,13 +1280,10 @@ void Modify_Primary_Partition_Information( int partition_number ) Print_At( 4, 6, svarlang_str( 9, 0 ) ); Color_Printf( " %d", ( flags.drive_number - 127 ) ); - Print_At( - 4, 8, - svarlang_str( 10, 11 ) ); + Print_At( 4, 8, svarlang_str( 10, 11 ) ); /* Drive Letter of Partition */ - if ( IsRecognizedFatPartition( - p->num_type == 1 ) ) { + if ( IsRecognizedFatPartition( p->num_type == 1 ) ) { Print_At( 5, 9, "%c:", drive_lettering_buffer[( flags.drive_number - 128 )] [partition_number] ); @@ -1328,8 +1293,7 @@ void Modify_Primary_Partition_Information( int partition_number ) Color_Print_At( 8, 9, "%d", ( partition_number + 1 ) ); /* Partition Type */ - Print_At( 10, 9, "%3d", - ( p->num_type ) ); + Print_At( 10, 9, "%3d", ( p->num_type ) ); /* Status */ if ( p->active_status > 0 ) { @@ -1341,14 +1305,10 @@ void Modify_Primary_Partition_Information( int partition_number ) Print_UL( p->size_in_MB ); /* Description */ - Print_At( - 33, 9, "%-15s", - part_type_descr(p->num_type) ); + Print_At( 33, 9, "%-15s", part_type_descr( p->num_type ) ); /* Usage */ - usage = - Convert_To_Percentage( p->size_in_MB, - pDrive->disk_size_mb ); + usage = Convert_To_Percentage( p->size_in_MB, pDrive->disk_size_mb ); Print_At( 51, 9, "%3d%%", usage ); @@ -1372,7 +1332,7 @@ void Modify_Primary_Partition_Information( int partition_number ) /* NLS:Enter choice: */ Print_At( 4, 19, svarlang_str( 9, 1 ) ); - con_print(" "); + con_print( " " ); flags.esc = FALSE; input = (int)Input( 1, -1, -1, NUM, 1, 4, ESCC, -1, 0, '\0', '\0' ); @@ -1383,9 +1343,7 @@ void Modify_Primary_Partition_Information( int partition_number ) if ( input == 1 ) { /* Change partition type */ - Print_At( - 4, 19, - svarlang_str( 10, 105 ) ); + Print_At( 4, 19, svarlang_str( 10, 105 ) ); flags.esc = FALSE; input = @@ -1453,7 +1411,7 @@ int Set_Active_Partition_Interface( void ) partition_settable[index] = TRUE; } else if ( ( p->num_type > 0 ) && - ( flags.set_any_pri_part_active == TRUE ) ) { + ( flags.set_any_pri_part_active == TRUE ) ) { available_partition_counter++; if ( ( available_partition_counter == 1 ) && ( p->active_status == 0x80 ) ) { @@ -1476,7 +1434,7 @@ int Set_Active_Partition_Interface( void ) if ( available_partition_counter == 0 ) { /* NLS:No partitions to make active.*/ - Color_Print_At( 4, 22, svarlang_str(10, 50) ); + Color_Print_At( 4, 22, svarlang_str( 10, 50 ) ); Input( 0, 0, 0, ESC, 0, 0, ESCC, 0, 0, '\0', '\0' ); } @@ -1485,7 +1443,7 @@ int Set_Active_Partition_Interface( void ) ( available_partition_counter > 0 ) ) { con_set_cursor_xy( 5, 17 ); /*NLS:Enter the number of the partition you want to make active */ - con_print( svarlang_str( 10, 51 )); + con_print( svarlang_str( 10, 51 ) ); con_print( " " ); con_save_cursor_xy();