Cleaned up/inlined a little
This commit is contained in:
parent
06a88ab558
commit
58cfea634a
39
nuke.c
39
nuke.c
@ -25,6 +25,11 @@ typedef struct {
|
|||||||
double x,y,z;
|
double x,y,z;
|
||||||
} spaceblob;
|
} spaceblob;
|
||||||
|
|
||||||
|
static int color_ramp1[] = {1,1,1,2,2,2,3,3,3,1,1, -1};
|
||||||
|
static int bold_ramp1[] = {1,1,0,1,0,0,1,0,0,0,0, -1};
|
||||||
|
static int color_ramp2[] = {1,1,1,1,2,2,2,2,2,3,3,3,3,3,1,1,1,1,1,1, -1};
|
||||||
|
static int bold_ramp2[] = {1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0, -1};
|
||||||
|
|
||||||
double prng() {
|
double prng() {
|
||||||
static long long s=1;
|
static long long s=1;
|
||||||
s = s * 1488248101 + 981577151;
|
s = s * 1488248101 + 981577151;
|
||||||
@ -38,12 +43,7 @@ static void sighandler(int sig) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int color_ramp1[] = {1,1,1,2,2,2,3,3,3,1,1, -1};
|
static void draw_frame(int i, int midx, int midy, spaceblob* blobs) {
|
||||||
int bold_ramp1[] = {1,1,0,1,0,0,1,0,0,0,0, -1};
|
|
||||||
int color_ramp2[] = {1,1,1,1,2,2,2,2,2,3,3,3,3,3,1,1,1,1,1,1, -1};
|
|
||||||
int bold_ramp2[] = {1,1,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0, -1};
|
|
||||||
|
|
||||||
void draw_frame(int i, int midx, int midy, spaceblob* blobs) {
|
|
||||||
int rows,cols;
|
int rows,cols;
|
||||||
getmaxyx(stdscr,rows,cols);
|
getmaxyx(stdscr,rows,cols);
|
||||||
int maxx,minx,maxy,miny;
|
int maxx,minx,maxy,miny;
|
||||||
@ -106,24 +106,13 @@ void draw_frame(int i, int midx, int midy, spaceblob* blobs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
|
static int remove_callback(const char *path, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
|
||||||
{
|
{
|
||||||
int rv = remove(fpath);
|
int rv = remove(path);
|
||||||
if (rv)
|
if (rv) perror(path);
|
||||||
perror(fpath);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rmrf(char *path)
|
|
||||||
{
|
|
||||||
DIR *dir;
|
|
||||||
if (!(dir = opendir(path))) {
|
|
||||||
return remove(path);
|
|
||||||
} else {
|
|
||||||
return nftw(path, unlink_cb, 64, FTW_DEPTH | FTW_PHYS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc > 1 && strcmp(argv[1], "--help") == 0) {
|
if (argc > 1 && strcmp(argv[1], "--help") == 0) {
|
||||||
@ -449,7 +438,15 @@ exit_success:
|
|||||||
curs_set(1); /* unhide cursor */
|
curs_set(1); /* unhide cursor */
|
||||||
endwin(); /* Exit ncurses */
|
endwin(); /* Exit ncurses */
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (rmrf(argv[i]) == 0) {
|
int failure;
|
||||||
|
DIR *dir;
|
||||||
|
if (!(dir = opendir(argv[i]))) {
|
||||||
|
failure = remove(argv[i]);
|
||||||
|
} else {
|
||||||
|
closedir(dir);
|
||||||
|
failure = nftw(argv[i], remove_callback, 64, FTW_DEPTH | FTW_PHYS);
|
||||||
|
}
|
||||||
|
if (!failure) {
|
||||||
printf("deleted %s\n", argv[i]);
|
printf("deleted %s\n", argv[i]);
|
||||||
} else {
|
} else {
|
||||||
printf("unable to delete %s\n (%s)", argv[i], strerror(errno));
|
printf("unable to delete %s\n (%s)", argv[i], strerror(errno));
|
||||||
|
Loading…
Reference in New Issue
Block a user