Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
fac2179c23 | |||
9b196f0b13 | |||
be291628b8 |
3 changed files with 18 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "map.h"
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -142,8 +143,13 @@ int success_handler(const void *key, size_t size, uintptr_t val, void *usr) {
|
|||
}
|
||||
|
||||
char *handle_pages(char *command, char *invs) {
|
||||
char *data;
|
||||
char *data2;
|
||||
if (strncmp(command, invs, strlen(invs)) == 0) {
|
||||
return &command[strlen(invs)];
|
||||
data = &command[strlen(invs)];
|
||||
data2 = malloc(strlen(data) + 1);
|
||||
memcpy(data2,data,strlen(data) + 1);
|
||||
return data2;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -177,6 +183,8 @@ int suggest_command(char *command, char *command_re, hashmap *polls, hashmap *co
|
|||
char *val = calloc(MAX_BUF_LENGTH, sizeof(char));
|
||||
sprintf(val, "%s;%s", page, command_re);
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
char *key = calloc(MAX_BUF_LENGTH, sizeof(char));
|
||||
sprintf(key, "%s_%i", name, (int)rand());
|
||||
|
||||
|
|
|
@ -26,7 +26,9 @@ int entry_handler(const void *key, size_t size, uintptr_t val, void *usr) {
|
|||
}
|
||||
} else if (usr2->mode == 1) {
|
||||
fwrite(key2, sizeof(char), strlen(key2), usr2->fptr);
|
||||
if (key2[strlen(key2) - 1] != '\n') {
|
||||
fwrite("\n", sizeof(char), 1, usr2->fptr);
|
||||
}
|
||||
} else {
|
||||
fwrite(key2, sizeof(char), strlen(key2), usr2->fptr);
|
||||
fwrite(";", sizeof(char), 1, usr2->fptr);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "command.h"
|
||||
#include "loader.h"
|
||||
#include "map.h"
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
@ -87,8 +88,11 @@ int main(int argc, char *argv[]) {
|
|||
was_combination = 0;
|
||||
if (help_command(command))
|
||||
continue;
|
||||
if (polls_command(command, polls, elements))
|
||||
continue;
|
||||
if (polls_command(command, polls, elements)) {
|
||||
hashmap_free(polls);
|
||||
polls = hashmap_create();
|
||||
init_tables(elements, inv, polls, elements_rev, 0);
|
||||
}
|
||||
if (slash_command(command, inv))
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Reference in a new issue