source: titan/plugins/betarobot/betarobot.h @ 23287

Last change on this file since 23287 was 23287, checked in by nit, 11 years ago

[titan] add betaronot plugin

File size: 1.4 KB
Line 
1#ifndef BETAROBOT_H
2#define BETAROBOT_H
3
4betarobotthread()
5{
6        int max = 0, akt = 0, rccode = -1, r = 0;
7       
8        //get max rc entry
9        m_lock(&status.clistmutex, 12);
10        struct clist **clist = rcconfig;
11        for(i = 0; i < LISTHASHSIZE; i++)
12        {
13                node = clist[i];
14
15                while(node != NULL)
16                {
17                        max++;
18                        node = node->next;
19                }
20        }
21        m_unlock(&status.clistmutex, 12);
22       
23        while(1)
24        {
25                r = getrandom(max);
26                akt = 0, rccode = -1;
27               
28                m_lock(&status.clistmutex, 12);
29                clist = rcconfig
30                for(i = 0; i < LISTHASHSIZE; i++)
31                {
32                        node = clist[i];
33       
34                        while(node != NULL)
35                        {
36                                akt++;
37                                if(akt == r)
38                                {
39                                        if(node->value != NULL)
40                                                rccode = atoi(node->value);
41                                        break;         
42                                }
43                                node = node->next;
44                        }
45                }
46                m_unlock(&status.clistmutex, 12);
47               
48                if(rccode != -1)
49                        writerc(rccode);
50        }
51}
52
53void screenbetarobot()
54{
55        int pinret = 0;
56       
57        if(textbox(_("Message"), _("This Plugin is only for Betatester and can change your Settings!\nRealy run it?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 300, 0, 0) != 1) return;
58
59        if(!file_exist("/etc/.beta"))
60                pinret = screenpincheck(3, NULL);
61        if(pinret != 0) return;
62       
63        writerc(getrcconfigint("rcexit", NULL));
64        writerc(getrcconfigint("rcexit", NULL));
65        writerc(getrcconfigint("rcexit", NULL));
66        writerc(getrcconfigint("rcexit", NULL));
67        writerc(getrcconfigint("rcexit", NULL));       
68        addtimer(&betarobotthread, START, 1000, 1, NULL, NULL, NULL);
69}
70
71#endif
Note: See TracBrowser for help on using the repository browser.