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

Go to the source code of this file.

Functions

static int validate (const char *const tag)
 
int main (int argc, const char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
const char **  argv 
)

Definition at line 60 of file checkTag.c.

61 {
62  const char* const exeName = argv[0];
63  const char* const tag = argv[1];
64  if (argc!=2) {
65  printf("incorrect usage : %s tag \n", exeName);
66  return 2;
67  }
68 
69  printf("Version : %s \n", LZ4_VERSION_STRING);
70  printf("Tag : %s \n", tag);
71 
72  if (validate(tag)) {
73  printf("OK : tag is compatible with lz4 version \n");
74  return 0;
75  }
76 
77  printf("!! error : tag and versions are not compatible !! \n");
78  return 1;
79 }
static int validate(const char *const tag)
Definition: checkTag.c:46
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
#define LZ4_VERSION_STRING
Definition: lz4.h:110

References argv, LZ4_VERSION_STRING, printf(), test-lz4-versions::tag, and validate().

◆ validate()

static int validate ( const char *const  tag)
static

Definition at line 46 of file checkTag.c.

47 {
48  size_t const tagLength = strlen(tag);
49  size_t const verLength = strlen(LZ4_VERSION_STRING);
50 
51  if (tagLength < 2) return 0;
52  if (tag[0] != 'v') return 0;
53  if (tagLength <= verLength) return 0;
54 
55  if (strncmp(LZ4_VERSION_STRING, tag+1, verLength)) return 0;
56 
57  return 1;
58 }

References LZ4_VERSION_STRING, and test-lz4-versions::tag.

Referenced by main(), and zip_source_crc_create().