advgetopt 2.0.49
Parse complex command line arguments and configuration files in C++.
Classes | Macros | Functions | Variables
hide_warnings.cpp File Reference

Tool used to hide "Gtk-warning" messages from terminal. More...

#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <limits.h>
#include <errno.h>
#include <regex.h>
#include <poll.h>
Include dependency graph for hide_warnings.cpp:

Go to the source code of this file.

Classes

struct  io_buf
 

Macros

#define _GNU_SOURCE
 
#define IN_OUT_BUFSIZ   (64 * 1024)
 

Functions

int main (int argc, char *argv[], char *envp[])
 
void output_data (FILE *out, regex_t const *regex, char *str, size_t len)
 
void read_pipe (int pipe, FILE *out, regex_t const *regex, struct io_buf *io)
 
void usage ()
 

Variables

struct io_buf g_buf_err
 
struct io_buf g_buf_out
 
int g_case_sensitive = 0
 
char const *const g_default_regex = "gtk-warning|gtk-critical|glib-gobject-warning|^$"
 
int g_filter_stdout = 0
 
char const * g_progname = NULL
 
char const * g_regex = NULL
 
char const *const g_version = "1.0"
 

Detailed Description

This tool can be used to hide certain errors and warnings from your console. Many of us really do not care about those Gtk-WARNINGS, which we cannot really do anything about, except parse out with such a tool.

To use, create an alias in your ~/.bashrc file:

alias gvim="hide-warnings gvim"
alias meld="hide-warnings meld"
...any command that generates Gtk-WARNINGS...

If you want to parse out other things, you may change the default regex ('gtk-wanring|gtk-critical|glib-gobject-warning|^$') with whatever you want. Use the –regex command line option for that purpose:

alias gimp="hide-warnings --regex 'cannot change name of operation class|glib-gobject-warning|gtk-warning|^$' gimp"

If your command starts with a dash (-), then use – on the command line before your command:

alias weird="hide-warnings --regex 'forget|that' -- -really-weird'
Todo:
Transform the command line handling to make use of the advgetopt. I wrote this tool in a separate project at first but wanted to share it and make it an example on how to use advgetopt but as we can see at the moment it's not yet converted... For now, it's a C++ file at least.

Definition in file hide_warnings.cpp.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 58 of file hide_warnings.cpp.

◆ IN_OUT_BUFSIZ

#define IN_OUT_BUFSIZ   (64 * 1024)

Definition at line 88 of file hide_warnings.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[],
char *  envp[] 
)

◆ output_data()

void output_data ( FILE *  out,
regex_t const *  regex,
char *  str,
size_t  len 
)

Definition at line 114 of file hide_warnings.cpp.

References g_progname.

Referenced by read_pipe().

◆ read_pipe()

void read_pipe ( int  pipe,
FILE *  out,
regex_t const *  regex,
struct io_buf io 
)

Definition at line 150 of file hide_warnings.cpp.

References io_buf::f_buf, io_buf::f_pos, g_progname, IN_OUT_BUFSIZ, and output_data().

Referenced by main().

◆ usage()

void usage ( )

Definition at line 98 of file hide_warnings.cpp.

References g_progname.

Referenced by main(), and advgetopt::getopt::process_system_options().

Variable Documentation

◆ g_buf_err

struct io_buf g_buf_err

Definition at line 95 of file hide_warnings.cpp.

Referenced by main().

◆ g_buf_out

struct io_buf g_buf_out

Definition at line 94 of file hide_warnings.cpp.

Referenced by main().

◆ g_case_sensitive

int g_case_sensitive = 0

Definition at line 85 of file hide_warnings.cpp.

Referenced by main().

◆ g_default_regex

char const* const g_default_regex = "gtk-warning|gtk-critical|glib-gobject-warning|^$"

Definition at line 81 of file hide_warnings.cpp.

Referenced by main().

◆ g_filter_stdout

int g_filter_stdout = 0

Definition at line 86 of file hide_warnings.cpp.

Referenced by main().

◆ g_progname

char const* g_progname = NULL

Definition at line 83 of file hide_warnings.cpp.

Referenced by main(), output_data(), read_pipe(), and usage().

◆ g_regex

char const* g_regex = NULL

Definition at line 84 of file hide_warnings.cpp.

Referenced by main().

◆ g_version

char const* const g_version = "1.0"

Definition at line 80 of file hide_warnings.cpp.

Referenced by main().

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.