~ubuntu-branches/ubuntu/precise/openipmi/precise

« back to all changes in this revision

Viewing changes to sample/sample.c

  • Committer: Bazaar Package Importer
  • Author(s): Noèl Köthe
  • Date: 2005-10-20 23:01:55 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051020230155-32ns8hnb1es8hntb
Tags: 2.0.2-2
added missing libgdbm-dev to libopenipmi-dev
(closes: Bug#334623)

Show diffs side-by-side

added added

removed removed

Lines of Context:
428
428
 
429
429
static os_handler_t *os_hnd;
430
430
 
 
431
static void
 
432
my_vlog(os_handler_t         *handler,
 
433
        const char           *format,
 
434
        enum ipmi_log_type_e log_type,
 
435
        va_list              ap)
 
436
{
 
437
    int do_nl = 1;
 
438
 
 
439
    switch(log_type)
 
440
    {
 
441
        case IPMI_LOG_INFO:
 
442
            printf("INFO: ");
 
443
            break;
 
444
 
 
445
        case IPMI_LOG_WARNING:
 
446
            printf("WARN: ");
 
447
            break;
 
448
 
 
449
        case IPMI_LOG_SEVERE:
 
450
            printf("SEVR: ");
 
451
            break;
 
452
 
 
453
        case IPMI_LOG_FATAL:
 
454
            printf("FATL: ");
 
455
            break;
 
456
 
 
457
        case IPMI_LOG_ERR_INFO:
 
458
            printf("EINF: ");
 
459
            break;
 
460
 
 
461
        case IPMI_LOG_DEBUG_START:
 
462
            do_nl = 0;
 
463
            /* FALLTHROUGH */
 
464
        case IPMI_LOG_DEBUG:
 
465
            printf("DEBG: ");
 
466
            break;
 
467
 
 
468
        case IPMI_LOG_DEBUG_CONT:
 
469
            do_nl = 0;
 
470
            /* FALLTHROUGH */
 
471
        case IPMI_LOG_DEBUG_END:
 
472
            break;
 
473
    }
 
474
 
 
475
    vprintf(format, ap);
 
476
 
 
477
    if (do_nl)
 
478
        printf("\n");
 
479
}
 
480
 
431
481
int
432
482
main(int argc, char *argv[])
433
483
{
445
495
        exit(1);
446
496
    }
447
497
 
 
498
    /* Override the default log handler (just to show how). */
 
499
    os_hnd->set_log_handler(os_hnd, my_vlog);
 
500
 
448
501
    /* Initialize the OpenIPMI library. */
449
502
    ipmi_init(os_hnd);
450
503
 
503
556
    /* Technically, we can't get here, but this is an example. */
504
557
    os_hnd->free_os_handler(os_hnd);
505
558
}
506
 
 
507
 
void
508
 
posix_vlog(char *format, enum ipmi_log_type_e log_type, va_list ap)
509
 
{
510
 
    int do_nl = 1;
511
 
 
512
 
    switch(log_type)
513
 
    {
514
 
        case IPMI_LOG_INFO:
515
 
            printf("INFO: ");
516
 
            break;
517
 
 
518
 
        case IPMI_LOG_WARNING:
519
 
            printf("WARN: ");
520
 
            break;
521
 
 
522
 
        case IPMI_LOG_SEVERE:
523
 
            printf("SEVR: ");
524
 
            break;
525
 
 
526
 
        case IPMI_LOG_FATAL:
527
 
            printf("FATL: ");
528
 
            break;
529
 
 
530
 
        case IPMI_LOG_ERR_INFO:
531
 
            printf("EINF: ");
532
 
            break;
533
 
 
534
 
        case IPMI_LOG_DEBUG_START:
535
 
            do_nl = 0;
536
 
            /* FALLTHROUGH */
537
 
        case IPMI_LOG_DEBUG:
538
 
            printf("DEBG: ");
539
 
            break;
540
 
 
541
 
        case IPMI_LOG_DEBUG_CONT:
542
 
            do_nl = 0;
543
 
            /* FALLTHROUGH */
544
 
        case IPMI_LOG_DEBUG_END:
545
 
            break;
546
 
    }
547
 
 
548
 
    vprintf(format, ap);
549
 
 
550
 
    if (do_nl)
551
 
        printf("\n");
552
 
}