Смекни!
smekni.com

Распределенная служба кодирования (стр. 3 из 3)

curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);

/* enable uploading */

curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);

/* specify target */

strcpy(command, "ftp://");

strcat(command, ftp_login); //Vladimir.Belekhov

strcat(command, ":"); //:

strcat(command, ftp_pass); // pass

strcat(command, "@"); //@

strcat(command, ftp_link); //share.auditory.ru/2011/Vladimir.Belekhov/test/upload/");

strcat(command, newname); // avi.avi

// printf("%s\n\n", command);

curl_easy_setopt(curl,CURLOPT_URL, command);

/* now specify which file to upload */

curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);

curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);

/* Now run off and do what you've been told! */

res = curl_easy_perform(curl);

/** curl_ok != res maybe? **/

if(CURLE_OK != res)

{

/* we failed */

fprintf(stderr, "curl told us %d\n", res);

send(fdclient, "upnload error error", MAXLINE, 0);

continue;

}

else

{

progress = 3;

strcpy(command, "rm ");

strcat(command, recvname);

strcat(command, " ");

strcat(command, newname);

system(command);

}

/* always cleanup */

curl_easy_cleanup(curl);

}

fclose(hd_src); /* close the local file */

// тут мы пошлем серверу результат кодирования (удачный или нет)

send(fdclient, "next goal", MAXLINE, 0);

}

/* завершение работы клиента

*/

curl_global_cleanup();

close(fdclient);

return 0;

}

client.conf


***serv_port

2011

***serv_addres

0.0.0.0

// gets only first string after flag

10.0.0.140

***ftp_login

***ftp_pass

***ftp_link

share.auditory.ru/2011/Vladimir.Belekhov/test/upload/

***encode_streams

2

***end

MySQL dump тестовой базы данных

-- MySQL Administrator dump 1.4

--

-- ------------------------------------------------------

-- Server version 5.0.51a-24+lenny1

/*!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 utf8 */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;

/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;

/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

--

-- Create schema rsk

--

CREATE DATABASE IF NOT EXISTS rsk;

USE rsk;

--

-- Definition of table `rsk`.`goal`

--

DROP TABLE IF EXISTS `rsk`.`goal`;

CREATE TABLE `rsk`.`goal` (

`id` int(10) unsigned NOT NULL auto_increment,

`link` char(200) character set ucs2 NOT NULL default '0' COMMENT 'links to download files - must send to client',

`at_work` tinyint(1) unsigned NOT NULL default '0' COMMENT '1 when goal already send to client',

`file_name` char(100) NOT NULL COMMENT 'file names кароче чтобы наш curl мог назвать так скачанный файл',

PRIMARY KEY (`id`)

) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1 COMMENT='stored rsk goals';

--

-- Dumping data for table `rsk`.`goal`

--

/*!40000 ALTER TABLE `goal` DISABLE KEYS */;

LOCK TABLES `goal` WRITE;

INSERT INTO `rsk`.`goal` VALUES (1,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testa.bmp',1,'testa.bmp'),

(2,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testaa.bmp',1,'testaa.bmp'),

(3,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testaaa.bmp',1,'testaaa.bmp'),

(4,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testaaaa.bmp',1,'testaaaa.bmp'),

(5,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testaaaaa.bmp',1,'testaaaaa.bmp'),

(6,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testaaaaaa.bmp',1,'testaaaaaa.bmp'),

(7,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testaaaaaaa.bmp',1,'testaaaaaaa.bmp'),

(8,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testaaaaaaaa.bmp',1,'testaaaaaaaa.bmp'),

(9,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testaaaaaaaaa.bmp',1,'testaaaaaaaaa.bmp'),

(10,'http://share.auditory.ru/2011/Vladimir.Belekhov/test/testaaaaaaaaaa.bmp',1,'testaaaaaaaaaa.bmp');

UNLOCK TABLES;

/*!40000 ALTER TABLE `goal` ENABLE KEYS */;

--

-- Definition of table `rsk`.`pid`

--

DROP TABLE IF EXISTS `rsk`.`pid`;

CREATE TABLE `rsk`.`pid` (

`pids` int(10) unsigned NOT NULL COMMENT 'child pids',

`at_work` tinyint(1) NOT NULL default '0' COMMENT 'true when server work with client'

) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='stored pids parallel servers childs';

--

-- Dumping data for table `rsk`.`pid`

--

/*!40000 ALTER TABLE `pid` DISABLE KEYS */;

LOCK TABLES `pid` WRITE;

INSERT INTO `rsk`.`pid` VALUES (1,1);

UNLOCK TABLES;

/*!40000 ALTER TABLE `pid` ENABLE KEYS */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

/*!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 */;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;