为提高性能,改用c替换原本的flask

This commit is contained in:
2025-09-28 12:02:26 +08:00
parent a0e9bf1b44
commit 3c574e489d
24 changed files with 7240 additions and 0 deletions

View File

@ -0,0 +1,40 @@
#include <stdio.h>
#include <stdlib.h>
#include "pkginstall.h"
int check_python(pkger *self)
{
//只需要检查pip是否存在即可确定python是否存在
int pip_ex = system("pip -V >/dev/null 2>&1");
if(WIFEXITED(pip_ex) && WEXITSTATUS(pip_ex) == 0)
return 1;
else
return 0;
}
//TO_DO 完成一下函数实现
int install_dependence(pkger *self)
{
}
int check_dir(pkger *self)
{
}
int packup(pkger *self)
{
}//运行包安装器时执行此函数,注意所有函数通过结构体内部调用。
pkger *init_pkginstaller()
{
pkger *self = (pkger*)malloc(sizeof(pkger));
self->check_dir = check_dir;
self->check_python = check_python;
self->install_dependence = install_dependence;
self->packup = packup;
}

View File

@ -0,0 +1,21 @@
#ifndef PKGINSTALL
#define PKGINSTALL
typedef struct pkger
{
//data
int requirement;//存储requirement.txt的文件fd
char dir[256];
//method
int (*check_python)(struct pkger*);
int (*install_dependence)(struct pkger*);
int (*check_dir)(struct pkger*);
int (*packup)(struct pkger*);
}pkger;
pkger *init_pkginstaller();
#endif