Upload files to "/"

This commit is contained in:
8nl 2024-06-22 10:24:24 +00:00
parent 55006980f5
commit f17b2c7eee

View File

@ -8,21 +8,39 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <ctype.h> #include <ctype.h>
#define NARGS 1024
#define ARG_SIZE 50 #define ARG_SIZE 50
int args;
int values[NARGS + 1];
struct winsize ws; struct winsize ws;
int max;
int min;
int args;
size_t middle;
int add_value(const char *str) { int add_value(const char *str) {
if (args >= sizeof(values) / sizeof(int) || args > ws.ws_col) if (args > (int)ws.ws_col)
return 1; return 1;
values[args] = atoi(str); int val1 = atoi(str);
args++;
int val2 = val1;
if (val2 < 0)
val2 *= -1;
if (val2 > max)
max = val2;
else if (val2 < min)
min = val2;
int k = (val2 - min) * (middle - 5) / ((max - min) + 1);
if (val1 > 0)
mvprintw(middle - k, args, "@");
else
mvprintw(middle + k, args, "@");
args++;
return 0; return 0;
} }
@ -60,14 +78,6 @@ void sig_handler(int sig) {
exit(0); exit(0);
} }
void print(int middle, int k, int x) {
if (values[x] < 0)
mvprintw(middle + k, x, "@");
else
mvprintw(middle - k, x, "@");
}
int main(void) { int main(void) {
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler); signal(SIGTERM, sig_handler);
@ -79,31 +89,12 @@ int main(void) {
curs_set(0); curs_set(0);
timeout(0); timeout(0);
int min = 0; middle = ws.ws_row / 2;
int max = 0;
int middle = (int)ws.ws_row / 2;
while (1) { while (1) {
args = 0; args = 0;
stdin_read();
clear(); clear();
for (int i = 0; i < args; i++) { stdin_read();
int val = values[i];
if (val < 0)
val *= -1;
if (val < min)
min = val;
else if (val > max)
max = val;
/* Main */
int lvl = (val - min) * (middle - 5) / ((max - min) + 1);
print(middle, lvl, i);
}
refresh(); refresh();
} }
} }