GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
aprintf.c File Reference

GIS Library - Print functions for aligning wide characters. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <grass/gis.h>
#include <grass/glocale.h>
Include dependency graph for aprintf.c:

Go to the source code of this file.

Macros

#define CONVS   "diouxXeEfFgGaAcsCSpnm%"
 
#define SPEC_BUF_SIZE   16
 

Functions

int G_vaprintf (const char *format, va_list ap)
 vprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_vfaprintf (FILE *stream, const char *format, va_list ap)
 vfprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_vsaprintf (char *str, const char *format, va_list ap)
 vsprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_vsnaprintf (char *str, size_t size, const char *format, va_list ap)
 vsnprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_aprintf (const char *format,...)
 Adjust the width of string specifiers to the display space instead of the number of bytes for wide characters and print them formatted using the adjusted display width. More...
 
int G_faprintf (FILE *stream, const char *format,...)
 fprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_saprintf (char *str, const char *format,...)
 sprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 
int G_snaprintf (char *str, size_t size, const char *format,...)
 snprintf() version of G_aprintf(). See G_aprintf() for more details. More...
 

Detailed Description

GIS Library - Print functions for aligning wide characters.

Extracted from the aligned printf C library (libaprintf under GPL v3+) by Huidae Cho.

(C) 2020 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Huidae Cho
Date
2020

Definition in file aprintf.c.

Macro Definition Documentation

◆ CONVS

#define CONVS   "diouxXeEfFgGaAcsCSpnm%"

Definition at line 28 of file aprintf.c.

◆ SPEC_BUF_SIZE

#define SPEC_BUF_SIZE   16

Definition at line 31 of file aprintf.c.

Function Documentation

◆ G_aprintf()

int G_aprintf ( const char *  format,
  ... 
)

Adjust the width of string specifiers to the display space instead of the number of bytes for wide characters and print them formatted using the adjusted display width.

compare

printf("%10s|\n%10s|\n", "ABCD", "가나");

ABCD|

가나|

and

G_aprintf("%10s|\n%10s|\n", "ABCD", "가나");

ABCD|

가나|

Parameters
[in]formatstring format
[in]...arguments for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 465 of file aprintf.c.

◆ G_faprintf()

int G_faprintf ( FILE *  stream,
const char *  format,
  ... 
)

fprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]streamfile pointer
[in]formatstring format
[in]...arguments for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 485 of file aprintf.c.

◆ G_saprintf()

int G_saprintf ( char *  str,
const char *  format,
  ... 
)

sprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]strstring buffer
[in]formatstring format
[in]...arguments for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 505 of file aprintf.c.

◆ G_snaprintf()

int G_snaprintf ( char *  str,
size_t  size,
const char *  format,
  ... 
)

snprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]strstring buffer
[in]sizestring buffer size
[in]formatstring format
[in]...arguments for the format string
Returns
number of bytes that would be printed if size was big enough or fatal error on error

Definition at line 527 of file aprintf.c.

◆ G_vaprintf()

int G_vaprintf ( const char *  format,
va_list  ap 
)

vprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]formatstring format
[in]apvariable argument list for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 379 of file aprintf.c.

◆ G_vfaprintf()

int G_vfaprintf ( FILE *  stream,
const char *  format,
va_list  ap 
)

vfprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]streamfile pointer
[in]formatstring format
[in]apvariable argument list for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 392 of file aprintf.c.

◆ G_vsaprintf()

int G_vsaprintf ( char *  str,
const char *  format,
va_list  ap 
)

vsprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]strstring buffer
[in]formatstring format
[in]apvariable argument list for the format string
Returns
number of bytes printed or fatal error on error

Definition at line 411 of file aprintf.c.

◆ G_vsnaprintf()

int G_vsnaprintf ( char *  str,
size_t  size,
const char *  format,
va_list  ap 
)

vsnprintf() version of G_aprintf(). See G_aprintf() for more details.

Parameters
[in]strstring buffer
[in]sizestring buffer size
[in]formatstring format
[in]apvariable argument list for the format string
Returns
number of bytes that would be printed if size was big enough or fatal error on error

Definition at line 432 of file aprintf.c.