2 |
3 | using namespace std;
4 | int main()
5 | {
6 | char* p = NULL;
7 | *p = 'a';
8 | cout<
3 | #include
4 |
5 | #define CASE(STA)\
6 | case STA: \
7 | puts( #STA );
8 |
9 | #define deftest(name, pathname, fin, fout) \
10 | int test_##name () \
11 | {\
12 | if(fork() == 0){\
13 | struct sablebox sbox;\
14 | struct profile ret;\
15 | puts("------------" #name "-------------------\n");\
16 | sable_init(&sbox, #pathname, NULL, #fin, #fout, 1000, 1024*50, 0);\
17 | ret = sable_run(&sbox);\
18 | switch(ret.status){\
19 | CASE(PROF_SUCCESS)\
20 | break;\
21 | CASE(PROF_NOTSET)\
22 | break;\
23 | CASE(PROF_RUNTIME_ERROR)\
24 | printf("%s\n", ret.info);\
25 | break;\
26 | CASE(PROF_TIME_LIMIT_EXCEED)\
27 | break;\
28 | CASE(PROF_MEMORY_LIMIT_EXCEED)\
29 | break;\
30 | CASE(PROF_SYSTEM_ERROR)\
31 | break;\
32 | }\
33 | printf("Memory: %ld\nTime: %ld\n", ret.memory, ret.time);\
34 | puts("");\
35 | puts("----------------------------------------\n");\
36 | exit(0);\
37 | }else{\
38 | wait(0);\
39 | }\
40 | }
41 | deftest(re_seg, ./re_seg, t.in, t.out)
42 | deftest(re_div0, ./re_div0, t.in, t.out)
43 | deftest(helloworld, ./helloworld, t.in, t.out)
44 | deftest(mle_static, ./mle_static, t.in, t.out)
45 | deftest(mle_dyn, ./mle_dyn, t.in, t.out)
46 | deftest(1003re, ./1003re, 1003.in, 1003.out)
47 | deftest(1500ac, ./1500ac, 1500.in, 1500.out)
48 | deftest(2000mle, ./2000mle, 2000.in, 2000.out)
49 | deftest(tle, ./tle, t.in, t.out)
50 | deftest(block, ./block, t.in, t.out)
51 | deftest(futex_test, ./futex_test, 3172.in, t.out)
52 |
53 | int main(int argc, char** argv)
54 | {
55 | test_tle();
56 | test_helloworld();
57 | test_re_div0();
58 | test_re_seg();
59 | test_mle_static();
60 | test_mle_dyn();
61 | test_1003re();
62 | test_1500ac();
63 | test_2000mle();
64 | test_block();
65 | test_futex_test();
66 | return 0;
67 | }
68 |
--------------------------------------------------------------------------------
/daemon/libsablebox/scaffold.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/libsablebox/scaffold.o
--------------------------------------------------------------------------------
/daemon/libsablebox/t.in:
--------------------------------------------------------------------------------
1 | 123
2 |
--------------------------------------------------------------------------------
/daemon/libsablebox/t.out:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/libsablebox/t.out
--------------------------------------------------------------------------------
/daemon/libsablebox/t.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/libsablebox/t.txt
--------------------------------------------------------------------------------
/daemon/libsablebox/tle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/libsablebox/tle
--------------------------------------------------------------------------------
/daemon/libsablebox/tle.c:
--------------------------------------------------------------------------------
1 | int main()
2 | {
3 | for(;;);
4 | }
--------------------------------------------------------------------------------
/daemon/libsablebox/tle.cpp:
--------------------------------------------------------------------------------
1 | int main()
2 | {
3 | while(1)
4 | ;
5 | return 0;
6 | }
7 |
--------------------------------------------------------------------------------
/daemon/monitor/oj_monitor.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | #define JUDGE_USER_NAME "judge"
13 | #define DAEMON_PATH "/home/zhang/daemon"
14 |
15 | #define MY_SPECIAL_CODE 135
16 |
17 | struct passwd * user_info;
18 | uid_t judge_uid;
19 | pid_t cpid;
20 | int stopped;
21 |
22 | void signal_handle(int p)
23 | {
24 | kill(-cpid, SIGKILL);
25 | stopped = 1;
26 | }
27 | int main(int argc, char *argv[])
28 | {
29 | if(0 != getuid()) {
30 | puts("getuid() != 0");
31 | exit(EXIT_FAILURE);
32 | }
33 | if(!(user_info = getpwnam(JUDGE_USER_NAME))) {
34 | puts("Cannot find judge user");
35 | exit(EXIT_FAILURE);
36 | }
37 | judge_uid = user_info->pw_uid;
38 |
39 | if(0 == fork()) {
40 | int fd;
41 | fd = open("/var/lock/ojdaemon.lock", O_WRONLY|O_CREAT);
42 | if(fd==-1 || flock(fd, LOCK_EX|LOCK_NB)) {
43 | puts("Cannot get lock");
44 | exit(EXIT_FAILURE);
45 | }
46 |
47 | if(-1 == setsid()) {
48 | perror("setsid");
49 | exit(EXIT_FAILURE);
50 | }
51 | if(SIG_ERR == signal(SIGTERM, signal_handle)) {
52 | perror("signal");
53 | exit(EXIT_FAILURE);
54 | }
55 |
56 | openlog("bashu-onlinejudge", LOG_PERROR|LOG_PID, LOG_DAEMON);
57 |
58 | puts("Monitor started");
59 | for(;;) {
60 | cpid = fork();
61 | if (cpid == -1) {
62 | perror("fork");
63 | syslog(LOG_ERR, "Can't fork");
64 | exit(EXIT_FAILURE);
65 | }
66 |
67 | if (cpid == 0) {
68 | freopen("/var/log/onlinejudge.log", "a", stdout);
69 |
70 | if(-1 == setsid()) {
71 | perror("setsid");
72 | _exit(MY_SPECIAL_CODE);
73 | }
74 |
75 | setuid(judge_uid);
76 |
77 | if(-1 == execl(DAEMON_PATH, DAEMON_PATH, NULL)) {
78 | perror("Cannot execute daemon");
79 | _exit(MY_SPECIAL_CODE);
80 | }
81 | } else {
82 | pid_t w;
83 | int status;
84 |
85 | syslog(LOG_INFO, "Child PID is %ld\n", (long) cpid);
86 | syslog(LOG_INFO, "Set UID %ld\n", (long) judge_uid);
87 |
88 | w = waitpid(cpid, &status, WUNTRACED);
89 | if (w == -1) {
90 | syslog(LOG_ERR, "waitpid failed");
91 | perror("waitpid");
92 | exit(EXIT_FAILURE);
93 | }
94 |
95 | kill(-cpid, SIGKILL); //kill runner
96 |
97 | if (WIFEXITED(status)) {
98 | syslog(LOG_ERR, "exited, status=%d\n", WEXITSTATUS(status));
99 | if(MY_SPECIAL_CODE == WEXITSTATUS(status))
100 | break;
101 | } else if (WIFSIGNALED(status)) {
102 | syslog(LOG_ERR, "killed by signal %d\n", WTERMSIG(status));
103 | } else if (WIFSTOPPED(status)) {
104 | int ign;
105 | waitpid(cpid, &ign, 0); //avoid zombie
106 | syslog(LOG_ERR, "stopped by signal %d\n", WSTOPSIG(status));
107 | } else if (WIFCONTINUED(status)) {
108 | syslog(LOG_ERR, "continued\n");
109 | }
110 |
111 | if(stopped) {
112 | syslog(LOG_INFO, "Monitor stopped...\n");
113 | break;
114 | }
115 | syslog(LOG_INFO, "Sleep 2s...\n");
116 | sleep(2);
117 | }
118 | }
119 | flock(fd, LOCK_UN);
120 | close(fd);
121 | }
122 | return 0;
123 | }
124 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/libmysql.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/mysql/mysql_win/libmysql.a
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/my_alloc.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 |
16 | /*
17 | Data structures for mysys/my_alloc.c (root memory allocator)
18 | */
19 |
20 | #ifndef _my_alloc_h
21 | #define _my_alloc_h
22 |
23 | #define ALLOC_MAX_BLOCK_TO_DROP 4096
24 | #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | typedef struct st_used_mem
31 | { /* struct for once_alloc (block) */
32 | struct st_used_mem *next; /* Next block in use */
33 | unsigned int left; /* memory left in block */
34 | unsigned int size; /* size of block */
35 | } USED_MEM;
36 |
37 |
38 | typedef struct st_mem_root
39 | {
40 | USED_MEM *free; /* blocks with free memory in it */
41 | USED_MEM *used; /* blocks almost without free memory */
42 | USED_MEM *pre_alloc; /* preallocated block */
43 | /* if block have less memory it will be put in 'used' list */
44 | size_t min_malloc;
45 | size_t block_size; /* initial block size */
46 | unsigned int block_num; /* allocated blocks counter */
47 | /*
48 | first free block in queue test counter (if it exceed
49 | MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
50 | */
51 | unsigned int first_block_usage;
52 |
53 | void (*error_handler)(void);
54 | } MEM_ROOT;
55 |
56 | #ifdef __cplusplus
57 | }
58 | #endif
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/my_attribute.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 |
16 | /*
17 | Helper macros used for setting different __attributes__
18 | on functions in a portable fashion
19 | */
20 |
21 | #ifndef _my_attribute_h
22 | #define _my_attribute_h
23 |
24 | #if defined(__GNUC__)
25 | # ifndef GCC_VERSION
26 | # define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
27 | # endif
28 | #endif
29 |
30 | /*
31 | Disable __attribute__() on gcc < 2.7, g++ < 3.4, and non-gcc compilers.
32 | Some forms of __attribute__ are actually supported in earlier versions of
33 | g++, but we just disable them all because we only use them to generate
34 | compilation warnings.
35 | */
36 | #ifndef __attribute__
37 | # if !defined(__GNUC__)
38 | # define __attribute__(A)
39 | # elif GCC_VERSION < 2008
40 | # define __attribute__(A)
41 | # elif defined(__cplusplus) && GCC_VERSION < 3004
42 | # define __attribute__(A)
43 | # endif
44 | #endif
45 |
46 | /*
47 | __attribute__((format(...))) is only supported in gcc >= 2.8 and g++ >= 3.4
48 | But that's already covered by the __attribute__ tests above, so this is
49 | just a convenience macro.
50 | */
51 | #ifndef ATTRIBUTE_FORMAT
52 | # define ATTRIBUTE_FORMAT(style, m, n) __attribute__((format(style, m, n)))
53 | #endif
54 |
55 | /*
56 |
57 | __attribute__((format(...))) on a function pointer is not supported
58 | until gcc 3.1
59 | */
60 | #ifndef ATTRIBUTE_FORMAT_FPTR
61 | # if (GCC_VERSION >= 3001)
62 | # define ATTRIBUTE_FORMAT_FPTR(style, m, n) ATTRIBUTE_FORMAT(style, m, n)
63 | # else
64 | # define ATTRIBUTE_FORMAT_FPTR(style, m, n)
65 | # endif /* GNUC >= 3.1 */
66 | #endif
67 |
68 |
69 | #endif
70 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/my_dir.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 |
16 | #ifndef MY_DIR_H
17 | #define MY_DIR_H
18 |
19 | #include "my_global.h"
20 |
21 | #include
22 |
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | /* Defines for my_dir and my_stat */
28 |
29 | #define MY_S_IFMT S_IFMT /* type of file */
30 | #define MY_S_IFDIR S_IFDIR /* directory */
31 | #define MY_S_IFCHR S_IFCHR /* character special */
32 | #define MY_S_IFBLK S_IFBLK /* block special */
33 | #define MY_S_IFREG S_IFREG /* regular */
34 | #define MY_S_IFIFO S_IFIFO /* fifo */
35 | #define MY_S_ISUID S_ISUID /* set user id on execution */
36 | #define MY_S_ISGID S_ISGID /* set group id on execution */
37 | #define MY_S_ISVTX S_ISVTX /* save swapped text even after use */
38 | #define MY_S_IREAD S_IREAD /* read permission, owner */
39 | #define MY_S_IWRITE S_IWRITE /* write permission, owner */
40 | #define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */
41 |
42 | #define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR)
43 | #define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR)
44 | #define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK)
45 | #define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG)
46 | #define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO)
47 |
48 | #define MY_DONT_SORT 512 /* my_lib; Don't sort files */
49 | #define MY_WANT_STAT 1024 /* my_lib; stat files */
50 |
51 | /* typedefs for my_dir & my_stat */
52 |
53 | #ifdef USE_MY_STAT_STRUCT
54 |
55 | typedef struct my_stat
56 | {
57 | dev_t st_dev; /* major & minor device numbers */
58 | ino_t st_ino; /* inode number */
59 | ushort st_mode; /* file permissons (& suid sgid .. bits) */
60 | short st_nlink; /* number of links to file */
61 | ushort st_uid; /* user id */
62 | ushort st_gid; /* group id */
63 | dev_t st_rdev; /* more major & minor device numbers (???) */
64 | off_t st_size; /* size of file */
65 | time_t st_atime; /* time for last read */
66 | time_t st_mtime; /* time for last contens modify */
67 | time_t st_ctime; /* time for last inode or contents modify */
68 | } MY_STAT;
69 |
70 | #else
71 |
72 | #if(_MSC_VER)
73 | #define MY_STAT struct _stati64 /* 64 bit file size */
74 | #else
75 | #define MY_STAT struct stat /* Orginal struct have what we need */
76 | #endif
77 |
78 | #endif /* USE_MY_STAT_STRUCT */
79 |
80 | /* Struct describing one file returned from my_dir */
81 | typedef struct fileinfo
82 | {
83 | char *name;
84 | MY_STAT *mystat;
85 | } FILEINFO;
86 |
87 | typedef struct st_my_dir /* Struct returned from my_dir */
88 | {
89 | /*
90 | These members are just copies of parts of DYNAMIC_ARRAY structure,
91 | which is allocated right after the end of MY_DIR structure (MEM_ROOT
92 | for storing names is also resides there). We've left them here because
93 | we don't want to change code that uses my_dir.
94 | */
95 | struct fileinfo *dir_entry;
96 | uint number_off_files;
97 | } MY_DIR;
98 |
99 | extern MY_DIR *my_dir(const char *path,myf MyFlags);
100 | extern void my_dirend(MY_DIR *buffer);
101 | extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags);
102 | extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags);
103 |
104 | #ifdef __cplusplus
105 | }
106 | #endif
107 |
108 | #endif /* MY_DIR_H */
109 |
110 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/my_list.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 |
16 | #ifndef _list_h_
17 | #define _list_h_
18 |
19 | #ifdef __cplusplus
20 | extern "C" {
21 | #endif
22 |
23 | typedef struct st_list {
24 | struct st_list *prev,*next;
25 | void *data;
26 | } LIST;
27 |
28 | typedef int (*list_walk_action)(void *,void *);
29 |
30 | extern LIST *list_add(LIST *root,LIST *element);
31 | extern LIST *list_delete(LIST *root,LIST *element);
32 | extern LIST *list_cons(void *data,LIST *root);
33 | extern LIST *list_reverse(LIST *root);
34 | extern void list_free(LIST *root,unsigned int free_data);
35 | extern unsigned int list_length(LIST *);
36 | extern int list_walk(LIST *,list_walk_action action,unsigned char * argument);
37 |
38 | #define list_rest(a) ((a)->next)
39 | #define list_push(a,b) (a)=list_cons((b),(a))
40 | #define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old); my_free(old); }
41 |
42 | #ifdef __cplusplus
43 | }
44 | #endif
45 | #endif
46 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/my_net.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
15 |
16 | /*
17 | This file is also used to make handling of sockets and ioctl()
18 | portable accross systems.
19 |
20 | */
21 |
22 | #ifndef _my_net_h
23 | #define _my_net_h
24 |
25 | #include "my_global.h" /* C_MODE_START, C_MODE_END */
26 |
27 | C_MODE_START
28 |
29 | #include
30 | #ifdef HAVE_SYS_SOCKET_H
31 | #include
32 | #endif
33 | #ifdef HAVE_NETINET_IN_H
34 | #include
35 | #endif
36 | #ifdef HAVE_ARPA_INET_H
37 | #include
38 | #endif
39 | #ifdef HAVE_POLL
40 | #include
41 | #endif
42 | #ifdef HAVE_SYS_IOCTL_H
43 | #include
44 | #endif
45 |
46 | #if !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES)
47 | #include
48 | #include
49 | #include
50 | #if !defined(alpha_linux_port)
51 | #include
52 | #endif
53 | #endif
54 |
55 | #if defined(__WIN__)
56 | #define O_NONBLOCK 1 /* For emulation of fcntl() */
57 |
58 | /*
59 | SHUT_RDWR is called SD_BOTH in windows and
60 | is defined to 2 in winsock2.h
61 | #define SD_BOTH 0x02
62 | */
63 | #define SHUT_RDWR 0x02
64 |
65 | #endif
66 |
67 | /*
68 | On OSes which don't have the in_addr_t, we guess that using uint32 is the best
69 | possible choice. We guess this from the fact that on HP-UX64bit & FreeBSD64bit
70 | & Solaris64bit, in_addr_t is equivalent to uint32. And on Linux32bit too.
71 | */
72 | #ifndef HAVE_IN_ADDR_T
73 | #define in_addr_t uint32
74 | #endif
75 |
76 |
77 | C_MODE_END
78 | #endif
79 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/my_xml.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2000 MySQL AB
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
15 |
16 |
17 | #ifndef _my_xml_h
18 | #define _my_xml_h
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 |
25 | #define MY_XML_OK 0
26 | #define MY_XML_ERROR 1
27 |
28 | /*
29 | A flag whether to use absolute tag names in call-back functions,
30 | like "a", "a.b" and "a.b.c" (used in character set file parser),
31 | or relative names like "a", "b" and "c".
32 | */
33 | #define MY_XML_FLAG_RELATIVE_NAMES 1
34 |
35 | /*
36 | A flag whether to skip normilization of text values before calling
37 | call-back functions: i.e. skip leading/trailing spaces,
38 | \r, \n, \t characters.
39 | */
40 | #define MY_XML_FLAG_SKIP_TEXT_NORMALIZATION 2
41 |
42 | enum my_xml_node_type
43 | {
44 | MY_XML_NODE_TAG, /* can have TAG, ATTR and TEXT children */
45 | MY_XML_NODE_ATTR, /* can have TEXT children */
46 | MY_XML_NODE_TEXT /* cannot have children */
47 | };
48 |
49 | typedef struct xml_stack_st
50 | {
51 | int flags;
52 | enum my_xml_node_type current_node_type;
53 | char errstr[128];
54 | char attr[128];
55 | char *attrend;
56 | const char *beg;
57 | const char *cur;
58 | const char *end;
59 | void *user_data;
60 | int (*enter)(struct xml_stack_st *st,const char *val, size_t len);
61 | int (*value)(struct xml_stack_st *st,const char *val, size_t len);
62 | int (*leave_xml)(struct xml_stack_st *st,const char *val, size_t len);
63 | } MY_XML_PARSER;
64 |
65 | void my_xml_parser_create(MY_XML_PARSER *st);
66 | void my_xml_parser_free(MY_XML_PARSER *st);
67 | int my_xml_parse(MY_XML_PARSER *st,const char *str, size_t len);
68 |
69 | void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
70 | const char *,
71 | size_t len));
72 | void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
73 | const char *,
74 | size_t len));
75 | void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
76 | const char *,
77 | size_t len));
78 | void my_xml_set_user_data(MY_XML_PARSER *st, void *);
79 |
80 | size_t my_xml_error_pos(MY_XML_PARSER *st);
81 | uint my_xml_error_lineno(MY_XML_PARSER *st);
82 |
83 | const char *my_xml_error_string(MY_XML_PARSER *st);
84 |
85 | #ifdef __cplusplus
86 | }
87 | #endif
88 |
89 | #endif /* _my_xml_h */
90 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql/innodb_priv.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
15 |
16 | #ifndef INNODB_PRIV_INCLUDED
17 | #define INNODB_PRIV_INCLUDED
18 |
19 | /** @file Declaring server-internal functions that are used by InnoDB. */
20 |
21 | #include
22 |
23 | class THD;
24 |
25 | int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
26 | bool schema_table_store_record(THD *thd, TABLE *table);
27 | void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
28 | bool check_global_access(THD *thd, ulong want_access);
29 | uint strconvert(CHARSET_INFO *from_cs, const char *from,
30 | CHARSET_INFO *to_cs, char *to, uint to_length,
31 | uint *errors);
32 | void sql_print_error(const char *format, ...);
33 |
34 |
35 |
36 | #endif /* INNODB_PRIV_INCLUDED */
37 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql/plugin_auth.h:
--------------------------------------------------------------------------------
1 | #ifndef MYSQL_PLUGIN_AUTH_INCLUDED
2 | /* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 |
4 | This program is free software; you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation; version 2 of the License.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 |
17 | /**
18 | @file
19 |
20 | Authentication Plugin API.
21 |
22 | This file defines the API for server authentication plugins.
23 | */
24 |
25 | #define MYSQL_PLUGIN_AUTH_INCLUDED
26 |
27 | #include
28 |
29 | #define MYSQL_AUTHENTICATION_INTERFACE_VERSION 0x0100
30 |
31 | #include
32 |
33 | /* defines for MYSQL_SERVER_AUTH_INFO.password_used */
34 |
35 | #define PASSWORD_USED_NO 0
36 | #define PASSWORD_USED_YES 1
37 | #define PASSWORD_USED_NO_MENTION 2
38 |
39 |
40 | /**
41 | Provides server plugin access to authentication information
42 | */
43 | typedef struct st_mysql_server_auth_info
44 | {
45 | /**
46 | User name as sent by the client and shown in USER().
47 | NULL if the client packet with the user name was not received yet.
48 | */
49 | char *user_name;
50 |
51 | /**
52 | Length of user_name
53 | */
54 | unsigned int user_name_length;
55 |
56 | /**
57 | A corresponding column value from the mysql.user table for the
58 | matching account name
59 | */
60 | const char *auth_string;
61 |
62 | /**
63 | Length of auth_string
64 | */
65 | unsigned long auth_string_length;
66 |
67 | /**
68 | Matching account name as found in the mysql.user table.
69 | A plugin can override it with another name that will be
70 | used by MySQL for authorization, and shown in CURRENT_USER()
71 | */
72 | char authenticated_as[MYSQL_USERNAME_LENGTH+1];
73 |
74 |
75 | /**
76 | The unique user name that was used by the plugin to authenticate.
77 | Plugins should put null-terminated UTF-8 here.
78 | Available through the @@EXTERNAL_USER variable.
79 | */
80 | char external_user[512];
81 |
82 | /**
83 | This only affects the "Authentication failed. Password used: %s"
84 | error message. has the following values :
85 | 0 : %s will be NO.
86 | 1 : %s will be YES.
87 | 2 : there will be no %s.
88 | Set it as appropriate or ignore at will.
89 | */
90 | int password_used;
91 |
92 | /**
93 | Set to the name of the connected client host, if it can be resolved,
94 | or to its IP address otherwise.
95 | */
96 | const char *host_or_ip;
97 |
98 | /**
99 | Length of host_or_ip
100 | */
101 | unsigned int host_or_ip_length;
102 |
103 | } MYSQL_SERVER_AUTH_INFO;
104 |
105 | /**
106 | Server authentication plugin descriptor
107 | */
108 | struct st_mysql_auth
109 | {
110 | int interface_version; /** version plugin uses */
111 | /**
112 | A plugin that a client must use for authentication with this server
113 | plugin. Can be NULL to mean "any plugin".
114 | */
115 | const char *client_auth_plugin;
116 | /**
117 | Function provided by the plugin which should perform authentication (using
118 | the vio functions if necessary) and return 0 if successful. The plugin can
119 | also fill the info.authenticated_as field if a different username should be
120 | used for authorization.
121 | */
122 | int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info);
123 | };
124 | #endif
125 |
126 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql/psi/psi_abi_v1.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software Foundation,
14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15 |
16 | /**
17 | @file mysql/psi/psi_abi_v1.h
18 | ABI check for mysql/psi/psi.h, when using PSI_VERSION_1.
19 | This file is only used to automate detection of changes between versions.
20 | Do not include this file, include mysql/psi/psi.h instead.
21 | */
22 | #define USE_PSI_1
23 | #define HAVE_PSI_INTERFACE
24 | #define _global_h
25 | #include "mysql/psi/psi.h"
26 |
27 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql/psi/psi_abi_v2.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software Foundation,
14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15 |
16 | /**
17 | @file mysql/psi/psi_abi_v1.h
18 | ABI check for mysql/psi/psi.h, when using PSI_VERSION_2.
19 | This file is only used to automate detection of changes between versions.
20 | Do not include this file, include mysql/psi/psi.h instead.
21 | */
22 | #define USE_PSI_2
23 | #define HAVE_PSI_INTERFACE
24 | #define _global_h
25 | #include "mysql/psi/psi.h"
26 |
27 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql/service_my_snprintf.h:
--------------------------------------------------------------------------------
1 | #ifndef MYSQL_SERVICE_MY_SNPRINTF_INCLUDED
2 | /* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
3 |
4 | This program is free software; you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation; version 2 of the License.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 |
17 | /**
18 | @file
19 | my_snprintf service
20 |
21 | Portable and limited vsnprintf() implementation.
22 |
23 | This is a portable, limited vsnprintf() implementation, with some
24 | extra features. "Portable" means that it'll produce identical result
25 | on all platforms (for example, on Windows and Linux system printf %e
26 | formats the exponent differently, on different systems %p either
27 | prints leading 0x or not, %s may accept null pointer or crash on
28 | it). "Limited" means that it does not support all the C89 features.
29 | But it supports few extensions, not in any standard.
30 |
31 | my_vsnprintf(to, n, fmt, ap)
32 |
33 | @param[out] to A buffer to store the result in
34 | @param[in] n Store up to n-1 characters, followed by an end 0
35 | @param[in] fmt printf-like format string
36 | @param[in] ap Arguments
37 |
38 | @return a number of bytes written to a buffer *excluding* terminating '\0'
39 |
40 | @post
41 | The syntax of a format string is generally the same:
42 | %
43 | where everithing but the format is optional.
44 |
45 | Three one-character flags are recognized:
46 | '0' has the standard zero-padding semantics;
47 | '-' is parsed, but silently ignored;
48 | '`' (backtick) is only supported for strings (%s) and means that the
49 | string will be quoted according to MySQL identifier quoting rules.
50 |
51 | Both and can be specified as numbers or '*'.
52 |
53 | can be 'l', 'll', or 'z'.
54 |
55 | Supported formats are 's' (null pointer is accepted, printed as
56 | "(null)"), 'b' (extension, see below), 'c', 'd', 'i', 'u', 'x', 'o',
57 | 'X', 'p' (works as 0x%x).
58 |
59 | Standard syntax for positional arguments $n is supported.
60 |
61 | Extensions:
62 |
63 | Flag '`' (backtick): see above.
64 |
65 | Format 'b': binary buffer, prints exactly bytes from the
66 | argument, without stopping at '\0'.
67 | */
68 |
69 | #ifdef __cplusplus
70 | extern "C" {
71 | #endif
72 |
73 | #ifndef MYSQL_ABI_CHECK
74 | #include
75 | #include
76 | #endif
77 |
78 | extern struct my_snprintf_service_st {
79 | size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
80 | size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
81 | } *my_snprintf_service;
82 |
83 | #ifdef MYSQL_DYNAMIC_PLUGIN
84 |
85 | #define my_vsnprintf my_snprintf_service->my_vsnprintf_type
86 | #define my_snprintf my_snprintf_service->my_snprintf_type
87 |
88 | #else
89 |
90 | size_t my_snprintf(char* to, size_t n, const char* fmt, ...);
91 | size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
92 |
93 | #endif
94 |
95 | #ifdef __cplusplus
96 | }
97 | #endif
98 |
99 | #define MYSQL_SERVICE_MY_SNPRINTF_INCLUDED
100 | #endif
101 |
102 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql/service_thd_wait.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 |
16 | #ifndef MYSQL_SERVICE_THD_WAIT_INCLUDED
17 | #define MYSQL_SERVICE_THD_WAIT_INCLUDED
18 |
19 | /**
20 | @file include/mysql/service_thd_wait.h
21 | This service provides functions for plugins and storage engines to report
22 | when they are going to sleep/stall.
23 |
24 | SYNOPSIS
25 | thd_wait_begin() - call just before a wait begins
26 | thd Thread object
27 | Use NULL if the thd is NOT known.
28 | wait_type Type of wait
29 | 1 -- short wait (e.g. for mutex)
30 | 2 -- medium wait (e.g. for disk io)
31 | 3 -- large wait (e.g. for locked row/table)
32 | NOTES
33 | This is used by the threadpool to have better knowledge of which
34 | threads that currently are actively running on CPUs. When a thread
35 | reports that it's going to sleep/stall, the threadpool scheduler is
36 | free to start another thread in the pool most likely. The expected wait
37 | time is simply an indication of how long the wait is expected to
38 | become, the real wait time could be very different.
39 |
40 | thd_wait_end() called immediately after the wait is complete
41 |
42 | thd_wait_end() MUST be called if thd_wait_begin() was called.
43 |
44 | Using thd_wait_...() service is optional but recommended. Using it will
45 | improve performance as the thread pool will be more active at managing the
46 | thread workload.
47 | */
48 |
49 | #ifdef __cplusplus
50 | extern "C" {
51 | #endif
52 |
53 | /*
54 | One should only report wait events that could potentially block for a
55 | long time. A mutex wait is too short of an event to report. The reason
56 | is that an event which is reported leads to a new thread starts
57 | executing a query and this has a negative impact of usage of CPU caches
58 | and thus the expected gain of starting a new thread must be higher than
59 | the expected cost of lost performance due to starting a new thread.
60 |
61 | Good examples of events that should be reported are waiting for row locks
62 | that could easily be for many milliseconds or even seconds and the same
63 | holds true for global read locks, table locks and other meta data locks.
64 | Another event of interest is going to sleep for an extended time.
65 | */
66 | typedef enum _thd_wait_type_e {
67 | THD_WAIT_SLEEP= 1,
68 | THD_WAIT_DISKIO= 2,
69 | THD_WAIT_ROW_LOCK= 3,
70 | THD_WAIT_GLOBAL_LOCK= 4,
71 | THD_WAIT_META_DATA_LOCK= 5,
72 | THD_WAIT_TABLE_LOCK= 6,
73 | THD_WAIT_USER_LOCK= 7,
74 | THD_WAIT_BINLOG= 8,
75 | THD_WAIT_GROUP_COMMIT= 9,
76 | THD_WAIT_SYNC= 10,
77 | THD_WAIT_LAST= 11
78 | } thd_wait_type;
79 |
80 | extern struct thd_wait_service_st {
81 | void (*thd_wait_begin_func)(MYSQL_THD, int);
82 | void (*thd_wait_end_func)(MYSQL_THD);
83 | } *thd_wait_service;
84 |
85 | #ifdef MYSQL_DYNAMIC_PLUGIN
86 |
87 | #define thd_wait_begin(_THD, _WAIT_TYPE) \
88 | thd_wait_service->thd_wait_begin_func(_THD, _WAIT_TYPE)
89 | #define thd_wait_end(_THD) thd_wait_service->thd_wait_end_func(_THD)
90 |
91 | #else
92 |
93 | void thd_wait_begin(MYSQL_THD thd, int wait_type);
94 | void thd_wait_end(MYSQL_THD thd);
95 |
96 | #endif
97 |
98 | #ifdef __cplusplus
99 | }
100 | #endif
101 |
102 | #endif
103 |
104 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql/service_thread_scheduler.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 |
4 | This program is free software; you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation; version 2 of the License.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 | */
17 |
18 | #ifndef SERVICE_THREAD_SCHEDULER_INCLUDED
19 | #define SERVICE_THREAD_SCHEDULER_INCLUDED
20 |
21 | #ifdef __cplusplus
22 | extern "C" {
23 | #endif
24 |
25 | struct scheduler_functions;
26 |
27 | extern struct my_thread_scheduler_service {
28 | int (*set)(struct scheduler_functions *scheduler);
29 | int (*reset)();
30 | } *my_thread_scheduler_service;
31 |
32 | #ifdef MYSQL_DYNAMIC_PLUGIN
33 |
34 | #define my_thread_scheduler_set(F) my_thread_scheduler_service->set((F))
35 | #define my_thread_scheduler_reset() my_thread_scheduler_service->reset()
36 |
37 | #else
38 |
39 | /**
40 | Set the thread scheduler to use for the server.
41 |
42 | @param scheduler Pointer to scheduler callbacks to use.
43 | @retval 0 Scheduler installed correctly.
44 | @retval 1 Invalid value (NULL) used for scheduler.
45 | */
46 | int my_thread_scheduler_set(struct scheduler_functions *scheduler);
47 |
48 | /**
49 | Restore the previous thread scheduler.
50 |
51 | @note If no thread scheduler was installed previously with
52 | thd_set_thread_scheduler, this function will report an error.
53 |
54 | @retval 0 Scheduler installed correctly.
55 | @retval 1 No scheduler installed.
56 | */
57 | int my_thread_scheduler_reset();
58 |
59 | #endif
60 |
61 | #ifdef __cplusplus
62 | }
63 | #endif
64 |
65 | #endif /* SERVICE_THREAD_SCHEDULER_INCLUDED */
66 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql/services.h:
--------------------------------------------------------------------------------
1 | #ifndef MYSQL_SERVICES_INCLUDED
2 | /* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
3 |
4 | This program is free software; you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation; version 2 of the License.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16 |
17 | #ifdef __cplusplus
18 | extern "C" {
19 | #endif
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 |
30 | #define MYSQL_SERVICES_INCLUDED
31 | #endif
32 |
33 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql_embed.h:
--------------------------------------------------------------------------------
1 | #ifndef MYSQL_EMBED_INCLUDED
2 | #define MYSQL_EMBED_INCLUDED
3 |
4 | /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
5 |
6 | This program is free software; you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation; version 2 of the License.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
18 |
19 | /* Defines that are unique to the embedded version of MySQL */
20 |
21 | #ifdef EMBEDDED_LIBRARY
22 |
23 | /* Things we don't need in the embedded version of MySQL */
24 | /* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */
25 |
26 | #undef HAVE_DLOPEN /* No udf functions */
27 | #undef HAVE_SMEM /* No shared memory */
28 |
29 | #endif /* EMBEDDED_LIBRARY */
30 | #endif /* MYSQL_EMBED_INCLUDED */
31 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql_time.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 2004 MySQL AB
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
15 |
16 | #ifndef _mysql_time_h_
17 | #define _mysql_time_h_
18 |
19 | /*
20 | Time declarations shared between the server and client API:
21 | you should not add anything to this header unless it's used
22 | (and hence should be visible) in mysql.h.
23 | If you're looking for a place to add new time-related declaration,
24 | it's most likely my_time.h. See also "C API Handling of Date
25 | and Time Values" chapter in documentation.
26 | */
27 |
28 | enum enum_mysql_timestamp_type
29 | {
30 | MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
31 | MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
32 | };
33 |
34 |
35 | /*
36 | Structure which is used to represent datetime values inside MySQL.
37 |
38 | We assume that values in this structure are normalized, i.e. year <= 9999,
39 | month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions
40 | in server such as my_system_gmt_sec() or make_time() family of functions
41 | rely on this (actually now usage of make_*() family relies on a bit weaker
42 | restriction). Also functions that produce MYSQL_TIME as result ensure this.
43 | There is one exception to this rule though if this structure holds time
44 | value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold
45 | bigger values.
46 | */
47 | typedef struct st_mysql_time
48 | {
49 | unsigned int year, month, day, hour, minute, second;
50 | unsigned long second_part;
51 | my_bool neg;
52 | enum enum_mysql_timestamp_type time_type;
53 | } MYSQL_TIME;
54 |
55 | #endif /* _mysql_time_h_ */
56 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/mysql_version.h:
--------------------------------------------------------------------------------
1 | /* Copyright Abandoned 1996, 1999, 2001 MySQL AB
2 | This file is public domain and comes with NO WARRANTY of any kind */
3 |
4 | /* Version numbers for protocol & mysqld */
5 |
6 | #ifndef _mysql_version_h
7 | #define _mysql_version_h
8 | #ifdef _CUSTOMCONFIG_
9 | #include
10 | #else
11 | #define PROTOCOL_VERSION 10
12 | #define MYSQL_SERVER_VERSION "5.5.22"
13 | #define MYSQL_BASE_VERSION "mysqld-5.5"
14 | #define MYSQL_SERVER_SUFFIX_DEF ""
15 | #define FRM_VER 6
16 | #define MYSQL_VERSION_ID 50522
17 | #define MYSQL_PORT 3306
18 | #define MYSQL_PORT_DEFAULT 0
19 | #define MYSQL_UNIX_ADDR "/tmp/mysql.sock"
20 | #define MYSQL_CONFIG_NAME "my"
21 | #define MYSQL_COMPILATION_COMMENT "MySQL Community Server (GPL)"
22 |
23 | /* mysqld compile time options */
24 | #endif /* _CUSTOMCONFIG_ */
25 |
26 | #ifndef LICENSE
27 | #define LICENSE GPL
28 | #endif /* LICENSE */
29 |
30 | #endif /* _mysql_version_h */
31 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/sslopt-case.h:
--------------------------------------------------------------------------------
1 | #ifndef SSLOPT_CASE_INCLUDED
2 | #define SSLOPT_CASE_INCLUDED
3 |
4 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
5 |
6 | This program is free software; you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation; version 2 of the License.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
18 |
19 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
20 | case OPT_SSL_KEY:
21 | case OPT_SSL_CERT:
22 | case OPT_SSL_CA:
23 | case OPT_SSL_CAPATH:
24 | case OPT_SSL_CIPHER:
25 | /*
26 | Enable use of SSL if we are using any ssl option
27 | One can disable SSL later by using --skip-ssl or --ssl=0
28 | */
29 | opt_use_ssl= 1;
30 | break;
31 | #endif
32 | #endif /* SSLOPT_CASE_INCLUDED */
33 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/sslopt-longopts.h:
--------------------------------------------------------------------------------
1 | #ifndef SSLOPT_LONGOPTS_INCLUDED
2 | #define SSLOPT_LONGOPTS_INCLUDED
3 |
4 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
5 |
6 | This program is free software; you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation; version 2 of the License.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
18 |
19 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
20 |
21 | {"ssl", OPT_SSL_SSL,
22 | "Enable SSL for connection (automatically enabled with other flags).",
23 | &opt_use_ssl, &opt_use_ssl, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
24 | {"ssl-ca", OPT_SSL_CA,
25 | "CA file in PEM format (check OpenSSL docs, implies --ssl).",
26 | &opt_ssl_ca, &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG,
27 | 0, 0, 0, 0, 0, 0},
28 | {"ssl-capath", OPT_SSL_CAPATH,
29 | "CA directory (check OpenSSL docs, implies --ssl).",
30 | &opt_ssl_capath, &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG,
31 | 0, 0, 0, 0, 0, 0},
32 | {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl).",
33 | &opt_ssl_cert, &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG,
34 | 0, 0, 0, 0, 0, 0},
35 | {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use (implies --ssl).",
36 | &opt_ssl_cipher, &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG,
37 | 0, 0, 0, 0, 0, 0},
38 | {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl).",
39 | &opt_ssl_key, &opt_ssl_key, 0, GET_STR, REQUIRED_ARG,
40 | 0, 0, 0, 0, 0, 0},
41 | #ifdef MYSQL_CLIENT
42 | {"ssl-verify-server-cert", OPT_SSL_VERIFY_SERVER_CERT,
43 | "Verify server's \"Common Name\" in its cert against hostname used "
44 | "when connecting. This option is disabled by default.",
45 | &opt_ssl_verify_server_cert, &opt_ssl_verify_server_cert,
46 | 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
47 | #endif
48 | #endif /* HAVE_OPENSSL */
49 | #endif /* SSLOPT_LONGOPTS_INCLUDED */
50 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/sslopt-vars.h:
--------------------------------------------------------------------------------
1 | #ifndef SSLOPT_VARS_INCLUDED
2 | #define SSLOPT_VARS_INCLUDED
3 |
4 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
5 |
6 | This program is free software; you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation; version 2 of the License.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
18 |
19 | #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
20 | #ifdef SSL_VARS_NOT_STATIC
21 | #define SSL_STATIC
22 | #else
23 | #define SSL_STATIC static
24 | #endif
25 | SSL_STATIC my_bool opt_use_ssl = 0;
26 | SSL_STATIC char *opt_ssl_ca = 0;
27 | SSL_STATIC char *opt_ssl_capath = 0;
28 | SSL_STATIC char *opt_ssl_cert = 0;
29 | SSL_STATIC char *opt_ssl_cipher = 0;
30 | SSL_STATIC char *opt_ssl_key = 0;
31 | #ifdef MYSQL_CLIENT
32 | SSL_STATIC my_bool opt_ssl_verify_server_cert= 0;
33 | #endif
34 | #endif
35 | #endif /* SSLOPT_VARS_INCLUDED */
36 |
--------------------------------------------------------------------------------
/daemon/mysql/mysql_win/typelib.h:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2 |
3 | This program is free software; you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation; version 2 of the License.
6 |
7 | This program is distributed in the hope that it will be useful,
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | GNU General Public License for more details.
11 |
12 | You should have received a copy of the GNU General Public License
13 | along with this program; if not, write to the Free Software
14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
15 |
16 |
17 | #ifndef _typelib_h
18 | #define _typelib_h
19 |
20 | #include "my_alloc.h"
21 |
22 | typedef struct st_typelib { /* Different types saved here */
23 | unsigned int count; /* How many types */
24 | const char *name; /* Name of typelib */
25 | const char **type_names;
26 | unsigned int *type_lengths;
27 | } TYPELIB;
28 |
29 | extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
30 | extern int find_type_or_exit(const char *x, TYPELIB *typelib,
31 | const char *option);
32 | #define FIND_TYPE_BASIC 0
33 | /** makes @c find_type() require the whole name, no prefix */
34 | #define FIND_TYPE_NO_PREFIX (1 << 0)
35 | /** always implicitely on, so unused, but old code may pass it */
36 | #define FIND_TYPE_NO_OVERWRITE (1 << 1)
37 | /** makes @c find_type() accept a number */
38 | #define FIND_TYPE_ALLOW_NUMBER (1 << 2)
39 | /** makes @c find_type() treat ',' as terminator */
40 | #define FIND_TYPE_COMMA_TERM (1 << 3)
41 |
42 | extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
43 | extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
44 | extern const char *get_type(TYPELIB *typelib,unsigned int nr);
45 | extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
46 |
47 | extern TYPELIB sql_protocol_typelib;
48 |
49 | my_ulonglong find_set_from_flags(const TYPELIB *lib, unsigned int default_name,
50 | my_ulonglong cur_set, my_ulonglong default_set,
51 | const char *str, unsigned int length,
52 | char **err_pos, unsigned int *err_len);
53 |
54 | #endif /* _typelib_h */
55 |
--------------------------------------------------------------------------------
/daemon/readconfig.cpp:
--------------------------------------------------------------------------------
1 | #include "INI1.26.h" // "feather-ini-parser" on googlecode
2 | #include "judge_daemon.h"
3 | #include "conf_items.h"
4 | #include //for MAXPATHLEN
5 |
6 | using std::string;
7 |
8 | #define MAXLANG 10
9 |
10 | int lang_extra_mem[MAXLANG];
11 | bool lang_exist[MAXLANG];
12 | string lang_ext[MAXLANG];
13 | string lang_compiler[MAXLANG];
14 |
15 | char DATABASE_HOST[64], DATABASE_USER[128], DATABASE_PASS[128], DATABASE_NAME[128];
16 | char HTTP_BIND_IP[32];
17 | uint16_t HTTP_BIND_PORT;
18 |
19 | char DataDir[MAXPATHLEN+16];
20 |
21 | typedef INI ini_t;
22 |
23 | bool read_config()
24 | {
25 | ini_t ini("config.ini", false);
26 | if(!ini.Parse()) {
27 | applog("Error: Cannot open config.ini, Exit...");
28 | exit(1);
29 | }
30 |
31 | ini.Select("system");
32 | std::string tmp = ini.Get(std::string("datadir"), std::string(""));
33 | if(tmp==""){
34 | applog("Error: We don't know your data directory.");
35 | return false;
36 | }
37 | strncpy(DataDir, tmp.c_str(), MAXPATHLEN);
38 |
39 | tmp = ini.Get(std::string("DATABASE_HOST"), std::string("localhost"));
40 | strncpy(DATABASE_HOST, tmp.c_str(), 62);
41 |
42 | tmp = ini.Get(std::string("DATABASE_USER"), std::string("root"));
43 | strncpy(DATABASE_USER, tmp.c_str(), 120);
44 |
45 | tmp = ini.Get(std::string("DATABASE_PASS"), std::string(""));
46 | strncpy(DATABASE_PASS, tmp.c_str(), 120);
47 |
48 | tmp = ini.Get(std::string("DATABASE_NAME"), std::string("bsoj"));
49 | strncpy(DATABASE_NAME, tmp.c_str(), 120);
50 |
51 | tmp = ini.Get(std::string("HTTP_BIND_IP"), std::string("0.0.0.0"));
52 | strncpy(HTTP_BIND_IP, tmp.c_str(), 30);
53 |
54 | HTTP_BIND_PORT = ini.Get("HTTP_BIND_PORT", 8881u);
55 |
56 | for(auto i = ini.sections.begin(); i != ini.sections.end(); ++i) {
57 | const string &lang = i->first;
58 | if(lang.find("lang") != 0)
59 | continue;
60 | int num = atoi(lang.c_str() + 4);
61 | if(!num || num > MAXLANG) {
62 | applog("Info: Language number is not correct.");
63 | return false;
64 | }
65 | num--;
66 | std::map &keys = *(i->second);
67 | if(keys.count(string("extra_mem")))
68 | lang_extra_mem[num] = Convert(keys[string("extra_mem")]);
69 | else
70 | lang_extra_mem[num] = 0;
71 |
72 | if(keys.count(string("compiler")))
73 | lang_compiler[num] = keys[string("compiler")];
74 | else
75 | return false;
76 |
77 | if(keys.count(string("ext")))
78 | lang_ext[num] = keys[string("ext")];
79 | else
80 | return false;
81 |
82 | lang_exist[num] = true;
83 | }
84 | /*
85 | for(int i = 0; i < MAXLANG; i++) {
86 | if(lang_exist[i]) {
87 | printf("extra_mem: %d\n", lang_extra_mem[i]);
88 | printf("lang_compiler: %s\n", lang_compiler[i].c_str());
89 | printf("ext: %s\n", lang_ext[i].c_str());
90 | }
91 | }
92 | */
93 | return true;
94 | }
--------------------------------------------------------------------------------
/daemon/runner_linux.c:
--------------------------------------------------------------------------------
1 | #include "sablebox.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | static struct scmask safe_syscall;
8 |
9 | static const int sc_safe[] = {
10 | #ifdef __x86_64__
11 | 0, 1, 3, 5, 8, 9, 10, 11, 12, 13, 16, 19, 20, 21, 25, 63, 89, 97, 100, 158, 201, 231
12 | #else
13 | 3, 4, 6, 108, 19, 90, 125, 91, 45, 174, 54, 145, 146, 33, 163, 122, 85, 76, 43, 13, 252, 140, 192, 197, 224, 243
14 | #endif
15 | //read, write, close, fstat, lseek, mmap, mprotect, munmap, brk, rt_sigaction, ioctl, readv, writev, access, mremap, uname, readlink, getrlimit, times, arch_prctl, time, exit_group, _llseek, mmap2, fstat64, gettid, set_thread_area
16 | };
17 |
18 | static void init_safe_syscall()
19 | {
20 | memset(&safe_syscall, 0, sizeof(struct scmask));
21 | int i, len = sizeof(sc_safe) / sizeof(int);
22 | for(i=0; i 7 && strcmp(argv[6], "-spj")==0) { // to run spj validator
52 | int cnt = argc - 7, i;
53 | args = (char**)malloc((cnt + 2) * sizeof(char*));
54 | args[0] = argv[1];
55 | for(i = 7; i>10, &safe_syscall);
69 | ret = sable_run(&sbox);
70 |
71 | switch(ret.status){
72 | case PROF_SUCCESS:
73 | state = 0;
74 | if(ret.exit_code != 0) {
75 | state = 5;
76 | ret.info = "Exit code is not zero";
77 | }
78 | break;
79 | case PROF_NOTSET:
80 | sys_error = 1;
81 | break;
82 | case PROF_RUNTIME_ERROR:
83 | state = 5;
84 | break;
85 | case PROF_TIME_LIMIT_EXCEED:
86 | state = 2;
87 | break;
88 | case PROF_MEMORY_LIMIT_EXCEED:
89 | state = 3;
90 | break;
91 | case PROF_SYSTEM_ERROR:
92 | sys_error = 1;
93 | break;
94 | default:
95 | sys_error = 1;
96 | break;
97 | }
98 | if(sys_error)
99 | return 2;
100 |
101 | if(isspj) {
102 | if(ret.info)
103 | printf("spj: %s\n", ret.info);
104 | return (state == 0) ? 0 : 10+state;//whether validator exited successfully
105 | }
106 | run_info = fopen("run.info", "w");
107 | if(!run_info)
108 | return 3;
109 |
110 | fprintf(run_info, "Time = %ld\n", ret.time);
111 | fprintf(run_info, "Memory = %ld\n", ret.memory);
112 | fprintf(run_info, "State = %d\n", state);
113 | if(ret.info)
114 | fprintf(run_info, "Info = %s\n", ret.info);
115 | fclose(run_info);
116 |
117 | return 0;
118 | }
119 |
--------------------------------------------------------------------------------
/daemon/test/README:
--------------------------------------------------------------------------------
1 | This directory was created by YangZX in Nov.24, 2012 to fix a bug in validator.c
2 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/1817_data/1817/a1.in:
--------------------------------------------------------------------------------
1 | 13
2 | 23
3 | 44
4 | 45
5 | 29
6 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/1817_data/1817/a1.out:
--------------------------------------------------------------------------------
1 | 7639
2 | 101821927
3 | 106465954658531465
4 | 289841389106439413
5 | 35866550869
6 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/1817_data/1817/a2.in:
--------------------------------------------------------------------------------
1 | 10
2 | 20
3 | 30
4 | 40
5 | 50
6 | 49
7 | 48
8 | 47
9 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/1817_data/1817/a2.out:
--------------------------------------------------------------------------------
1 | 507
2 | 5622109
3 | 95991365288
4 | 1954002050661819
5 | 4262465330
6 | 16033495247557039074
7 | 5873225808361331954
8 | 2152814945971655556
9 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/filelines_test/blank.txt:
--------------------------------------------------------------------------------
1 | 123
--------------------------------------------------------------------------------
/daemon/test/validator_test/filelines_test/filelines:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/test/validator_test/filelines_test/filelines
--------------------------------------------------------------------------------
/daemon/test/validator_test/filelines_test/filelines.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | long filelines(FILE* stream)
5 | {
6 | fseek(stream, 0, SEEK_SET);
7 | int c, tmp = 0, sum = 0, non_empty = 0;
8 | while(c = getc(stream)){
9 | if(c == EOF)
10 | break;
11 | if(c == '\n'){
12 | tmp++;
13 | }else{
14 | sum += tmp;
15 | tmp = 0;
16 | non_empty = 1;
17 | }
18 | }
19 | return sum + non_empty;
20 | }
21 |
22 | #define should(left, op, right) \
23 | if(!(left op right)){ \
24 | puts("Failed!!!" #left #op #right);\
25 | printf("%s = %d, %s = %d\n\n", #left, left, #right, right); \
26 | }else{\
27 | puts("Passed!!!" #left #op #right);\
28 | }
29 |
30 | void test_blank()
31 | {
32 | {
33 | system("echo \"\n\n\" > blank.txt");
34 | FILE* fp = fopen("blank.txt", "r");
35 | should(filelines(fp), ==, 0);
36 | }
37 |
38 | {
39 | system("echo \"\" > blank.txt");
40 | FILE* fp = fopen("blank.txt", "r");
41 | should(filelines(fp), ==, 0);
42 | }
43 | }
44 |
45 | void test_ordinary()
46 | {
47 | {
48 | system("echo \"123\" > blank.txt");
49 | FILE* fp = fopen("blank.txt", "r");
50 | should(filelines(fp), ==, 1);
51 | }
52 | {
53 | system("echo \"123\n123\n\n\n\" > blank.txt");
54 | FILE* fp = fopen("blank.txt", "r");
55 | should(filelines(fp), ==, 2);
56 | }
57 | {
58 | system("echo \"123\n\n123\" > blank.txt");
59 | FILE* fp = fopen("blank.txt", "r");
60 | should(filelines(fp), ==, 3);
61 | }
62 | {
63 | system("echo \"haha\" > blank.txt");
64 | FILE* fp = fopen("blank.txt", "r");
65 | should(filelines(fp), ==, 1);
66 | }
67 | }
68 |
69 | void test_invalid()
70 | {
71 | FILE* fp = fopen("blank.txt", "w");
72 | fprintf(fp, "123");
73 | fclose(fp);
74 | {
75 | FILE* fp = fopen("blank.txt", "r");
76 | should(filelines(fp), ==, 1);
77 | }
78 | }
79 |
80 | int main()
81 | {
82 | test_blank();
83 | test_ordinary();
84 | test_invalid();
85 | return 0;
86 | }
87 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/filelines_test/makefile:
--------------------------------------------------------------------------------
1 | test:filelines
2 | ./filelines
3 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/makefile:
--------------------------------------------------------------------------------
1 | test_validator: validator.c test_validator.c
2 | gcc validator.c test_validator.c -o test_validator
3 | test: test_validator
4 | ./test_validator
5 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/std1.txt:
--------------------------------------------------------------------------------
1 | 123
2 | 456
3 | 789
4 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/std2.txt:
--------------------------------------------------------------------------------
1 | 123
2 | 123
3 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/std_identical.txt:
--------------------------------------------------------------------------------
1 | 123455
--------------------------------------------------------------------------------
/daemon/test/validator_test/std_invalid.txt:
--------------------------------------------------------------------------------
1 | 123
2 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/std_multi.txt:
--------------------------------------------------------------------------------
1 | 507
2 | 5622109
3 | 95991365288
4 | 1954002050661819
5 | 4262465330
6 | 16033495247557039074
7 | 5873225808361331954
8 | 2152814945971655556
9 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/test_validator:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/test/validator_test/test_validator
--------------------------------------------------------------------------------
/daemon/test/validator_test/test_validator.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #define VAL_FUCKED (-1)
6 | #define VAL_IDENTICAL 0
7 | #define VAL_MISMATCH 1
8 | #define VAL_LONGER 2
9 | #define VAL_SHORTER 3
10 |
11 | struct validator_info validator(FILE* fstd, FILE* fuser);
12 |
13 | struct validator_info{
14 | int ret;
15 | char* user_mismatch;
16 | char* std_mismatch;
17 | };
18 |
19 | #define should(left, op, right) \
20 | if(!(left op right)){ \
21 | puts("Failed!!!" #left #op #right);\
22 | printf("%s = %d, %s = %d\n\n", #left, left, #right, right); \
23 | }else{\
24 | puts("Passed!!!" #left #op #right);\
25 | }
26 |
27 | void test_shorter()
28 | {
29 | /*user output is shorter than standart output.*/
30 | FILE* fu = fopen("user1.txt", "r");
31 | FILE* fs = fopen("std1.txt", "r");
32 | struct validator_info info = validator(fs, fu);
33 | should(info.ret, ==, VAL_SHORTER);
34 | }
35 |
36 | void test_longer()
37 | {
38 | /*user output is shorter than longer output.*/
39 | FILE* fu = fopen("user2.txt", "r");
40 | FILE* fs = fopen("std2.txt", "r");
41 | struct validator_info info = validator(fs, fu);
42 | should(info.ret, ==, VAL_LONGER);
43 | }
44 |
45 | void test_multi()
46 | {
47 | FILE* fu = fopen("user_multi.txt", "r");
48 | FILE* fs = fopen("std_multi.txt", "r");
49 | struct validator_info info = validator(fs, fu);
50 | should(info.ret, ==, VAL_SHORTER);
51 | }
52 |
53 | void test_indentical()
54 | {
55 | system("echo \"123456\n123\" > user_identical.txt");
56 | system("echo \"123456\n123\" > std_identical.txt");
57 | FILE* fu = fopen("user_identical.txt", "r");
58 | FILE* fs = fopen("std_identical.txt", "r");
59 | struct validator_info info = validator(fs, fu);
60 | should(info.ret, ==, VAL_IDENTICAL);
61 | }
62 |
63 | void test_invaliddata()
64 | {
65 | FILE* fu = fopen("user_invalid.txt", "w+");
66 | FILE* fs = fopen("std_invalid.txt", "w+");
67 | fprintf(fu, "123\n\n\n");
68 | fprintf(fs, "123\n");
69 | struct validator_info info = validator(fs, fu);
70 | should(info.ret, ==, VAL_IDENTICAL);
71 | }
72 |
73 | void test_singleline()
74 | {
75 | {
76 | FILE* fu = fopen("user_identical.txt", "w");
77 | fprintf(fu, "\n");
78 | fclose(fu);
79 |
80 | FILE* fs = fopen("std_identical.txt", "w");
81 | fprintf(fs, "123455");
82 | fclose(fs);
83 | }
84 | FILE* fu = fopen("user_identical.txt", "r");
85 | FILE* fs = fopen("std_identical.txt", "r");
86 | struct validator_info info = validator(fs, fu);
87 | should(info.ret, ==, VAL_SHORTER);
88 | }
89 |
90 | int main()
91 | {
92 | test_shorter();
93 | test_longer();
94 | test_multi();
95 | test_indentical();
96 | test_invaliddata();
97 | test_singleline();
98 | return 0;
99 | }
100 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/user.txt:
--------------------------------------------------------------------------------
1 | 123
2 |
3 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/user1.txt:
--------------------------------------------------------------------------------
1 | 123
2 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/user2.txt:
--------------------------------------------------------------------------------
1 | 123
2 | 123
3 | 123
4 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/user_identical.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/user_invalid.txt:
--------------------------------------------------------------------------------
1 | 123
2 |
3 |
4 |
--------------------------------------------------------------------------------
/daemon/test/validator_test/user_multi.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/test/validator_test/user_multi.txt
--------------------------------------------------------------------------------
/daemon/win32_ruc/win32_ruc/win32_ruc.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "win32_ruc", "win32_ruc.vcproj", "{FAF4AEE2-72DB-4010-BC68-2DED57619525}"
5 | EndProject
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "win32_run_compiler", "..\win32_run_compiler\win32_run_compiler.vcproj", "{549BB008-902C-4FF0-8191-E79D062F6476}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Win32 = Debug|Win32
11 | Release|Win32 = Release|Win32
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {FAF4AEE2-72DB-4010-BC68-2DED57619525}.Debug|Win32.ActiveCfg = Debug|Win32
15 | {FAF4AEE2-72DB-4010-BC68-2DED57619525}.Debug|Win32.Build.0 = Debug|Win32
16 | {FAF4AEE2-72DB-4010-BC68-2DED57619525}.Release|Win32.ActiveCfg = Release|Win32
17 | {FAF4AEE2-72DB-4010-BC68-2DED57619525}.Release|Win32.Build.0 = Release|Win32
18 | {549BB008-902C-4FF0-8191-E79D062F6476}.Debug|Win32.ActiveCfg = Debug|Win32
19 | {549BB008-902C-4FF0-8191-E79D062F6476}.Debug|Win32.Build.0 = Debug|Win32
20 | {549BB008-902C-4FF0-8191-E79D062F6476}.Release|Win32.ActiveCfg = Release|Win32
21 | {549BB008-902C-4FF0-8191-E79D062F6476}.Release|Win32.Build.0 = Release|Win32
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/daemon/win32_ruc/win32_ruc/win32_ruc.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/win32_ruc/win32_ruc/win32_ruc.suo
--------------------------------------------------------------------------------
/daemon/win32_ruc/win32_ruc/win32_ruc.vcproj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/win32_ruc/win32_ruc/win32_ruc.vcproj
--------------------------------------------------------------------------------
/daemon/win32_ruc/win32_ruc/win32_ruc.vcproj.MICROSOF-E7F3D7.Administrator.user:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
35 |
36 |
39 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/daemon/win32_ruc/win32_run_compiler/main.cpp:
--------------------------------------------------------------------------------
1 | #define _WIN32_WINNT 0x0500
2 | #include
3 | #include
4 | #include
5 | #pragma comment(lib,"Psapi.lib")
6 |
7 | #define compiler_max_time 20000
8 | //#define compiler_max_memory 1024*1024*1024 //1GB
9 | HANDLE hJOB;
10 | HANDLE create_child_process(const char *cmd)
11 | {
12 | PROCESS_INFORMATION pi = {0};
13 | STARTUPINFO si = {sizeof(si)};
14 |
15 | hJOB = CreateJobObject(NULL, NULL);
16 | if(!hJOB) {
17 | return NULL;
18 | }
19 |
20 | /*JOBOBJECT_SECURITY_LIMIT_INFORMATION security_info = {0};
21 | security_info.SecurityLimitFlags = JOB_OBJECT_SECURITY_NO_ADMIN;
22 | if(!SetInformationJobObject(hJOB, JobObjectSecurityLimitInformation, &security_info, sizeof security_info)) {
23 | CloseHandle(hJOB);
24 | return NULL;
25 | }*/
26 | freopen("err.out", "w", stderr);
27 | freopen("cmpr.out", "w", stdout);
28 |
29 | BOOL bSuccess = CreateProcess(NULL, (LPSTR)(void*)cmd, NULL, NULL, TRUE, CREATE_SUSPENDED | CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
30 | if(!bSuccess) {
31 | CloseHandle(hJOB);
32 | return NULL;
33 | }
34 | if(!AssignProcessToJobObject(hJOB, pi.hProcess)) {
35 | CloseHandle(hJOB);
36 | CloseHandle(pi.hThread);
37 | TerminateProcess(pi.hProcess, 0);
38 | CloseHandle(pi.hProcess);
39 | return NULL;
40 | }
41 | if(-1 == ResumeThread(pi.hThread)) {
42 | CloseHandle(hJOB);
43 | CloseHandle(pi.hThread);
44 | TerminateProcess(pi.hProcess, 0);
45 | CloseHandle(pi.hProcess);
46 | return NULL;
47 | }
48 | CloseHandle(pi.hThread);
49 | return pi.hProcess;
50 | }
51 | int run_compiler(const char *cmd, int *exit_code)
52 | {
53 | HANDLE hChild = create_child_process(cmd);
54 | if(!hChild) {
55 | return 1;
56 | }
57 | *exit_code = 0;
58 | if(WAIT_TIMEOUT == WaitForSingleObject(hChild, compiler_max_time + 200)) {
59 | *exit_code = 2;
60 | TerminateJobObject(hJOB, 1);
61 | //WaitForSingleObject(hChild, INFINITE);
62 | }
63 | if(! *exit_code)
64 | GetExitCodeProcess(hChild, (LPDWORD)exit_code);
65 |
66 | CloseHandle(hChild);
67 | CloseHandle(hJOB);
68 |
69 | return 0;
70 | }
71 |
72 | int main(int argc, char **argv)
73 | {
74 | if(argc < 2) {
75 | puts("usage: win32_run_compiler cmd");
76 | return 1;
77 | }
78 | int exit_code;
79 | int ret = run_compiler(argv[1], &exit_code);
80 | if(ret)
81 | return ret;
82 | if(exit_code == 0)
83 | fprintf(stderr, "@~good~@\n");
84 | fclose(stderr);
85 | return 0;
86 | }
87 |
--------------------------------------------------------------------------------
/daemon/win32_ruc/win32_run_compiler/win32_run_compiler.vcproj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/win32_ruc/win32_run_compiler/win32_run_compiler.vcproj
--------------------------------------------------------------------------------
/daemon/win32_ruc/win32_run_compiler/win32_run_compiler.vcproj.MICROSOF-E7F3D7.Administrator.user:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
35 |
36 |
39 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/daemon/windows_binary/config.ini:
--------------------------------------------------------------------------------
1 | [system]
2 | datadir=d:/data
3 | DATABASE_USER=root
4 | DATABASE_PASS=
5 |
6 | [lang1]
7 | ext=cpp
8 | extra_mem=0
9 | compiler=g++ -fno-asm -s -w -O -DONLINE_JUDGE -o target.exe
10 |
11 | [lang2]
12 | ext=c
13 | extra_mem=0
14 | compiler=gcc -fno-asm -s -w -O -DONLINE_JUDGE -O -o target.exe
15 |
16 | [lang3]
17 | ext=pas
18 | extra_mem=0
19 | compiler=fpc -Xs -Sgic -dONLINE_JUDGE -otarget.exe
20 |
21 | [lang4]
22 | ext=cpp
23 | extra_mem=0
24 | compiler=g++ --std=gnu++0x -O -DONLINE_JUDGE -o target.exe
25 |
--------------------------------------------------------------------------------
/daemon/windows_binary/daemon.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/daemon.exe
--------------------------------------------------------------------------------
/daemon/windows_binary/libgcrypt-11.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/libgcrypt-11.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/libgmp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/libgmp.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/libgnutls-28.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/libgnutls-28.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/libgpg-error-0.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/libgpg-error-0.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/libiconv-2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/libiconv-2.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/libintl-8.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/libintl-8.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/libmicrohttpd-10.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/libmicrohttpd-10.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/libmysql.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/libmysql.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/libplibc-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/libplibc-1.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/pthreadGC2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/pthreadGC2.dll
--------------------------------------------------------------------------------
/daemon/windows_binary/win32_ruc.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/win32_ruc.exe
--------------------------------------------------------------------------------
/daemon/windows_binary/win32_run_compiler.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/win32_run_compiler.exe
--------------------------------------------------------------------------------
/daemon/windows_binary/zlib1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/daemon/windows_binary/zlib1.dll
--------------------------------------------------------------------------------
/doc/database_convert.txt:
--------------------------------------------------------------------------------
1 | 数据库先对blob解码(password,source),再将编码转为utf-8
2 | 清空loginlog
3 | 清除solution中的waiting(10000)
4 | 更新users中的solved和submit
5 | PE,OE全部转为WA; 1,6 -> 4
6 | SE转为RE; 98 -> 5
7 | 一些表的列功能发生变化
--------------------------------------------------------------------------------
/doc/diagram_daemon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/doc/diagram_daemon.png
--------------------------------------------------------------------------------
/doc/init_score.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os,sys;
3 | import MySQLdb as mdb;
4 |
5 | data_dir='/root/data/';
6 | database_pass='';
7 | max_prob=3542;
8 |
9 | def count_in(dir):
10 | num=0;
11 | files=os.listdir(dir);
12 | for line in files:
13 | line=os.path.join(dir,line);
14 | if os.path.isfile(line):
15 | if line.endswith('.in'):
16 | num=num+1;
17 | # print dir,num
18 | return num;
19 |
20 | con=mdb.connect('localhost','root',database_pass,'bsoj');
21 |
22 | def update(p,s):
23 | global con;
24 | print p,s;
25 | con.cursor().execute("update problem set case_score="+str(s)+" where problem_id="+str(p));
26 |
27 | for i in range(1000,max_prob-1):
28 | n=count_in(data_dir+str(i));
29 | if n==0:
30 | continue;
31 | elif n<40:
32 | update(i,100/n);
33 | else:
34 | update(i,200/n);
35 |
--------------------------------------------------------------------------------
/doc/nginx.conf:
--------------------------------------------------------------------------------
1 | #reference configuration for nginx
2 |
3 | user ojwww ojwww;
4 | #should be existing user and group
5 |
6 | worker_processes 4;
7 |
8 | error_log logs/error.log;
9 | #error_log logs/error.log notice;
10 | #error_log logs/error.log info;
11 |
12 | pid logs/nginx.pid;
13 |
14 | events {
15 | worker_connections 1024;
16 | }
17 |
18 |
19 | http {
20 | include mime.types;
21 | default_type application/octet-stream;
22 |
23 | log_format main '$remote_addr - $remote_user [$time_local] "$request" '
24 | '$status $body_bytes_sent "$http_referer" '
25 | '"$http_user_agent" "$http_x_forwarded_for"';
26 |
27 | #access_log logs/access.log main;
28 | access_log off;
29 |
30 | sendfile on;
31 | #tcp_nopush on;
32 |
33 | #keepalive_timeout 0;
34 | keepalive_timeout 10;
35 |
36 | gzip on;
37 | gzip_min_length 2000;
38 | gzip_buffers 4 8k;
39 | gzip_types text/plain application/x-javascript text/css application/xml;
40 |
41 | server {
42 | listen 8080;
43 | server_name _;
44 |
45 | root /var/nginx/html;
46 | #should be changed to your real path
47 |
48 | index index.html index.htm index.php;
49 |
50 | #pass to OJ daemon
51 | location ^~ /query/ {
52 | proxy_pass http://127.0.0.1:8888/;
53 | }
54 | location ^~ /assets/ {
55 | expires 10d;
56 | }
57 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
58 | location ~ \.php$ {
59 | fastcgi_pass 127.0.0.1:9000;
60 | fastcgi_index index.php;
61 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
62 | include fastcgi_params;
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/doc/spj_example.c:
--------------------------------------------------------------------------------
1 | //Linux平台下保存为spj.cpp放到题目的数据目录下
2 | //Windows平台编译为spj.exe放到题目的数据目录下
3 | #include
4 |
5 | FILE *fscore,*freport,*fstd,*fin,*fout;
6 | int score;
7 | int main(int argc,char *argv[])
8 | {
9 | fscore=fopen("score.log","w");//打开得分文件,写入一个数字表示测试点得分
10 | freport=fopen("report.log","w");//打开报告文件,用于反馈信息给选手
11 | fstd=fopen(argv[2],"r");//打开测试点标准输出文件
12 | score=atoi(argv[1]);//取得测试点的满分
13 |
14 | fin=fopen("user.in","r");//测试数据的输入
15 | fout=fopen("user.out","r");//选手的输出
16 |
17 | //评测
18 |
19 | if (/*完全正确*/)
20 | {
21 | fprintf(fscore,"%d",score);//返回满分
22 | fprintf(freport,"right");//报告用户结果,内容任意
23 | }
24 | else if (/*部分正确*/)
25 | {
26 | fprintf(fscore,"%d",/*部分分*/);
27 | fprintf(freport,/*输出错误信息*/);
28 | }
29 | else
30 | {
31 | fprintf(fscore,"%d",0);//返回0分
32 | fprintf(freport,"wrong");//报告用户结果,内容任意
33 | }
34 |
35 | fclose(fscore);//关闭得分文件
36 | fclose(freport);//关闭报告文件
37 | return 0;
38 | }
39 |
--------------------------------------------------------------------------------
/test_mutex.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require 'net/http'
4 |
5 | USER = 'NOI'
6 | PASSWD = 'NOINOI'
7 | HOST = 'oj.bashu.com.cn'
8 |
9 | def die message, code = 1
10 | puts message.to_s
11 | exit code
12 | end
13 |
14 | puts "User : #{USER}"
15 | puts 'Login ...Wait...'
16 |
17 | conn = Net::HTTP.new HOST
18 | post_data = URI.encode_www_form('uid' => USER, 'pwd' => PASSWD, 'url' => 'index.php')
19 | resp = conn.post '/code/login.php', post_data, {}
20 | die "Can't connect to OJ, check your network. HTTP Code - " + resp.code if resp.code != '302' && resp.code != '200'
21 | die 'Invalid username or password. ' if resp.body.size != 0
22 |
23 | cookie = resp.response['set-cookie']
24 |
25 | (1..1000).each do |i|
26 | post_data = URI.encode_www_form 'message' => "testing...", 'detail' => "mutex is evil"
27 | conn.post '/code/postmessage.php', post_data, {'Cookie' => cookie}
28 | puts i
29 | end
30 |
--------------------------------------------------------------------------------
/web/assets/Mathjax/README.md:
--------------------------------------------------------------------------------
1 | **Please extract Mathjax files here**
2 |
--------------------------------------------------------------------------------
/web/assets/css/ex.css:
--------------------------------------------------------------------------------
1 | .btn-grey{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#662299;*background-color:#662299;background-image:-moz-linear-gradient(top,#662299,#662299);background-image:-webkit-gradient(linear,0 0,0 100%,from(#662299),to(#662299));background-image:-webkit-linear-gradient(top,#662299,#662299);background-image:-o-linear-gradient(top,#662299,#662299);background-image:linear-gradient(to bottom,#662299,#662299);background-repeat:repeat-x;border-color:#662299 #662299 #913800;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff662299',endColorstr='#ff662299',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-grey:hover,.btn-grey:focus,.btn-grey:active,.btn-grey.active,.btn-grey.disabled,.btn-grey[disabled]{color:#fff;background-color:#662299;*background-color:#c44c00}.btn-grey:active,.btn-grey.active{background-color:#aa4200 \9}
2 | .btn-emmm{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#2f4f6f;*background-color:#2f4f6f;background-image:-moz-linear-gradient(top,#2f4f6f,#2f4f6f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#2f4f6f),to(#2f4f6f));background-image:-webkit-linear-gradient(top,#2f4f6f,#2f4f6f);background-image:-o-linear-gradient(top,#2f4f6f,#2f4f6f);background-image:linear-gradient(to bottom,#2f4f6f,#2f4f6f);background-repeat:repeat-x;border-color:#2f4f6f #2f4f6f #913800;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff2f4f6f',endColorstr='#ff2f4f6f',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-emmm:hover,.btn-emmm:focus,.btn-emmm:active,.btn-emmm.active,.btn-emmm.disabled,.btn-emmm[disabled]{color:#fff;background-color:#2f4f6f;*background-color:#c44c00}.btn-emmm:active,.btn-emmm.active{background-color:#aa4200 \9}
3 | .btn-item{
4 | display:block;
5 | padding-top: 0.928571em;
6 | padding-right: 1.14286em;
7 | padding-bottom: 0.928571em;
8 | padding-left: 1.14286em;
9 | }
10 | .active{
11 | color:#2f2f2f;
12 | }
--------------------------------------------------------------------------------
/web/assets/css/images/animated-overlay.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/animated-overlay.gif
--------------------------------------------------------------------------------
/web/assets/css/images/ui-bg_flat_0_aaaaaa_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-bg_flat_0_aaaaaa_40x100.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-bg_flat_75_ffffff_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-bg_flat_75_ffffff_40x100.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-bg_glass_55_fbf9ee_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-bg_glass_55_fbf9ee_1x400.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-bg_glass_65_ffffff_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-bg_glass_65_ffffff_1x400.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-bg_glass_75_dadada_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-bg_glass_75_dadada_1x400.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-bg_glass_75_e6e6e6_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-bg_glass_75_e6e6e6_1x400.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-bg_glass_95_fef1ec_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-bg_glass_95_fef1ec_1x400.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-icons_222222_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-icons_222222_256x240.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-icons_2e83ff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-icons_2e83ff_256x240.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-icons_454545_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-icons_454545_256x240.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-icons_888888_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-icons_888888_256x240.png
--------------------------------------------------------------------------------
/web/assets/css/images/ui-icons_cd0a0a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/css/images/ui-icons_cd0a0a_256x240.png
--------------------------------------------------------------------------------
/web/assets/fonts/Font-Awesome/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/fonts/Font-Awesome/FontAwesome.otf
--------------------------------------------------------------------------------
/web/assets/fonts/Font-Awesome/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/fonts/Font-Awesome/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/web/assets/fonts/Font-Awesome/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/fonts/Font-Awesome/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/web/assets/fonts/Font-Awesome/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/fonts/Font-Awesome/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/web/assets/fonts/euler.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/fonts/euler.otf
--------------------------------------------------------------------------------
/web/assets/fonts/telex.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/fonts/telex.woff
--------------------------------------------------------------------------------
/web/assets/ico/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/ico/favicon.ico
--------------------------------------------------------------------------------
/web/assets/img/glyphicons-halflings-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/img/glyphicons-halflings-white.png
--------------------------------------------------------------------------------
/web/assets/img/glyphicons-halflings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/img/glyphicons-halflings.png
--------------------------------------------------------------------------------
/web/assets/img/loading.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/img/loading.gif
--------------------------------------------------------------------------------
/web/assets/img/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/img/logo.jpg
--------------------------------------------------------------------------------
/web/assets/img/ok-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/img/ok-icon.png
--------------------------------------------------------------------------------
/web/assets/img/plupload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/img/plupload.png
--------------------------------------------------------------------------------
/web/assets/img/rotate.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/img/rotate.gif
--------------------------------------------------------------------------------
/web/assets/img/wrong-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/z4yx/bashu-onlinejudge/3a5301f6a3508640eba6a4e7575a41b90a968b8f/web/assets/img/wrong-icon.png
--------------------------------------------------------------------------------
/web/assets/js/bootstrap-affix.js:
--------------------------------------------------------------------------------
1 | /* ==========================================================
2 | * bootstrap-affix.js v2.3.1
3 | * http://twitter.github.com/bootstrap/javascript.html#affix
4 | * ==========================================================
5 | * Copyright 2012 Twitter, Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * ========================================================== */
19 |
20 |
21 | !function ($) {
22 |
23 | "use strict"; // jshint ;_;
24 |
25 |
26 | /* AFFIX CLASS DEFINITION
27 | * ====================== */
28 |
29 | var Affix = function (element, options) {
30 | this.options = $.extend({}, $.fn.affix.defaults, options)
31 | this.$window = $(window)
32 | .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
33 | .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
34 | this.$element = $(element)
35 | this.checkPosition()
36 | }
37 |
38 | Affix.prototype.checkPosition = function () {
39 | if (!this.$element.is(':visible')) return
40 |
41 | var scrollHeight = $(document).height()
42 | , scrollTop = this.$window.scrollTop()
43 | , position = this.$element.offset()
44 | , offset = this.options.offset
45 | , offsetBottom = offset.bottom
46 | , offsetTop = offset.top
47 | , reset = 'affix affix-top affix-bottom'
48 | , affix
49 |
50 | if (typeof offset != 'object') offsetBottom = offsetTop = offset
51 | if (typeof offsetTop == 'function') offsetTop = offset.top()
52 | if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
53 |
54 | affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
55 | false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
56 | 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
57 | 'top' : false
58 |
59 | if (this.affixed === affix) return
60 |
61 | this.affixed = affix
62 | this.unpin = affix == 'bottom' ? position.top - scrollTop : null
63 |
64 | this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
65 | }
66 |
67 |
68 | /* AFFIX PLUGIN DEFINITION
69 | * ======================= */
70 |
71 | var old = $.fn.affix
72 |
73 | $.fn.affix = function (option) {
74 | return this.each(function () {
75 | var $this = $(this)
76 | , data = $this.data('affix')
77 | , options = typeof option == 'object' && option
78 | if (!data) $this.data('affix', (data = new Affix(this, options)))
79 | if (typeof option == 'string') data[option]()
80 | })
81 | }
82 |
83 | $.fn.affix.Constructor = Affix
84 |
85 | $.fn.affix.defaults = {
86 | offset: 0
87 | }
88 |
89 |
90 | /* AFFIX NO CONFLICT
91 | * ================= */
92 |
93 | $.fn.affix.noConflict = function () {
94 | $.fn.affix = old
95 | return this
96 | }
97 |
98 |
99 | /* AFFIX DATA-API
100 | * ============== */
101 |
102 | $(window).on('load', function () {
103 | $('[data-spy="affix"]').each(function () {
104 | var $spy = $(this)
105 | , data = $spy.data()
106 |
107 | data.offset = data.offset || {}
108 |
109 | data.offsetBottom && (data.offset.bottom = data.offsetBottom)
110 | data.offsetTop && (data.offset.top = data.offsetTop)
111 |
112 | $spy.affix(data)
113 | })
114 | })
115 |
116 |
117 | }(window.jQuery);
--------------------------------------------------------------------------------
/web/assets/js/bootstrap-alert.js:
--------------------------------------------------------------------------------
1 | /* ==========================================================
2 | * bootstrap-alert.js v2.3.1
3 | * http://twitter.github.com/bootstrap/javascript.html#alerts
4 | * ==========================================================
5 | * Copyright 2012 Twitter, Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * ========================================================== */
19 |
20 |
21 | !function ($) {
22 |
23 | "use strict"; // jshint ;_;
24 |
25 |
26 | /* ALERT CLASS DEFINITION
27 | * ====================== */
28 |
29 | var dismiss = '[data-dismiss="alert"]'
30 | , Alert = function (el) {
31 | $(el).on('click', dismiss, this.close)
32 | }
33 |
34 | Alert.prototype.close = function (e) {
35 | var $this = $(this)
36 | , selector = $this.attr('data-target')
37 | , $parent
38 |
39 | if (!selector) {
40 | selector = $this.attr('href')
41 | selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
42 | }
43 |
44 | $parent = $(selector)
45 |
46 | e && e.preventDefault()
47 |
48 | $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
49 |
50 | $parent.trigger(e = $.Event('close'))
51 |
52 | if (e.isDefaultPrevented()) return
53 |
54 | $parent.removeClass('in')
55 |
56 | function removeElement() {
57 | $parent
58 | .trigger('closed')
59 | .remove()
60 | }
61 |
62 | $.support.transition && $parent.hasClass('fade') ?
63 | $parent.on($.support.transition.end, removeElement) :
64 | removeElement()
65 | }
66 |
67 |
68 | /* ALERT PLUGIN DEFINITION
69 | * ======================= */
70 |
71 | var old = $.fn.alert
72 |
73 | $.fn.alert = function (option) {
74 | return this.each(function () {
75 | var $this = $(this)
76 | , data = $this.data('alert')
77 | if (!data) $this.data('alert', (data = new Alert(this)))
78 | if (typeof option == 'string') data[option].call($this)
79 | })
80 | }
81 |
82 | $.fn.alert.Constructor = Alert
83 |
84 |
85 | /* ALERT NO CONFLICT
86 | * ================= */
87 |
88 | $.fn.alert.noConflict = function () {
89 | $.fn.alert = old
90 | return this
91 | }
92 |
93 |
94 | /* ALERT DATA-API
95 | * ============== */
96 |
97 | $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
98 |
99 | }(window.jQuery);
--------------------------------------------------------------------------------
/web/assets/js/bootstrap-button.js:
--------------------------------------------------------------------------------
1 | /* ============================================================
2 | * bootstrap-button.js v2.3.1
3 | * http://twitter.github.com/bootstrap/javascript.html#buttons
4 | * ============================================================
5 | * Copyright 2012 Twitter, Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * ============================================================ */
19 |
20 |
21 | !function ($) {
22 |
23 | "use strict"; // jshint ;_;
24 |
25 |
26 | /* BUTTON PUBLIC CLASS DEFINITION
27 | * ============================== */
28 |
29 | var Button = function (element, options) {
30 | this.$element = $(element)
31 | this.options = $.extend({}, $.fn.button.defaults, options)
32 | }
33 |
34 | Button.prototype.setState = function (state) {
35 | var d = 'disabled'
36 | , $el = this.$element
37 | , data = $el.data()
38 | , val = $el.is('input') ? 'val' : 'html'
39 |
40 | state = state + 'Text'
41 | data.resetText || $el.data('resetText', $el[val]())
42 |
43 | $el[val](data[state] || this.options[state])
44 |
45 | // push to event loop to allow forms to submit
46 | setTimeout(function () {
47 | state == 'loadingText' ?
48 | $el.addClass(d).attr(d, d) :
49 | $el.removeClass(d).removeAttr(d)
50 | }, 0)
51 | }
52 |
53 | Button.prototype.toggle = function () {
54 | var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
55 |
56 | $parent && $parent
57 | .find('.active')
58 | .removeClass('active')
59 |
60 | this.$element.toggleClass('active')
61 | }
62 |
63 |
64 | /* BUTTON PLUGIN DEFINITION
65 | * ======================== */
66 |
67 | var old = $.fn.button
68 |
69 | $.fn.button = function (option) {
70 | return this.each(function () {
71 | var $this = $(this)
72 | , data = $this.data('button')
73 | , options = typeof option == 'object' && option
74 | if (!data) $this.data('button', (data = new Button(this, options)))
75 | if (option == 'toggle') data.toggle()
76 | else if (option) data.setState(option)
77 | })
78 | }
79 |
80 | $.fn.button.defaults = {
81 | loadingText: 'loading...'
82 | }
83 |
84 | $.fn.button.Constructor = Button
85 |
86 |
87 | /* BUTTON NO CONFLICT
88 | * ================== */
89 |
90 | $.fn.button.noConflict = function () {
91 | $.fn.button = old
92 | return this
93 | }
94 |
95 |
96 | /* BUTTON DATA-API
97 | * =============== */
98 |
99 | $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
100 | var $btn = $(e.target)
101 | if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
102 | $btn.button('toggle')
103 | })
104 |
105 | }(window.jQuery);
--------------------------------------------------------------------------------
/web/assets/js/bootstrap-popover.js:
--------------------------------------------------------------------------------
1 | /* ===========================================================
2 | * bootstrap-popover.js v2.3.1
3 | * http://twitter.github.com/bootstrap/javascript.html#popovers
4 | * ===========================================================
5 | * Copyright 2012 Twitter, Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * =========================================================== */
19 |
20 |
21 | !function ($) {
22 |
23 | "use strict"; // jshint ;_;
24 |
25 |
26 | /* POPOVER PUBLIC CLASS DEFINITION
27 | * =============================== */
28 |
29 | var Popover = function (element, options) {
30 | this.init('popover', element, options)
31 | }
32 |
33 |
34 | /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
35 | ========================================== */
36 |
37 | Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
38 |
39 | constructor: Popover
40 |
41 | , setContent: function () {
42 | var $tip = this.tip()
43 | , title = this.getTitle()
44 | , content = this.getContent()
45 |
46 | $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
47 | $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
48 |
49 | $tip.removeClass('fade top bottom left right in')
50 | }
51 |
52 | , hasContent: function () {
53 | return this.getTitle() || this.getContent()
54 | }
55 |
56 | , getContent: function () {
57 | var content
58 | , $e = this.$element
59 | , o = this.options
60 |
61 | content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
62 | || $e.attr('data-content')
63 |
64 | return content
65 | }
66 |
67 | , tip: function () {
68 | if (!this.$tip) {
69 | this.$tip = $(this.options.template)
70 | }
71 | return this.$tip
72 | }
73 |
74 | , destroy: function () {
75 | this.hide().$element.off('.' + this.type).removeData(this.type)
76 | }
77 |
78 | })
79 |
80 |
81 | /* POPOVER PLUGIN DEFINITION
82 | * ======================= */
83 |
84 | var old = $.fn.popover
85 |
86 | $.fn.popover = function (option) {
87 | return this.each(function () {
88 | var $this = $(this)
89 | , data = $this.data('popover')
90 | , options = typeof option == 'object' && option
91 | if (!data) $this.data('popover', (data = new Popover(this, options)))
92 | if (typeof option == 'string') data[option]()
93 | })
94 | }
95 |
96 | $.fn.popover.Constructor = Popover
97 |
98 | $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
99 | placement: 'right'
100 | , trigger: 'click'
101 | , content: ''
102 | , template: ''
103 | })
104 |
105 |
106 | /* POPOVER NO CONFLICT
107 | * =================== */
108 |
109 | $.fn.popover.noConflict = function () {
110 | $.fn.popover = old
111 | return this
112 | }
113 |
114 | }(window.jQuery);
115 |
--------------------------------------------------------------------------------
/web/assets/js/bootstrap-transition.js:
--------------------------------------------------------------------------------
1 | /* ===================================================
2 | * bootstrap-transition.js v2.3.1
3 | * http://twitter.github.com/bootstrap/javascript.html#transitions
4 | * ===================================================
5 | * Copyright 2012 Twitter, Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | * ========================================================== */
19 |
20 |
21 | !function ($) {
22 |
23 | "use strict"; // jshint ;_;
24 |
25 |
26 | /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
27 | * ======================================================= */
28 |
29 | $(function () {
30 |
31 | $.support.transition = (function () {
32 |
33 | var transitionEnd = (function () {
34 |
35 | var el = document.createElement('bootstrap')
36 | , transEndEventNames = {
37 | 'WebkitTransition' : 'webkitTransitionEnd'
38 | , 'MozTransition' : 'transitionend'
39 | , 'OTransition' : 'oTransitionEnd otransitionend'
40 | , 'transition' : 'transitionend'
41 | }
42 | , name
43 |
44 | for (name in transEndEventNames){
45 | if (el.style[name] !== undefined) {
46 | return transEndEventNames[name]
47 | }
48 | }
49 |
50 | }())
51 |
52 | return transitionEnd && {
53 | end: transitionEnd
54 | }
55 |
56 | })()
57 |
58 | })
59 |
60 | }(window.jQuery);
--------------------------------------------------------------------------------
/web/assets/js/chat.js:
--------------------------------------------------------------------------------
1 | var socket;
2 | function ws_connect(){
3 | socket = new WebSocket(ws_url);
4 |
5 | socket.onopen = function(){
6 | $('#info_socket').html('Connected');
7 | $('#chat_content').removeAttr('disabled').css('background-color','#fff');;
8 | $('#ipt_message').removeAttr('disabled');
9 | $('#btn_send').removeAttr('disabled');
10 | $('#btn_switch').removeAttr('disabled').html('Leave');
11 |
12 | socket.send(userid);
13 | };
14 | socket.onmessage = function(msgobj){
15 | var ele = $('#chat_content').append(htmlEncode(msgobj.data.replace(/\n/g, '')) + "\n").get(0);
16 | ele.scrollTop = ele.scrollHeight;
17 | };
18 | socket.onclose = function(){
19 | $('#info_socket').html('Disconnected');
20 | $('#chat_content').prop('disabled','disabled').css('background-color','#eee');
21 | $('#ipt_message').prop('disabled','disabled');
22 | $('#btn_send').prop('disabled','disabled');
23 | $('#btn_switch').removeAttr('disabled').html('Enter');
24 | };
25 | }
26 | $(document).ready(function(){
27 | $('#btn_switch').click(function(){
28 | if(typeof(ws_url)==='undefined')
29 | return false;
30 | if(!("WebSocket" in window)){
31 | alert('Sorry, you need a browser that supports HTML5 WebSockets.');
32 | return false;
33 | }
34 | if(typeof(userid)==='undefined'){
35 | alert("You have to log in before you can enter chat room.");
36 | return false;
37 | }
38 | var cmd = $(this).prop('disabled','disabled').html();
39 | if(cmd == 'Enter')
40 | ws_connect();
41 | else
42 | socket.close();
43 | });
44 | $('#btn_send').click(function(){
45 | var ele=$('#ipt_message');
46 | if(! $.trim(ele.val()))
47 | return false;
48 | socket.send(ele.val());
49 | ele.val('');
50 | });
51 | $('#ipt_message').keypress(function(E){
52 | if(E.keyCode == '13'){
53 | $('#btn_send').click();
54 | return false;
55 | }
56 | });
57 | });
--------------------------------------------------------------------------------
/web/assets/js/google-code-prettify/prettify.css:
--------------------------------------------------------------------------------
1 | .com { color: #93a1a1; }
2 | .lit { color: #195f91; }
3 | .pun, .opn, .clo { color: #93a1a1; }
4 | .fun { color: #dc322f; }
5 | .str, .atv { color: #D14; }
6 | .kwd, .prettyprint .tag { color: #1e347b; }
7 | .typ, .atn, .dec, .var { color: teal; }
8 | .pln { color: #48484c; }
9 |
10 | .prettyprint {
11 | padding: 8px;
12 | background-color: #f7f7f9;
13 | border: 1px solid #e1e1e8;
14 | }
15 | .prettyprint.linenums {
16 | -webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
17 | -moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
18 | box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
19 | }
20 |
21 | /* Specify class=linenums on a pre to get line numbering */
22 | ol.linenums {
23 | margin: 0 0 0 33px; /* IE indents via margin-left */
24 | }
25 | ol.linenums li {
26 | padding-left: 12px;
27 | color: #bebec5;
28 | line-height: 20px;
29 | text-shadow: 0 1px 0 #fff;
30 | }
--------------------------------------------------------------------------------
/web/assets/js/html5.js:
--------------------------------------------------------------------------------
1 | /*
2 | HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
3 | */
4 | (function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
5 | a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x";
6 | c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
7 | "undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",version:"3.6.2pre",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment();
8 | for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;dYou are not administrator.');
6 |
7 | require('inc/database.php');
8 | if(isset($_POST['paswd'])){
9 |
10 | require_once('inc/checkpwd.php');
11 | if(password_right($_SESSION['user'], $_POST['paswd'])){
12 | $_SESSION['admin_tfa']=1;
13 | if(isset($_SESSION['admin_retpage']))
14 | $ret = $_SESSION['admin_retpage'];
15 | else
16 | $ret = "index.php";
17 | header("Location: $ret");
18 | exit(0);
19 | }
20 | }
21 |
22 | $Title="Admin Verification";
23 | ?>
24 |
25 |
26 |
27 |
28 |
29 |
30 |
47 |
48 |
49 |
50 |
51 |
52 |
59 |
60 |
--------------------------------------------------------------------------------
/web/code/ajax_deleteprob.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/web/code/ajax_mailfunc.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/web/code/ajax_opensource.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/web/code/ajax_preferences.php:
--------------------------------------------------------------------------------
1 | $name=$tmp;
19 | mysql_query("insert into preferences(user_id,property,value) values ('$user','$name','$tmp') ON DUPLICATE KEY UPDATE value='$tmp'");
20 |
21 | }
22 |
23 | processOption('hidelogo');
24 | processOption('sharecode');
25 | processOption('hidehotkey');
26 |
27 | $_SESSION['pref']=serialize($pref);
28 |
29 |
30 |
--------------------------------------------------------------------------------
/web/code/ajax_profile.php:
--------------------------------------------------------------------------------
1 | 190)
5 | die('Nick is too long!');
6 | if(strlen($_POST['school'])>60)
7 | die('School name is too long!');
8 | if(strlen($_POST['email'])>60)
9 | die('E-mail is too long!');
10 | if($_POST['type']=='profile'){
11 | if(!isset($_POST['oldpwd']))
12 | die('Invalid argument.');
13 | session_start();
14 | if(!isset($_SESSION['user']))
15 | die('Not logged in.');
16 | $user=$_SESSION['user'];
17 | require('inc/database.php');
18 | require_once('inc/checkpwd.php');
19 | if(!password_right($user, $_POST['oldpwd']))
20 | die('Old password is not correct!');
21 |
22 | $query='update users set email=\''.mysql_real_escape_string($_POST['email']).'\',school=\''.mysql_real_escape_string($_POST['school']).'\',nick=\''.mysql_real_escape_string($_POST['nick']).'\'';
23 | if(isset($_POST['newpwd']) && $_POST['newpwd']!=''){
24 | $len=strlen($_POST['newpwd']);
25 | if($len<6||$len>20)
26 | die('Password is too long or too short!');
27 | $query.=',password=\''.mysql_real_escape_string(my_rsa($_POST['newpwd'])).'\'';
28 | }
29 | $query.=" where user_id='$user'";
30 | mysql_query($query);
31 | echo "User infomation updated successfully!";
32 | }else if($_POST['type']=='reg'){
33 | if(!isset($_POST['userid'],$_POST['newpwd']))
34 | die('Invalid argument.');
35 | require('inc/database.php');
36 | $user=mysql_real_escape_string(trim($_POST['userid']));
37 | $len=strlen($user);
38 | if($len==0)
39 | die('User name cannot be empty.');
40 | if($len>20)
41 | die('User name is too long.');
42 | if(preg_match('/\W/',$user))
43 | die('User name can only contain number,letter and "_".');
44 |
45 | $len=strlen($_POST['newpwd']);
46 | if($len<6||$len>20)
47 | die('Password is too long or too short!');
48 | $pwd=mysql_real_escape_string($_POST['newpwd']);
49 |
50 | mysql_query("insert into users (user_id,email,password,reg_time,nick,school) values ('$user','".mysql_real_escape_string($_POST['email'])."','$pwd',NOW(),'".mysql_real_escape_string($_POST['nick'])."','".mysql_real_escape_string($_POST['school'])."')");
51 | $code=mysql_errno();
52 | if($code==0)
53 | echo 'User created successfully!';
54 | else if($code==1062)
55 | echo "User '$user' exists.";
56 | else
57 | echo "Unknown error.";
58 | }
59 | ?>
--------------------------------------------------------------------------------
/web/code/ajax_saveproblem.php:
--------------------------------------------------------------------------------
1 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | User: | |
40 | Last Login: | |
41 |
42 | IP: | |
43 |
44 | School: | |
45 | E-mail: | |
46 | Reg Time: | |
47 | AC/Submit: | |
48 | 0");
51 | $number=mysql_num_rows($failed);
52 | echo "Failed: ($number) | ";
53 | while($row=mysql_fetch_row($failed)){
54 | echo '',$row[0],' ';
55 | if((++$i)==11){
56 | echo ' ';
57 | $i=0;
58 | }
59 | }
60 | echo ' |
';
61 | $i=0;
62 | $solved=mysql_query("select problem_id from solution where result=0 and user_id='$user' group by problem_id");
63 | $number=mysql_num_rows($solved);
64 | echo "Solved: ($number) | ";
65 | while($row=mysql_fetch_row($solved)){
66 | echo '',$row[0],' ';
67 | if((++$i)==11){
68 | echo ' ';
69 | $i=0;
70 | }
71 | }
72 | ?>
73 | |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/web/code/ajax_usernote.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/web/code/backupcode.php:
--------------------------------------------------------------------------------
1 |