Reorganised the modules directory, started serious work on GUI support
[tpg/acess2.git] / Usermode / Applications / login_src / database_tpl.c
1 /*
2  * Acess 2 Login
3  */
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include "header.h"
7
8 // === CONSTANTS ===
9
10 // === PROTOTYPES ===
11  int    ValidateUser(char *Username, char *Password);
12 tUserInfo       *GetUserInfo(int UID);
13
14 // === GLOBALS ===
15 tUserInfo       gUserInfo;
16
17 // === CODE ===
18 /**
19  * \fn int ValidateUser(char *Username, char *Password)
20  * \brief Validates a users credentials
21  * \return UID on success, -1 on failure
22  */
23 int ValidateUser(char *Username, char *Password)
24 {
25         if(Username == NULL)    return -1;
26         if(Password == NULL)    return -1;
27         if(strcmp(Username, "root") == 0)       return 0;
28         if(strcmp(Username, "tpg") == 0)        return 1;
29         if(strcmp(Username, "gui") == 0)        return 2;
30         return -1;
31 }
32
33 /**
34  * \fn void GetUserInfo(int UID)
35  * \brief Gets a users information
36  */
37 tUserInfo *GetUserInfo(int UID)
38 {       
39         gUserInfo.UID = UID;
40         gUserInfo.GID = UID;
41         gUserInfo.Shell = "/Acess/Bin/CLIShell";
42         switch(UID)
43         {
44         case 0:
45                 gUserInfo.Home = "/Acess/Root";
46                 break;
47         case 1:
48                 gUserInfo.Home = "/Acess/Users/tpg";
49                 break;
50         case 2:
51                 gUserInfo.UID = 0;      //HACK!
52                 gUserInfo.Home = "/Acess/Users/gui";
53                 gUserInfo.Shell = "/Acess/Apps/AxWin/1.0/AxWinWM";
54                 break;
55         default:
56                 gUserInfo.Home = "/Acess/Users/Guest";
57                 break;
58         }
59         return &gUserInfo;
60 }
61

UCC git Repository :: git.ucc.asn.au