A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1#include <stddef.h>
2#include "string.h"
3#include "strmemccpy.h"
4/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
6
7This file was part of groff.
8
9groff is free software; you can redistribute it and/or modify it under
10the terms of the GNU General Public License as published by the Free
11Software Foundation; either version 2, or (at your option) any later
12version.
13
14groff is distributed in the hope that it will be useful, but WITHOUT ANY
15WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17for more details.
18
19You should have received a copy of the GNU General Public License along
20with groff; see the file COPYING. If not, write to the Free Software
21Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23#define INT_DIGITS 19 /* enough for 64 bit integer */
24
25char *itoa_buf(char *buf, size_t bufsz, long int i)
26{
27 /* Room for INT_DIGITS digits, - and '\0' */
28 static char intbuf[INT_DIGITS + 2];
29 char *p = intbuf + INT_DIGITS + 1; /* points to terminating '\0' */
30 if (i >= 0) {
31 do {
32 *--p = '0' + (i % 10);
33 i /= 10;
34 } while (i != 0);
35 }
36 else { /* i < 0 */
37 do {
38 *--p = '0' - (i % 10);
39 i /= 10;
40 } while (i != 0);
41 *--p = '-';
42 }
43 strmemccpy(buf, p, bufsz);
44 return buf;
45}