Rename to use xy_run

This commit is contained in:
Aoran Zeng 2024-06-11 16:54:28 +08:00
parent f53c05b2c2
commit 452fc72762

View File

@ -3,7 +3,7 @@
* License : MIT
* Authors : Aoran Zeng <ccmywish@qq.com>
* Created on : <2023-08-28>
* Last modified : <2024-06-08>
* Last modified : <2024-06-11>
*
* xy:
*
@ -17,7 +17,7 @@
#ifndef XY_H
#define XY_H
#define XY_Version "v0.1.2-2024/06/08"
#define XY_Version "v0.1.2-2024/06/11"
#define XY_Maintain_URL "https://gitee.com/RubyMetric/chsrc/blob/main/xy.h"
#include <assert.h>
@ -545,19 +545,22 @@ _xy_log_remarkably (int level, const char *prompt1, const char *prompt2, const c
* System
******************************************************/
/**
* cmd
* cmditer_func
*
* @param cmd
* @param n 0 n (n>0) n行
* @param func
* @param cmd
* @param n 0 n (n>0) n行
*
* @param iter_func
*
* @note
* @note
*
* iter_func()
*/
static char *
xy_getcmd (const char *cmd, unsigned long n, void (*func) (const char *))
xy_run (const char *cmd, unsigned long n, void (*iter_func) (const char *))
{
const int size = 512;
char *buf = (char *)malloc (size);
char *buf = (char *) malloc (size);
FILE *stream = popen (cmd, "r");
if (stream == NULL)
@ -577,9 +580,9 @@ xy_getcmd (const char *cmd, unsigned long n, void (*func) (const char *))
count += 1;
if (n == count)
break;
if (func)
if (iter_func)
{
func (buf);
iter_func (buf);
}
}