Add xy_os_family

This commit is contained in:
Aoran Zeng 2025-06-20 08:51:00 +08:00
parent 75c1401776
commit 28a3aae6e1
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
2 changed files with 44 additions and 4 deletions

View File

@ -8,7 +8,7 @@
* Contributors : juzeon <skyjuzheng@gmail.com>
* |
* Created On : <2023-08-28>
* Last Modified : <2024-12-14>
* Last Modified : <2025-06-20>
*
* xy:
* Corss-Platform C utilities for CLI applications in Ruby flavor
@ -17,8 +17,10 @@
#ifndef XY_H
#define XY_H
#define _XY_Version "v0.1.4.4-2024/12/14"
#define _XY_Maintain_URL "https://gitee.com/RubyMetric/chsrc/blob/main/include/xy.h"
#define _XY_Version "v0.1.5.0-2025/06/20"
#define _XY_Maintain_URL "https://github.com/RubyMetric/chsrc/blob/main/lib/xy.h"
#define _XY_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc/blob/main/lib/xy.h"
#include <assert.h>
#include <stdarg.h>
@ -646,6 +648,41 @@ xy_run (const char *cmd, unsigned long n)
}
/******************************************************
* cross OS
******************************************************/
/**
* just os_family() windows, unix
*
* @return "windows" "unix"
*/
#define xy_os_family _xy_os_family ()
static char *
_xy_os_family ()
{
if (xy_on_windows)
return "windows";
else
return "unix";
}
/**
* os family
*/
static const char *
xy_os_depend_str (const char *str_for_win, const char *str_for_unix)
{
if (xy_on_windows)
return str_for_win;
else
return str_for_unix;
}
#define xy_os_home _xy_os_home ()
static char *
_xy_os_home ()

View File

@ -6,7 +6,7 @@
* Contributors : Nil Null <nil@null.org>
* |
* Created On : <2023-08-30>
* Last Modified : <2025-06-19>
* Last Modified : <2025-06-20>
*
* Test xy.h
* ------------------------------------------------------------*/
@ -17,6 +17,9 @@ int
main (int argc, char const *argv[])
{
xy_useutf8 ();
puts (xy_os_depend_str ("Hello, Windows!", "Hello, Unix!"));
puti (3);
double dbl = 3.1415;
putf (dbl);