mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 10:45:22 +00:00
Also add snprintf(), and %X format code. BUG=chrome-os-partner:10206 TEST=timerinfo; should print correctly. 'ectool battery' on host side should print same serial as 'battery' on EC console. Change-Id: I5c9f69d1a20ee5d0a59440c122655adbf62c9aea Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/24635 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org>
48 lines
1.6 KiB
C
48 lines
1.6 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Printf-like functionality for Chrome EC */
|
|
|
|
#ifndef __CROS_EC_PRINTF_H
|
|
#define __CROS_EC_PRINTF_H
|
|
|
|
#include <stdarg.h> /* For va_list */
|
|
#include "common.h"
|
|
|
|
/* SUPPORTED FORMAT CODES:
|
|
* char (%c)
|
|
* string (%s)
|
|
* native int (signed/unsigned) (%d / %u / %x / %X)
|
|
* int32_t / uint32_t (%d / %x / %X)
|
|
* int64_t / uint64_t (%ld / %lu / %lx / %lX)
|
|
* pointer (%p)
|
|
* And the following special format codes:
|
|
* current time in sec (%T) - interpreted as "%.6T" for fixed-point format
|
|
* including padding (%-5s, %8d, %08x, %016lx)
|
|
*
|
|
* Floating point output (%f / %g) is not supported, but there is a fixed-point
|
|
* extension for integers; a padding option of .N (where N is a number) will
|
|
* put a decimal before that many digits. For example, printing 123 with
|
|
* format code %.6d will result in "0.000123". This is most useful for
|
|
* printing times, voltages, and currents. */
|
|
|
|
|
|
/* Print formatted output to a function, like vfprintf()
|
|
*
|
|
* addchar() will be called for every character to be printed, with the context
|
|
* pointer passed to vfnprintf(). addchar() should return 0 if the character
|
|
* was accepted or non-zero if the character was dropped due to overflow.
|
|
*
|
|
* Returns error if output was truncated. */
|
|
int vfnprintf(int (*addchar)(void *context, int c), void *context,
|
|
const char *format, va_list args);
|
|
|
|
|
|
/* Print formatted outut to a string */
|
|
int snprintf(char *str, int size, const char *format, ...);
|
|
|
|
|
|
#endif /* __CROS_EC_PRINTF_H */
|