文件
PazeSSH/include/paze/ssh_config.h
T

44 行
1.5 KiB
C

/* ssh_config.h —— ~/.pssh/config.conf 解析(ssh_config 子集)
*
* 支持指令:
* Host <pattern...> 段开始(支持 * 通配,可多模式空格分隔)
* HostName <host> 实际主机名
* Port <n> 端口
* User <name> 用户名
* IdentityFile <path> 私钥路径(支持 ~)
* ProxyJump [user@]host[:port] 代理跳转
* StrictHostKeyChecking no|accept-new|yes
*/
#ifndef PAZE_SSH_CONFIG_H
#define PAZE_SSH_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
char host[128]; /* Host 模式串 */
char hostname[256]; /* HostName */
char user[128]; /* User */
int port; /* Port,0=未设置 */
char identity_file[512];
char proxyjump[512];
int hostkey_mode; /* -1=未设置, 0=ask, 1=accept-new, 2=no */
} pssh_config_entry_t;
/* 解析配置文件;*out 为 malloc 数组,调用方 free。返回条目数,失败返回 -1。 */
int pssh_config_load(const char *path, pssh_config_entry_t **out, int *count);
/* 匹配主机别名,按 ssh_config 语义(第一个匹配段生效,后续不覆盖已设值)。
* out 需由调用方初始化(全零)后传入。返回匹配的段数,0=无。 */
int pssh_config_match(const pssh_config_entry_t *entries, int count,
const char *alias, pssh_config_entry_t *out);
/* 展开 ~ 为用户主目录 */
void pssh_config_expand_home(const char *in, char *out, size_t n);
#ifdef __cplusplus
}
#endif
#endif /* PAZE_SSH_CONFIG_H */