⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uxgen.c

📁 远程登陆工具软件源码 用于远程登陆unix
💻 C
字号:
/*
 * uxgen.c: Unix implementation of get_heavy_noise() from cmdgen.c.
 */

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>

#include "putty.h"

char *get_random_data(int len)
{
    char *buf = snewn(len, char);
    int fd;
    int ngot, ret;

    fd = open("/dev/random", O_RDONLY);
    if (fd < 0) {
	sfree(buf);
	perror("puttygen: unable to open /dev/random");
	return NULL;
    }

    ngot = 0;
    while (ngot < len) {
	ret = read(fd, buf+ngot, len-ngot);
	if (ret < 0) {
	    close(fd);
	    perror("puttygen: unable to read /dev/random");
	    return NULL;
	}
	ngot += ret;
    }

    return buf;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -