From b39645c1a9514c6e89dcc179ed93f9f64d22e6e5 Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期五, 09 十二月 2016 18:27:58 +0800
Subject: [PATCH] test for pc server

---
 ProxyConsole/proxyconsole.c    |   28 ++++++++
 ProxyConsole/opentutorials.sql |  111 +++++++++++++++++++++++++++++++++++++
 ProxyConsole/make.sh           |    4 +
 3 files changed, 141 insertions(+), 2 deletions(-)

diff --git a/ProxyConsole/make.sh b/ProxyConsole/make.sh
new file mode 100644
index 0000000..40ae956
--- /dev/null
+++ b/ProxyConsole/make.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+gcc -pthread -lmysqlclient proxyconsole.c -o proxyconsole
+
diff --git a/ProxyConsole/opentutorials.sql b/ProxyConsole/opentutorials.sql
new file mode 100644
index 0000000..4e21461
--- /dev/null
+++ b/ProxyConsole/opentutorials.sql
@@ -0,0 +1,111 @@
+-- phpMyAdmin SQL Dump
+-- version 4.5.4.1deb2ubuntu2
+-- http://www.phpmyadmin.net
+--
+-- Host: localhost
+-- Generation Time: Nov 03, 2016 at 09:58 AM
+-- Server version: 5.7.16-0ubuntu0.16.04.1
+-- PHP Version: 7.0.8-0ubuntu0.16.04.3
+
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET time_zone = "+00:00";
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+--
+-- Database: `opentutorials`
+--
+CREATE DATABASE IF NOT EXISTS `opentutorials` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
+USE `opentutorials`;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `tbl_deviceinfo`
+--
+
+CREATE TABLE `tbl_deviceinfo` (
+  `id` int(11) NOT NULL,
+  `equipmentip` varchar(20) DEFAULT NULL,
+  `equipmentport` varchar(10) DEFAULT NULL,
+  `serverip` varchar(20) DEFAULT NULL,
+  `serverport` varchar(10) DEFAULT NULL,
+  `password` varchar(50) DEFAULT NULL,
+  `username` varchar(50) DEFAULT NULL,
+  `analysis` varchar(10) DEFAULT NULL,
+  `comtype` varchar(10) DEFAULT NULL,
+  `redate` datetime  DEFAULT NULL,
+  `comment` varchar(256) DEFAULT NULL,
+  `reboot` int(10) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='This table contains device related infomation';
+
+--
+-- Dumping data for table `tbl_deviceinfo`
+--
+
+INSERT INTO `tbl_deviceinfo` (`id`, `equipmentip`, `equipmentport`, `serverip`, `serverport`, `password`, `username`, `analysis`, `comtype`, `redate`, `comment`, `reboot`) VALUES
+(4, '124.205.246.90', '80', '192.168.1.3', '5015', 'supervisor', 'supervisor', '222', 'TCP', '2016-11-02 11:37:48', '1256', 0),
+(6, '124.205.246.91', '80', '192.168.1.3', '5015', 'supervisor', 'supervisor', '10000', 'TCP', '2016-11-01 21:23:55', 'Bioolfy', 0);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `tbl_userinfo`
+--
+
+CREATE TABLE `tbl_userinfo` (
+  `id` int(10) UNSIGNED NOT NULL,
+  `account` varchar(50) DEFAULT NULL,
+  `password` varchar(50) DEFAULT NULL,
+  `redate` datetime DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Dumping data for table `tbl_userinfo`
+--
+
+INSERT INTO `tbl_userinfo` (`id`, `account`, `password`, `redate`) VALUES
+(1, 'admin', 'admin', '2016-10-22 00:00:00');
+
+--
+-- Indexes for dumped tables
+--
+
+--
+-- Indexes for table `tbl_deviceinfo`
+--
+ALTER TABLE `tbl_deviceinfo`
+  ADD PRIMARY KEY (`id`);
+
+--
+-- Indexes for table `tbl_userinfo`
+--
+ALTER TABLE `tbl_userinfo`
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `id` (`id`),
+  ADD UNIQUE KEY `id_2` (`id`),
+  ADD UNIQUE KEY `id_3` (`id`),
+  ADD UNIQUE KEY `id_4` (`id`),
+  ADD UNIQUE KEY `id_5` (`id`);
+
+--
+-- AUTO_INCREMENT for dumped tables
+--
+
+--
+-- AUTO_INCREMENT for table `tbl_deviceinfo`
+--
+ALTER TABLE `tbl_deviceinfo`
+  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
+--
+-- AUTO_INCREMENT for table `tbl_userinfo`
+--
+ALTER TABLE `tbl_userinfo`
+  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
diff --git a/ProxyConsole/proxyconsole.c b/ProxyConsole/proxyconsole.c
index df5effc..e009a9b 100644
--- a/ProxyConsole/proxyconsole.c
+++ b/ProxyConsole/proxyconsole.c
@@ -12,7 +12,7 @@
 #include <pthread.h>
 #include <sys/time.h>
 #include <fcntl.h>
-#include "/usr/include/mysql/mysql.h"
+//#include "/usr/include/mysql/mysql.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -437,6 +437,29 @@
   pthread_exit((void*)thread_Real[eidx]);
 }
 
+int Read_MysqlData()
+{
+	static sockinfo equipments_config[] = {
+		//{
+		//	.m_id = 1, 
+		//	.ip = "192.168.1.5", 		// equipmentip (analizer)
+		//	.port = "80", 				// equipmentport
+		//	.user = "supervisor", 		// equipment username
+		//	.pass = "supervisor", 		// equipment password
+		//	.serverIP = "192.168.1.2", 	// serverip
+		//	.serverport = "5015", 		// serverport
+		//	.reboot = 0
+		//},
+		{ .m_id = 1, .ip = "192.168.1.5", .port = "80", .user = "supervisor", .pass = "supervisor", .serverIP = "192.168.1.2", .serverport = "5015", .reboot = 0 },
+	};
+	
+	memcpy(equipments, equipments_config, sizeof(equipments_config));
+	NUM = sizeof(equipments_config) / sizeof(sockinfo);
+
+	return 1;
+}
+
+/*
 int Read_MysqlData(){
 	int ret=0;
 	MYSQL *conn;
@@ -529,7 +552,8 @@
 	mysql_close(conn);
 	return ret;
 	
-}
+}*/
+
 int net_test(char* serverIP,char* port){
 		struct sockaddr_in servaddr;
 	   int strlen=sizeof(servaddr);

--
Gitblit v1.8.0