Create different IDs for each bar (+test)
This commit is contained in:
@ -934,7 +934,14 @@ bar:
|
||||
{
|
||||
printf("\t new bar configuration finished, saving.\n");
|
||||
/* Generate a unique ID for this bar */
|
||||
current_bar.id = sstrdup("foo"); /* TODO */
|
||||
current_bar.id = sstrdup("bar-XXXXXX");
|
||||
/* This works similar to mktemp in that it replaces the last six X with
|
||||
* random letters, but without the restriction that the given buffer
|
||||
* has to contain a valid path name. */
|
||||
char *x = current_bar.id + strlen("bar-");
|
||||
while (*x != '\0') {
|
||||
*(x++) = (rand() % 26) + 'a';
|
||||
}
|
||||
|
||||
/* Copy the current (static) structure into a dynamically allocated
|
||||
* one, then cleanup our static one. */
|
||||
|
@ -217,6 +217,8 @@ int main(int argc, char *argv[]) {
|
||||
if (!isatty(fileno(stdout)))
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
init_logging();
|
||||
|
||||
start_argv = argv;
|
||||
|
Reference in New Issue
Block a user