Subversion Repositories mdb

Rev

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

Rev 12 Rev 14
Line 39... Line 39...
39
int createUser(int s1, char *user, char *playlist)
39
int createUser(int s1, char *user, char *playlist)
40
{
40
{
41
	char query[1024];
41
	char query[1024];
42
	char fname[256];
42
	char fname[256];
43
	sqlite3 *db;
43
	sqlite3 *db;
44
	char *zErrMsg = 0;
-
 
45
	int rc, id;
44
	int rc;
46
	sqlite3_stmt *res;
45
	sqlite3_stmt *res;
47
 
46
 
48
	strcpy(fname, configs.home);
47
	strcpy(fname, configs.home);
49
	strcat(fname, MUSICDB);
48
	strcat(fname, MUSICDB);
50
 
49
 
Line 106... Line 105...
106
		memset(userchain, 0, sizeof(USERS));
105
		memset(userchain, 0, sizeof(USERS));
107
		return userchain;
106
		return userchain;
108
	}
107
	}
109
	else
108
	else
110
	{
109
	{
111
		USERS *new, *act;
110
		USERS *neu, *act;
112
 
111
 
113
		if ((new = (USERS *)malloc(sizeof(USERS))) == NULL)
112
		if ((neu = (USERS *)malloc(sizeof(USERS))) == NULL)
114
		{
113
		{
115
			syslog(LOG_DAEMON, "Error allocating %ld bytes for a user: %s", sizeof(USERS), strerror(errno));
114
			syslog(LOG_DAEMON, "Error allocating %ld bytes for a user: %s", sizeof(USERS), strerror(errno));
116
			return NULL;
115
			return NULL;
117
		}
116
		}
118
 
117
 
119
		memset(new, 0, sizeof(USERS));
118
		memset(neu, 0, sizeof(USERS));
120
		/* Find last structure in chain */
119
		/* Find last structure in chain */
121
		act = userchain;
120
		act = userchain;
122
 
121
 
123
		while (act->next)
122
		while (act->next)
124
			act = act->next;
123
			act = act->next;
125
 
124
 
126
		act->next = new;
125
		act->next = neu;
-
 
126
		return neu;
127
	}
127
	}
128
}
128
}
129
 
129
 
130
void deleteUser()
130
void deleteUser()
131
{
131
{
Line 146... Line 146...
146
int selectUser (int s1, const char *user)
146
int selectUser (int s1, const char *user)
147
{
147
{
148
	char query[1024], hv0[128];
148
	char query[1024], hv0[128];
149
	char fname[256];
149
	char fname[256];
150
	sqlite3 *db;
150
	sqlite3 *db;
151
	char *uname, *playlist, *zErrMsg = 0;
-
 
152
	int rc, id, total;
151
	int rc, total;
153
	sqlite3_stmt *res;
152
	sqlite3_stmt *res;
154
	
153
	
155
	strcpy(fname, configs.home);
154
	strcpy(fname, configs.home);
156
	strcat(fname, MUSICDB);
155
	strcat(fname, MUSICDB);
157
	
156
	
Line 215... Line 214...
215
	sqlite3_close(db);
214
	sqlite3_close(db);
216
 
215
 
217
	return TRUE;
216
	return TRUE;
218
}
217
}
219
 
218
 
220
USERS *findPlaylist(char *playlist)
219
USERS *findPlaylist(char *user, char *playlist)
221
{
220
{
222
	USERS *act;
221
	USERS *act;
223
 
222
 
224
	act = userchain;
223
	act = userchain;
225
 
224
 
226
	while (act)
225
	while (act)
227
	{
226
	{
228
		if (strcmp(act->playlist, playlist) == 0)
227
		if (!strcmp(act->uname, user) && !strcmp(act->playlist, playlist))
229
			return act;
228
			return act;
230
 
229
 
231
		act = act->next;
230
		act = act->next;
232
	}
231
	}
233
 
232