ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
version.h File Reference

Go to the source code of this file.

Data Structures

struct  semantic_version_t
 Parsed semantic version structure. More...
 

Macros

#define ASCII_CHAT_VERSION_MAJOR   0
 
#define ASCII_CHAT_VERSION_MINOR   11
 
#define ASCII_CHAT_VERSION_PATCH   33
 
#define ASCII_CHAT_VERSION_STRING   "0.11.33"
 
#define ASCII_CHAT_GIT_VERSION   "dev-251+gf082a3bac"
 
#define ASCII_CHAT_GIT_COMMIT_HASH   "f082a3bac"
 
#define ASCII_CHAT_GIT_IS_DIRTY   false
 
#define ASCII_CHAT_BUILD_TYPE   "Release"
 
#define ASCII_CHAT_OS   "Linux"
 
#define ASCII_CHAT_BUILD_DATE   "2026-10-07"
 
#define ASCII_CHAT_REPO_HASH   "bcbbbe9920dda295dbf96a268aa351a0ffcf1cca0455c4fec639885117d45049"
 
#define ASCII_CHAT_VERSION_FULL   "v" ASCII_CHAT_VERSION_STRING "-" ASCII_CHAT_GIT_VERSION
 
#define ASCII_CHAT_DESCRIPTION_EMOJI_L   "💻📸"
 
#define ASCII_CHAT_DESCRIPTION_EMOJI_R   "🔡💬"
 
#define ASCII_CHAT_DESCRIPTION_TEXT   "Video chat in your terminal"
 
#define ASCII_CHAT_DESCRIPTION   ASCII_CHAT_DESCRIPTION_EMOJI_L " " ASCII_CHAT_DESCRIPTION_TEXT " " ASCII_CHAT_DESCRIPTION_EMOJI_R
 
#define ASCII_CHAT_BUILD_INFO_STRING   "ascii-chat " ASCII_CHAT_VERSION_FULL " built on " ASCII_CHAT_OS " (" ASCII_CHAT_BUILD_DATE ", " ASCII_CHAT_BUILD_TYPE ")"
 
#define ASCII_CHAT_DOT_COMMENT_STRING   ASCII_CHAT_BUILD_INFO_STRING "\n" ASCII_CHAT_DESCRIPTION "\n" "https://github.com/zfogg/ascii-chat"
 
#define ASCII_CHAT_DOT_ASCII_CHAT_STRING   ASCII_CHAT_DOT_COMMENT_STRING "\n" "coded with 🖤 by Zachary Fogg <me@zfo.gg>"
 

Functions

const char * ascii_chat_get_version (void)
 
const char * ascii_chat_get_comment (void)
 
const char * ascii_chat_get_build_info (void)
 
semantic_version_t version_parse (const char *version_string)
 Parse a version string into semantic version components.
 
int version_compare (semantic_version_t a, semantic_version_t b)
 Compare two semantic versions.
 

Macro Definition Documentation

◆ ASCII_CHAT_BUILD_DATE

#define ASCII_CHAT_BUILD_DATE   "2026-10-07"

Definition at line 16 of file version.h.

◆ ASCII_CHAT_BUILD_INFO_STRING

#define ASCII_CHAT_BUILD_INFO_STRING   "ascii-chat " ASCII_CHAT_VERSION_FULL " built on " ASCII_CHAT_OS " (" ASCII_CHAT_BUILD_DATE ", " ASCII_CHAT_BUILD_TYPE ")"

Definition at line 30 of file version.h.

◆ ASCII_CHAT_BUILD_TYPE

#define ASCII_CHAT_BUILD_TYPE   "Release"

Definition at line 14 of file version.h.

◆ ASCII_CHAT_DESCRIPTION

Definition at line 27 of file version.h.

◆ ASCII_CHAT_DESCRIPTION_EMOJI_L

#define ASCII_CHAT_DESCRIPTION_EMOJI_L   "💻📸"

Definition at line 24 of file version.h.

◆ ASCII_CHAT_DESCRIPTION_EMOJI_R

#define ASCII_CHAT_DESCRIPTION_EMOJI_R   "🔡💬"

Definition at line 25 of file version.h.

◆ ASCII_CHAT_DESCRIPTION_TEXT

#define ASCII_CHAT_DESCRIPTION_TEXT   "Video chat in your terminal"

Definition at line 26 of file version.h.

◆ ASCII_CHAT_DOT_ASCII_CHAT_STRING

#define ASCII_CHAT_DOT_ASCII_CHAT_STRING   ASCII_CHAT_DOT_COMMENT_STRING "\n" "coded with 🖤 by Zachary Fogg <me@zfo.gg>"

Definition at line 34 of file version.h.

◆ ASCII_CHAT_DOT_COMMENT_STRING

#define ASCII_CHAT_DOT_COMMENT_STRING   ASCII_CHAT_BUILD_INFO_STRING "\n" ASCII_CHAT_DESCRIPTION "\n" "https://github.com/zfogg/ascii-chat"

Definition at line 32 of file version.h.

◆ ASCII_CHAT_GIT_COMMIT_HASH

#define ASCII_CHAT_GIT_COMMIT_HASH   "f082a3bac"

Definition at line 12 of file version.h.

◆ ASCII_CHAT_GIT_IS_DIRTY

#define ASCII_CHAT_GIT_IS_DIRTY   false

Definition at line 13 of file version.h.

◆ ASCII_CHAT_GIT_VERSION

#define ASCII_CHAT_GIT_VERSION   "dev-251+gf082a3bac"

