mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-18 04:22:15 +02:00
@@ -391,7 +391,7 @@ void *rmalloc(size_t *size); /* don't ever use this */
|
|||||||
void rset(void *buf, size_t n);
|
void rset(void *buf, size_t n);
|
||||||
void *mkrbuf(size_t n);
|
void *mkrbuf(size_t n);
|
||||||
char *mkrstr(size_t n);
|
char *mkrstr(size_t n);
|
||||||
int win_lottery(void);
|
int win_lottery(char **buf);
|
||||||
|
|
||||||
/* Helper functions for command: dump
|
/* Helper functions for command: dump
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
#if defined(USE_URANDOM) && \
|
#if defined(USE_URANDOM) && \
|
||||||
((USE_URANDOM) > 0)
|
((USE_URANDOM) > 0)
|
||||||
#include <fcntl.h> /* if not arc4random: /dev/urandom */
|
#include <fcntl.h> /* if not arc4random: /dev/urandom */
|
||||||
|
#elif defined(__linux__)
|
||||||
|
#include <sys/random.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -70,7 +73,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
win_lottery(void) /* are u lucky? */
|
win_lottery(char **buf) /* are u lucky? */
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
int rval;
|
int rval;
|
||||||
@@ -84,6 +87,8 @@ win_lottery(void) /* are u lucky? */
|
|||||||
else
|
else
|
||||||
rval = 0;
|
rval = 0;
|
||||||
|
|
||||||
|
(void) scat(s1, s2, BUFSIZ << 1, buf);
|
||||||
|
|
||||||
free_if_null(&s1);
|
free_if_null(&s1);
|
||||||
free_if_null(&s2);
|
free_if_null(&s2);
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
size_t s;
|
char *s1 = NULL;
|
||||||
char *s1;
|
int rval = 0;
|
||||||
|
|
||||||
#if defined(__OpenBSD__) && defined(OpenBSD)
|
#if defined(__OpenBSD__) && defined(OpenBSD)
|
||||||
#if (OpenBSD) >= 509
|
#if (OpenBSD) >= 509
|
||||||
@@ -22,36 +22,20 @@ main(int argc, char *argv[])
|
|||||||
err_no_cleanup(0, errno, "openbsd won it");
|
err_no_cleanup(0, errno, "openbsd won it");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setvbuf(stdout, NULL, _IONBF, 0);
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
|
|
||||||
if (win_lottery()) {
|
if (win_lottery(&s1))
|
||||||
printf("You won!");
|
rval = 1;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
s1 = rmalloc(&s);
|
|
||||||
|
|
||||||
if (s1 != NULL) {
|
if (s1 != NULL) {
|
||||||
printf("%s\n\nYou lose. Sorry!\n", s1);
|
printf("%s\n\n", s1);
|
||||||
free(s1);
|
free(s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
printf("%s\n", rval ? "You won!" : "You lose! Sorry!");
|
||||||
|
return rval? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}/*
|
}/*
|
||||||
|
|
||||||
( >:3 )
|
( >:3 )
|
||||||
/| |\
|
/| |\
|
||||||
/ \ */
|
/ \ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user