ReactOS  0.4.14-dev-55-g2da92ac
jssnprintf.c File Reference
#include <schily/mconfig.h>
#include <schily/unistd.h>
#include <schily/stdio.h>
#include <schily/stdlib.h>
#include <schily/varargs.h>
#include <schily/standard.h>
#include <schily/schily.h>
Include dependency graph for jssnprintf.c:

Go to the source code of this file.

Classes

struct  BUF
 

Typedefs

typedef struct BUF _BUF
 

Functions

EXPORT int js_snprintf __PR ((char *, size_t maxcnt, const char *,...))
 
static void _cput (char c, void *l)
 
EXPORT int js_snprintf (char *buf, unsigned maxcnt, char *form, va_alist)
 

Typedef Documentation

◆ _BUF

typedef struct BUF _BUF

Function Documentation

◆ __PR()

EXPORT int js_snprintf __PR ( (char *, size_t maxcnt, const char *,...)  )

◆ _cput()

static void _cput ( char  c,
void l 
)
static

Definition at line 39 of file jssnprintf.c.

43 {
44  register BUF bp = (BUF)l;
45 
46  if (--bp->count > 0) {
47  *bp->ptr++ = c;
48  } else {
49  /*
50  * Make sure that there will never be a negative overflow.
51  */
52  bp->count++;
53  }
54 }
char * ptr
Definition: jssnprintf.c:30
#define BUF
Definition: skelserver.c:12
Definition: jssnprintf.c:29
r l[0]
Definition: byte_order.h:167
#define c
Definition: ke_i.h:80
int count
Definition: jssnprintf.c:31

Referenced by js_snprintf().

◆ js_snprintf()

EXPORT int js_snprintf ( char buf,
unsigned  maxcnt,
char form,
va_alist   
)

Definition at line 62 of file jssnprintf.c.

68 {
69  va_list args;
70  int cnt;
71  _BUF bb;
72 
73  bb.ptr = buf;
74  bb.count = maxcnt;
75 
76 #ifdef PROTOTYPES
77  va_start(args, form);
78 #else
79  va_start(args);
80 #endif
81  cnt = format(_cput, &bb, form, args);
82  va_end(args);
83  if (maxcnt > 0)
84  *(bb.ptr) = '\0';
85  if (bb.count < 0)
86  return (-1);
87 
88  return (cnt);
89 }
char * ptr
Definition: jssnprintf.c:30
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int form
Definition: main.c:89
Definition: match.c:390
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
Definition: jssnprintf.c:29
static void _cput(char c, void *l)
Definition: jssnprintf.c:39
char * va_list
Definition: acmsvcex.h:78
#define va_start(ap, A)
Definition: acmsvcex.h:91
int count
Definition: jssnprintf.c:31
#define args
Definition: format.c:66

Referenced by _comerr(), and set_de_path().