Annotation of embedaddon/bmon/src/output.c, revision 1.1.1.2

1.1       misho       1: /*
                      2:  * output.c               Output API
                      3:  *
1.1.1.2 ! misho       4:  * Copyright (c) 2001-2013 Thomas Graf <tgraf@suug.ch>
        !             5:  * Copyright (c) 2013 Red Hat, Inc.
1.1       misho       6:  *
                      7:  * Permission is hereby granted, free of charge, to any person obtaining a
                      8:  * copy of this software and associated documentation files (the "Software"),
                      9:  * to deal in the Software without restriction, including without limitation
                     10:  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
                     11:  * and/or sell copies of the Software, and to permit persons to whom the
                     12:  * Software is furnished to do so, subject to the following conditions:
                     13:  *
                     14:  * The above copyright notice and this permission notice shall be included
                     15:  * in all copies or substantial portions of the Software.
                     16:  *
                     17:  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
                     18:  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                     19:  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
                     20:  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                     21:  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
                     22:  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
                     23:  * DEALINGS IN THE SOFTWARE.
                     24:  */
                     25: 
                     26: #include <bmon/bmon.h>
                     27: #include <bmon/output.h>
1.1.1.2 ! misho      28: #include <bmon/module.h>
1.1       misho      29: #include <bmon/conf.h>
1.1.1.2 ! misho      30: #include <bmon/group.h>
1.1       misho      31: #include <bmon/utils.h>
                     32: 
1.1.1.2 ! misho      33: static struct bmon_subsys output_subsys;
1.1       misho      34: 
1.1.1.2 ! misho      35: void output_register(struct bmon_module *m)
1.1       misho      36: {
1.1.1.2 ! misho      37:        module_register(&output_subsys, m);
1.1       misho      38: }
                     39: 
1.1.1.2 ! misho      40: static void activate_default(void)
1.1       misho      41: {
1.1.1.2 ! misho      42:        /*
        !            43:         * Try to activate a default output module if the user did not make
        !            44:         * a selection
        !            45:         */
        !            46:        if (!output_subsys.s_nmod) {
        !            47:                struct bmon_module *m;
1.1       misho      48: 
1.1.1.2 ! misho      49:                if (!output_set("curses"))
        !            50:                        return;
1.1       misho      51: 
1.1.1.2 ! misho      52:                if (!output_set("ascii"))
        !            53:                        return;
1.1       misho      54: 
1.1.1.2 ! misho      55:                /* Fall back to anything that could act as default */
        !            56:                list_for_each_entry(m, &output_subsys.s_mod_list, m_list) {
        !            57:                        if (m->m_flags & BMON_MODULE_DEFAULT)
        !            58:                                if (!output_set(m->m_name))
        !            59:                                        return;
        !            60:                }
1.1       misho      61: 
1.1.1.2 ! misho      62:                quit("No output module found\n");
        !            63:        }
1.1       misho      64: }
                     65: 
                     66: void output_pre(void)
                     67: {
1.1.1.2 ! misho      68:        module_foreach_run_enabled_pre(&output_subsys);
1.1       misho      69: }
                     70:                                        
                     71: void output_draw(void)
                     72: {
1.1.1.2 ! misho      73:        module_foreach_run_enabled(&output_subsys);
1.1       misho      74: }
                     75: 
                     76: void output_post(void)
                     77: {
1.1.1.2 ! misho      78:        module_foreach_run_enabled_post(&output_subsys);
1.1       misho      79: }
                     80: 
1.1.1.2 ! misho      81: int output_set(const char *name)
1.1       misho      82: {
1.1.1.2 ! misho      83:        return module_set(&output_subsys, name);
1.1       misho      84: }
                     85: 
1.1.1.2 ! misho      86: static struct bmon_subsys output_subsys = {
        !            87:        .s_name                 = "output",
        !            88:        .s_activate_default     = &activate_default,
        !            89:        .s_mod_list             = LIST_SELF(output_subsys.s_mod_list),
        !            90: };
1.1       misho      91: 
1.1.1.2 ! misho      92: static void __init __output_init(void)
1.1       misho      93: {
1.1.1.2 ! misho      94:        return module_register_subsys(&output_subsys);
1.1       misho      95: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>