[BACK]Return to log.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/log.c between version 1.8 and 1.9

version 1.8, 2019/06/22 15:38:15 version 1.9, 2019/06/26 16:54:29
Line 48 
Line 48 
 #include <unistd.h>  #include <unistd.h>
   
 #include "def.h"  #include "def.h"
 #include "log.h"  #include "key.h"
   #include "kbd.h"
 #include "funmap.h"  #include "funmap.h"
   #include "chrdef.h"
   
   #include "log.h"
   
 char    *mglogfiles_create(char *);  char    *mglogfiles_create(char *);
 int      mglog_lines(PF);  int      mglog_lines(PF);
 int      mglog_undo(void);  int      mglog_undo(void);
 int      mglog_window(void);  int      mglog_window(void);
   int      mglog_key(KEYMAP *map);
   
 char            *mglogdir;  char            *mglogdir;
 extern char     *mglogpath_lines;  extern char     *mglogpath_lines;
 extern char     *mglogpath_undo;  extern char     *mglogpath_undo;
 extern char     *mglogpath_window;  extern char     *mglogpath_window;
   extern char     *mglogpath_key;
 int              mgloglevel;  int              mgloglevel;
   
 int  int
 mglog(PF funct)  mglog(PF funct, KEYMAP *map)
 {  {
         if(!mglog_lines(funct))          if(!mglog_lines(funct))
                 ewprintf("Problem logging lines");                  ewprintf("Problem logging lines");
Line 71 
Line 77 
                 ewprintf("Problem logging undo");                  ewprintf("Problem logging undo");
         if(!mglog_window())          if(!mglog_window())
                 ewprintf("Problem logging window");                  ewprintf("Problem logging window");
           if(!mglog_key(map))
                   ewprintf("Problem logging key");
   
         return (TRUE);          return (TRUE);
 }  }
   
   
 int  int
   mglog_key(KEYMAP *map)
   {
           struct stat      sb;
           FILE            *fd;
           PF              *pfp;
   
           if(stat(mglogpath_key, &sb))
                    return (FALSE);
           fd = fopen(mglogpath_key, "a");
   
           if (ISWORD(*key.k_chars)) {
                   if (fprintf(fd, "k_count:%d k_chars:%hd\tchr:%c\t", key.k_count,
                       *key.k_chars, CHARMASK(*key.k_chars)) == -1) {
                           fclose(fd);
                           return (FALSE);
                   }
           } else {
                   if (fprintf(fd, "k_count:%d k_chars:%hd\t\t", key.k_count,
                       *key.k_chars) == -1) {
                           fclose(fd);
                           return (FALSE);
                   }
           }
           if (fprintf(fd, "map:%p %d %d %p %hd %hd\n",
               map,
               map->map_num,
               map->map_max,
               map->map_default,
               map->map_element->k_base,
               map->map_element->k_num
               ) == -1) {
                   fclose(fd);
                   return (FALSE);
           }
           for (pfp = map->map_element->k_funcp; *pfp != '\0'; pfp++)
                   fprintf(fd, "%s ", function_name(*pfp));
   
           fprintf(fd, "\n\n");
           fclose(fd);
           return (TRUE);
   }
   
   int
 mglog_window(void)  mglog_window(void)
 {  {
         struct mgwin    *wp;          struct mgwin    *wp;
Line 253 
Line 304 
         struct stat      sb;          struct stat      sb;
         mode_t           dir_mode, f_mode, oumask;          mode_t           dir_mode, f_mode, oumask;
         char            *mglogfile_lines, *mglogfile_undo, *mglogfile_window;          char            *mglogfile_lines, *mglogfile_undo, *mglogfile_window;
           char            *mglogfile_key;
   
         mglogdir = "./log/";          mglogdir = "./log/";
         mglogfile_lines = "line.log";          mglogfile_lines = "line.log";
         mglogfile_undo = "undo.log";          mglogfile_undo = "undo.log";
         mglogfile_window = "window.log";          mglogfile_window = "window.log";
           mglogfile_key = "key.log";
   
         /*          /*
          * Change mgloglevel for desired level of logging.           * Change mgloglevel for desired level of logging.
Line 284 
Line 337 
         mglogpath_window = mglogfiles_create(mglogfile_window);          mglogpath_window = mglogfiles_create(mglogfile_window);
         if (mglogpath_window == NULL)          if (mglogpath_window == NULL)
                 return (FALSE);                  return (FALSE);
           mglogpath_key = mglogfiles_create(mglogfile_key);
           if (mglogpath_key == NULL)
                   return (FALSE);
   
         return (TRUE);          return (TRUE);
 }  }
Line 317 
Line 373 
   
         return (tmp2);          return (tmp2);
 }  }
   
   /*
    * Template log function.
    */
   /*
   int
   mglog_?(void)
   {
           struct stat      sb;
           FILE            *fd;
   
           if(stat(mglogpath_?, &sb))
           fd = fopen(mglogpath_?, "a");
   
           if (fprintf(fd, "%?", ??) == -1) {
                   fclose(fd);
                   return (FALSE);
           }
           fclose(fd);
           return (TRUE);
   }
   */

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9