cvs commit: ALFS/nALFS/src nprint.h init.c nalfs.c options.c win.h

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Thu Nov 6 08:57:41 PST 2003


kpfleming    03/11/06 09:57:41

  Modified:    nALFS/src init.c nalfs.c options.c win.h
  Added:       nALFS/src nprint.h
  Log:
  move Nprint-related definitions/macros from win.h to nprint.h
  change init.c/options.c to include nprint.h instead of win.h
  add nprint_init function to nalfs.c, used during initialization (before any profile execution or interactive mode are begun)
  
  Revision  Changes    Path
  1.10      +1 -1      ALFS/nALFS/src/init.c
  
  Index: init.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/init.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- init.c	5 Nov 2003 06:05:36 -0000	1.9
  +++ init.c	6 Nov 2003 16:57:41 -0000	1.10
  @@ -39,7 +39,7 @@
   #include "options.h"
   #include "utility.h"
   #include "logging.h"
  -#include "win.h"
  +#include "nprint.h"
   
   #include "init.h"
   
  
  
  
  1.37      +34 -1     ALFS/nALFS/src/nalfs.c
  
  Index: nalfs.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/nalfs.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- nalfs.c	5 Nov 2003 14:25:37 -0000	1.36
  +++ nalfs.c	6 Nov 2003 16:57:41 -0000	1.37
  @@ -48,6 +48,7 @@
   #include "bufsize.h"
   #include "utility.h"
   #include "parser.h"
  +#include "nprint.h"
   #include "win.h"
   #include "handlers.h"
   #include "backend.h"
  @@ -134,6 +135,9 @@
   /* Pointer to current function to use for printing to main window. */
   void (*nprint)(msg_id_e mid, const char *format, ...);
   
  +/* Counters used by nprint_init to track errors/warnings. */
  +int init_errors = 0;
  +int init_warnings = 0;
   
   /*
    * Some smaller, helper functions, used often.
  @@ -4626,6 +4630,33 @@
   	xfree(file);
   }
   
  +static void nprint_init(msg_id_e mid, const char *format,...)
  +{
  +	FILE *console;
  +	va_list ap;
  +
  +	va_start(ap, format);
  +
  +	switch (mid) {
  +	case T_ERR:
  +		console = stderr;
  +		++init_errors;
  +		break;
  +	case T_WAR:
  +		console = stdout;
  +		++init_warnings;
  +		break;
  +	default:
  +		console = stdout;
  +		break;
  +	}
  +
  +	vfprintf(console, format, ap);
  +	fflush(console);
  +
  +	va_end(ap);
  +}
  +
   /*
    * Main.
    */
  @@ -4635,7 +4666,7 @@
   	int i;
   
   
  -	nprint = nprint_text;
  +	nprint = nprint_init;
   
   
   	set_options_to_defaults();
  @@ -4657,6 +4688,8 @@
   
   	if (!post_validate_options())
   		return EXIT_FAILURE;
  +
  +	nprint = nprint_text;
   
   	init_needed_directories();
   
  
  
  
  1.20      +3 -3      ALFS/nALFS/src/options.c
  
  Index: options.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/options.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- options.c	6 Nov 2003 06:22:48 -0000	1.19
  +++ options.c	6 Nov 2003 16:57:41 -0000	1.20
  @@ -35,7 +35,7 @@
   #include "nalfs-core.h"
   #include "logging.h"
   #include "utility.h"
  -#include "win.h"
  +#include "nprint.h"
   #include "bufsize.h"
   
   /* These macro definitions will cause the options in options.h to actually
  @@ -211,10 +211,10 @@
   
   	va_start(ap, format);
   	if (vsnprintf(buffer, sizeof buffer, format, ap) > 0)
  -		Nprint_err("Option \"%s\" invalid value: %s",
  +		Nprint_err("Option \"%s\" invalid value: %s\n",
   			   option->name, buffer);
   	else
  -		Nprint_err("Option \"%s\" invalid value", option->name);
  +		Nprint_err("Option \"%s\" invalid value\n", option->name);
   	va_end(ap);
   }
   
  
  
  
  1.6       +1 -48     ALFS/nALFS/src/win.h
  
  Index: win.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/win.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- win.h	25 Oct 2003 02:29:43 -0000	1.5
  +++ win.h	6 Nov 2003 16:57:41 -0000	1.6
  @@ -28,6 +28,7 @@
   #include <curses.h>
   
   #include "logging.h"
  +#include "nprint.h"
   
   
   #define MOD_CTRL(x) ((x) & 31)
  @@ -60,20 +61,6 @@
   #define COL_WHITE	(COLOR_PAIR(COLP_WHITE))
   
   
  -/*
  - * Types of messages.  They are also used as message_types[] indexes.
  - * First should be 0, last T_ERR, order matters.
  - */
  -typedef enum msg_id_e {
  -	T_RAW = 0,
  -	T_INF,
  -	T_HLP,
  -	T_SYS,
  -	T_WAR,
  -	T_ERR
  -} msg_id_e;
  -
  -
   typedef struct msg_type_t {
   	msg_id_e id;		// Unique ID of the message type.
   	char character;		// Character to print before the message.
  @@ -119,40 +106,6 @@
   } windows_s;
   
   extern windows_s windows;
  -
  -
  -/*
  - * Printing macros.
  - */
  -
  -extern void (*nprint)(msg_id_e mid, const char *format,...);
  -
  -/* Print macros. */
  -#define Nprint(a, b...)		nprint(T_INF, a, ## b)
  -#define Nprint_warn(a, b...)	nprint(T_WAR, a, ## b)
  -#define Nprint_err(a, b...)	nprint(T_ERR, a, ## b)
  -#define Nprint_sys(a, b...)	nprint(T_SYS, a, ## b)
  -#define Nprint_raw(a, b...)	nprint(T_RAW, a, ## b)
  -#define Nprint_help(a, b...)	nprint(T_HLP, a, ## b)
  -
  -/*
  - * Print macros used in handlers.  TODO: Remove them and use the same
  - * macros as above, just define them differently when used in handlers.
  - */
  -#define Nprint_h(a, b...)	do { log_handler_action(a, ## b); \
  -					Nprint(a, ## b); } while (0)
  -#define Nprint_h_warn(a, b...)	do { log_handler_action(a, ## b); \
  -					Nprint_warn(a, ## b); } while (0)
  -#define Nprint_h_err(a, b...)	do { log_handler_action(a, ## b); \
  -					Nprint_err(a, ## b); } while (0)
  -#define Nprint_h_sys(a, b...)	do { log_handler_action(a, ## b); \
  -					Nprint_sys(a, ## b); } while (0)
  -#define Nprint_h_raw(a, b...)	do { log_handler_action(a, ## b); \
  -					Nprint_raw(a, ## b); } while (0)
  -#define Nprint_h_help(a, b...)	do{ log_handler_action(a, ## b); \
  -					Nprint_help(a, ## b); } while (0)
  -
  -
   
   void start_display(void);
   void end_display(void);
  
  
  
  1.1                  ALFS/nALFS/src/nprint.h
  
  Index: nprint.h
  ===================================================================
  /*
   *  nprint.h - Macros to provide access to "printing" functions.
   *
   *  Copyright (C) 2001, 2002, 2003
   *
   *  Neven Has <haski at sezampro.yu>
   *
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation; either version 2 of the License, or
   *  (at your option) any later version.
   *
   *  This program is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
   *
   *  You should have received a copy of the GNU General Public License
   *  along with this program; if not, write to the Free Software
   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   */
  
  
  #ifndef H_NPRINT_
  #define H_NPRINT_
  
  
  /*
   * Types of messages.  They are also used as message_types[] indexes.
   * First should be 0, last T_ERR, order matters.
   */
  typedef enum msg_id_e {
  	T_RAW = 0,
  	T_INF,
  	T_HLP,
  	T_SYS,
  	T_WAR,
  	T_ERR
  } msg_id_e;
  
  /*
   * Printing macros.
   */
  
  extern void (*nprint)(msg_id_e mid, const char *format,...);
  
  /* Print macros. */
  #define Nprint(a, b...)		nprint(T_INF, a, ## b)
  #define Nprint_warn(a, b...)	nprint(T_WAR, a, ## b)
  #define Nprint_err(a, b...)	nprint(T_ERR, a, ## b)
  #define Nprint_sys(a, b...)	nprint(T_SYS, a, ## b)
  #define Nprint_raw(a, b...)	nprint(T_RAW, a, ## b)
  #define Nprint_help(a, b...)	nprint(T_HLP, a, ## b)
  
  /*
   * Print macros used in handlers.  TODO: Remove them and use the same
   * macros as above, just define them differently when used in handlers.
   */
  #define Nprint_h(a, b...)	do { log_handler_action(a, ## b); \
  					Nprint(a, ## b); } while (0)
  #define Nprint_h_warn(a, b...)	do { log_handler_action(a, ## b); \
  					Nprint_warn(a, ## b); } while (0)
  #define Nprint_h_err(a, b...)	do { log_handler_action(a, ## b); \
  					Nprint_err(a, ## b); } while (0)
  #define Nprint_h_sys(a, b...)	do { log_handler_action(a, ## b); \
  					Nprint_sys(a, ## b); } while (0)
  #define Nprint_h_raw(a, b...)	do { log_handler_action(a, ## b); \
  					Nprint_raw(a, ## b); } while (0)
  #define Nprint_h_help(a, b...)	do{ log_handler_action(a, ## b); \
  					Nprint_help(a, ## b); } while (0)
  #endif /* H_NPRINT_ */
  
  
  



More information about the alfs-log mailing list