Subversion Repositories RepoView

Rev

Rev 3 | Rev 10 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 5
Line 1... Line 1...
1
/* $Id: util.c 3 2024-08-20 21:05:24Z nishi $ */
1
/* $Id: util.c 5 2024-08-20 22:43:56Z nishi $ */
2
 
2
 
3
#include "rv_util.h"
3
#include "rv_util.h"
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
7
#include "rv_version.h"
7
#include "rv_version.h"
-
 
8
#include "rv_db.h"
8
 
9
 
9
#include <stdio.h>
10
#include <stdio.h>
10
#include <stdlib.h>
11
#include <stdlib.h>
11
#include <string.h>
12
#include <string.h>
12
 
13
 
Line 71... Line 72...
71
			free(tmp);
72
			free(tmp);
72
		}
73
		}
73
	}
74
	}
74
	return r;
75
	return r;
75
}
76
}
-
 
77
 
-
 
78
char* rv_new_token(const char* username) {
-
 
79
	const char tokenstr[] = "0123456789abcdefghijklmnopqrstuvwxyz";
-
 
80
	char* token = malloc(17);
-
 
81
	token[16] = 0;
-
 
82
	int i;
-
 
83
regenerate:
-
 
84
	for(i = 0; i < 16; i++) {
-
 
85
		token[i] = tokenstr[rand() % strlen(tokenstr)];
-
 
86
	}
-
 
87
	if(rv_has_token(token)) goto regenerate;
-
 
88
	rv_save_token(username, token);
-
 
89
	return token;
-
 
90
}