Rizin
unix-like reverse engineering framework and cli tools
zip_error_to_str.c File Reference
#include <stdio.h>
#include <string.h>
#include <zlib.h>
#include "zipint.h"

Go to the source code of this file.

Macros

#define _ZIP_COMPILING_DEPRECATED
 

Functions

ZIP_EXTERN int zip_error_to_str (char *buf, zip_uint64_t len, int ze, int se)
 

Macro Definition Documentation

◆ _ZIP_COMPILING_DEPRECATED

#define _ZIP_COMPILING_DEPRECATED

Definition at line 39 of file zip_error_to_str.c.

Function Documentation

◆ zip_error_to_str()

ZIP_EXTERN int zip_error_to_str ( char *  buf,
zip_uint64_t  len,
int  ze,
int  se 
)

Definition at line 44 of file zip_error_to_str.c.

44  {
45  const char *zs, *ss;
46 
47  if (ze < 0 || ze >= _zip_err_str_count) {
48  return snprintf(buf, len, "Unknown error %d", ze);
49  }
50 
51  zs = _zip_err_str[ze].description;
52 
53  switch (_zip_err_str[ze].type) {
54  case ZIP_ET_SYS:
55  ss = strerror(se);
56  break;
57 
58  case ZIP_ET_ZLIB:
59  ss = zError(se);
60  break;
61 
62  default:
63  ss = NULL;
64  }
65 
66  return snprintf(buf, len, "%s%s%s", zs, (ss ? ": " : ""), (ss ? ss : ""));
67 }
size_t len
Definition: 6502dis.c:15
#define NULL
Definition: cris-opc.c:27
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
#define ZIP_ET_SYS
Definition: zip.h:142
#define ZIP_ET_ZLIB
Definition: zip.h:143
int type
Definition: mipsasm.c:17
const char * description
Definition: zipint.h:197
const struct _zip_err_info _zip_err_str[]
Definition: zip_err_str.c:15
const int _zip_err_str_count
Definition: zip_err_str.c:51
const char *ZEXPORT zError(int err)
Definition: zutil.c:133

References _zip_err_str, _zip_err_str_count, _zip_err_info::description, len, NULL, snprintf, type, zError(), ZIP_ET_SYS, and ZIP_ET_ZLIB.