Definition at line 11 of file version.h.

◆ ASCII_CHAT_OS

#define ASCII_CHAT_OS   "Linux"

Definition at line 15 of file version.h.

◆ ASCII_CHAT_REPO_HASH

#define ASCII_CHAT_REPO_HASH   "bcbbbe9920dda295dbf96a268aa351a0ffcf1cca0455c4fec639885117d45049"

Definition at line 17 of file version.h.

◆ ASCII_CHAT_VERSION_FULL

#define ASCII_CHAT_VERSION_FULL   "v" ASCII_CHAT_VERSION_STRING "-" ASCII_CHAT_GIT_VERSION

Definition at line 21 of file version.h.

◆ ASCII_CHAT_VERSION_MAJOR

#define ASCII_CHAT_VERSION_MAJOR   0

Definition at line 7 of file version.h.

◆ ASCII_CHAT_VERSION_MINOR

#define ASCII_CHAT_VERSION_MINOR   11

Definition at line 8 of file version.h.

◆ ASCII_CHAT_VERSION_PATCH

#define ASCII_CHAT_VERSION_PATCH   33

Definition at line 9 of file version.h.

◆ ASCII_CHAT_VERSION_STRING

#define ASCII_CHAT_VERSION_STRING   "0.11.33"

Definition at line 10 of file version.h.

Function Documentation

◆ ascii_chat_get_build_info()

const char * ascii_chat_get_build_info ( void  )

◆ ascii_chat_get_comment()

const char * ascii_chat_get_comment ( void  )

◆ ascii_chat_get_version()

const char * ascii_chat_get_version ( void  )

◆ version_compare()

int version_compare ( semantic_version_t  a,
semantic_version_t  b 
)

Compare two semantic versions.

Parameters
aFirst version
bSecond version
Returns
-1 if a < b, 0 if a == b, 1 if a > b

Definition at line 112 of file version.c.

112 {
113 // Compare major version
114 if (a.major < b.major) {
115 return -1;
116 }
117 if (a.major > b.major) {
118 return 1;
119 }
120
121 // Major versions equal, compare minor
122 if (a.minor < b.minor) {
123 return -1;
124 }
125 if (a.minor > b.minor) {
126 return 1;
127 }
128
129 // Minor versions equal, compare patch
130 if (a.patch < b.patch) {
131 return -1;
132 }
133 if (a.patch > b.patch) {
134 return 1;
135 }
136
137 // All components equal
138 return 0;
139}
int patch
Patch version (0 to INT_MAX)
Definition version.h:50
int major
Major version (0 to INT_MAX)
Definition version.h:48
int minor
Minor version (0 to INT_MAX)
Definition version.h:49

References semantic_version_t::major, semantic_version_t::minor, and semantic_version_t::patch.

Referenced by update_check_load_cache(), and update_check_perform().

◆ version_parse()

semantic_version_t version_parse ( const char *  version_string)

Parse a version string into semantic version components.

Handles both "v1.2.3" and "1.2.3" formats. Allows missing components (e.g., "1.2" = 1.2.0, "1" = 1.0.0).

Parameters
version_stringVersion string to parse (e.g., "v0.8.1", "1.2.3")
Returns
Parsed semantic version (check .valid field for success)

Definition at line 49 of file version.c.

49 {
50 semantic_version_t result = {0, 0, 0, false};
51
52 if (!version_string || version_string[0] == '\0') {
53 return result;
54 }
55
56 const char *p = version_string;
57
58 // Optionally skip 'v' prefix if present
59 if (p[0] == 'v' || p[0] == 'V') {
60 p++; // Skip 'v'
61 }
62
63 // Parse major version
64 char *endptr = NULL;
65 errno = 0; // Reset errno before strtol
66 long major = strtol(p, &endptr, 10);
67 if (errno == ERANGE || endptr == p || major < 0 || major > INT_MAX) {
68 return result; // Invalid major version or overflow
69 }
70 result.major = (int)major;
71 p = endptr;
72
73 // Version must have all three components (major.minor.patch)
74 if (*p != '.') {
75 return result; // Invalid: missing minor version
76 }
77 p++; // Skip dot
78
79 // Parse minor version
80 errno = 0; // Reset errno before strtol
81 long minor = strtol(p, &endptr, 10);
82 if (errno == ERANGE || endptr == p || minor < 0 || minor > INT_MAX) {
83 return result; // Invalid minor version or overflow
84 }
85 result.minor = (int)minor;
86 p = endptr;
87
88 // Version must have patch component
89 if (*p != '.') {
90 return result; // Invalid: missing patch version
91 }
92 p++; // Skip dot
93
94 // Parse patch version
95 errno = 0; // Reset errno before strtol
96 long patch = strtol(p, &endptr, 10);
97 if (errno == ERANGE || endptr == p || patch < 0 || patch > INT_MAX) {
98 return result; // Invalid patch version or overflow
99 }
100 result.patch = (int)patch;
101 p = endptr;
102
103 // Reject prerelease tags (e.g., "v1.2.3-beta") - must end after patch number
104 if (*p != '\0') {
105 return result; // Invalid: has extra characters after version
106 }
107
108 result.valid = true;
109 return result;
110}
#define ERANGE
int errno
Parsed semantic version structure.
Definition version.h:47
bool valid
True if parsing succeeded.
Definition version.h:51

References ERANGE, errno, semantic_version_t::major, semantic_version_t::minor, semantic_version_t::patch, and semantic_version_t::valid.

Referenced by update_check_load_cache(), and update_check_perform().