diff options
author | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-07-16 22:51:22 +0300 |
---|---|---|
committer | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-07-16 22:51:22 +0300 |
commit | 1aaf600d004945a745c5ba9e15e8be9007700593 (patch) | |
tree | e92eacfa56055b3e58223e9605d4a558df554a00 | |
parent | Add to segget.conf file section [provide_proxy_fetcher_to_others]. (diff) | |
download | idfetch-1aaf600d004945a745c5ba9e15e8be9007700593.tar.gz idfetch-1aaf600d004945a745c5ba9e15e8be9007700593.tar.bz2 idfetch-1aaf600d004945a745c5ba9e15e8be9007700593.zip |
Fix: Generate one .o per .cpp, and link them together.
-rw-r--r-- | segget/Makefile | 7 | ||||
-rw-r--r-- | segget/connection.cpp | 4 | ||||
-rw-r--r-- | segget/connection.h | 5 | ||||
-rw-r--r-- | segget/distfile.h | 23 | ||||
-rw-r--r-- | segget/mirror.cpp | 2 | ||||
-rw-r--r-- | segget/mirror.h | 2 | ||||
-rw-r--r-- | segget/network.cpp | 4 | ||||
-rw-r--r-- | segget/network.h | 6 | ||||
-rw-r--r-- | segget/networkbroker.h | 5 | ||||
-rw-r--r-- | segget/pkg.cpp | 2 | ||||
-rw-r--r-- | segget/pkg.h | 4 | ||||
-rw-r--r-- | segget/segget.cpp | 1 | ||||
-rw-r--r-- | segget/segget.h | 31 | ||||
-rw-r--r-- | segget/segment.cpp | 2 | ||||
-rw-r--r-- | segget/segment.h | 5 | ||||
-rw-r--r-- | segget/settings.cpp | 3 | ||||
-rw-r--r-- | segget/settings.h | 2 | ||||
-rw-r--r-- | segget/shorttypes.h | 32 | ||||
-rw-r--r-- | segget/stats.cpp | 2 | ||||
-rw-r--r-- | segget/stats.h | 3 | ||||
-rw-r--r-- | segget/str.cpp | 23 | ||||
-rw-r--r-- | segget/str.h | 10 | ||||
-rw-r--r-- | segget/tui.h | 1 | ||||
-rw-r--r-- | segget/ui_server.cpp | 4 | ||||
-rw-r--r-- | segget/ui_server.h | 9 | ||||
-rw-r--r-- | segget/utils.h | 4 |
26 files changed, 146 insertions, 50 deletions
diff --git a/segget/Makefile b/segget/Makefile index 07b0541..c242b53 100644 --- a/segget/Makefile +++ b/segget/Makefile @@ -17,8 +17,11 @@ all: clean $(BINS) %.o: %.cxx $(CXX) -c -o $@ $(CXXFLAGS) $^ -%: %.o - $(CXX) -o $@ $(LIBS) $(CIBS) $^ + +segget: segget.o connection.o checksum.o config.o distfile.o mirror.o network.o networkbroker.o pkg.o segment.o settings.o stats.o str.o tui.o utils.o ui_ + $(CXX) -o $@ -lncurses $(LIBS) $(CIBS) $^ +#%: %.o +# $(CXX) -o $@ $(LIBS) $(CIBS) $^ clean: -rm -f $(BINS) $(OBJS) diff --git a/segget/connection.cpp b/segget/connection.cpp index 423c783..254f971 100644 --- a/segget/connection.cpp +++ b/segget/connection.cpp @@ -25,6 +25,10 @@ */ #include "connection.h" +uint Tconnection::total_connections=0; +Tconnection connection_array[MAX_CONNECTS]; +time_t prev_time; + void Tconnection::start(CURLM *cm, uint network_number, uint distfile_num, Tsegment *started_segment, uint best_mirror_num){ try{ segment=started_segment; diff --git a/segget/connection.h b/segget/connection.h index a5dd206..91184e3 100644 --- a/segget/connection.h +++ b/segget/connection.h @@ -62,7 +62,6 @@ class Tconnection{ void show_connection_progress(ulong time_diff); }; -time_t prev_time; -uint Tconnection::total_connections=0; -Tconnection connection_array[MAX_CONNECTS]; +extern time_t prev_time; +extern Tconnection connection_array[MAX_CONNECTS]; #endif
\ No newline at end of file diff --git a/segget/distfile.h b/segget/distfile.h index abf8076..4ec2fc3 100644 --- a/segget/distfile.h +++ b/segget/distfile.h @@ -51,18 +51,19 @@ #include "checksum.h" #include "network.h" #include "networkbroker.h" +#include "segment.h" +class Tsegment; - -#include <sys/types.h> -#include <sys/socket.h> -#include <stdio.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <sys/ioctl.h> -#include <unistd.h> -#include <stdlib.h> -#include <string> -#include <string.h> +//#include <sys/types.h> +//#include <sys/socket.h> +//#include <stdio.h> +//#include <netinet/in.h> +//#include <arpa/inet.h> +//#include <sys/ioctl.h> +//#include <unistd.h> +//#include <stdlib.h> +//#include <string> +//#include <string.h> //#include "client.cpp" diff --git a/segget/mirror.cpp b/segget/mirror.cpp index b0e2002..22cd0d7 100644 --- a/segget/mirror.cpp +++ b/segget/mirror.cpp @@ -26,6 +26,8 @@ #include "mirror.h" +map<string,Tmirror *> mirror_list; + double Tmirror::mirror_on_the_wall(){ try{ double criterion=honesty*1000000000*dld_time/dld_size; diff --git a/segget/mirror.h b/segget/mirror.h index 765708f..e747d6b 100644 --- a/segget/mirror.h +++ b/segget/mirror.h @@ -55,7 +55,7 @@ class Tmirror{ uint get_active_num(){return active_num;}; }; -map<string,Tmirror *> mirror_list; +extern map<string,Tmirror *> mirror_list; string strip_mirror_name(string path); Tmirror* find_mirror(string mirror_url); #endif
\ No newline at end of file diff --git a/segget/network.cpp b/segget/network.cpp index ad765f5..2705947 100644 --- a/segget/network.cpp +++ b/segget/network.cpp @@ -24,6 +24,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "network.h" + +uint Tnetwork::network_count=0; +Tnetwork network_array[MAX_NETWORKS]; + void Tnetwork::load_mirror_list(){ try{ ifstream file; diff --git a/segget/network.h b/segget/network.h index a42f54d..e86e494 100644 --- a/segget/network.h +++ b/segget/network.h @@ -31,6 +31,7 @@ #include <vector> #include "str.h" #include "mirror.h" +class Tmirror; #include "config.h" //#include "tui.h" //#include "settings.cpp" @@ -47,6 +48,7 @@ class Tnetwork{ private: void load_mirror_list(); public: +// vector<int> benchmarked_mirror_list; vector<Tmirror> benchmarked_mirror_list; uint active_connections_num; //network @@ -113,6 +115,6 @@ class Tnetwork{ void disconnect(){active_connections_num--;}; }; -uint Tnetwork::network_count=0; -Tnetwork network_array[MAX_NETWORKS]; +//extern uint Tnetwork::network_count=0; +extern Tnetwork network_array[MAX_NETWORKS]; #endif
\ No newline at end of file diff --git a/segget/networkbroker.h b/segget/networkbroker.h index 05b9449..6b55e7d 100644 --- a/segget/networkbroker.h +++ b/segget/networkbroker.h @@ -26,6 +26,11 @@ #ifndef __NETWORK_DISTFILE_BROKER_H__ #define __NETWORK_DISTFILE_BROKER_H__ +#include <vector> +#include "shorttypes.h" +#include "network.h" +using namespace std; + class Tnetwork_distfile_broker{ public: // map<string,Tmirror *> benchmarked_mirror_list; diff --git a/segget/pkg.cpp b/segget/pkg.cpp index bcbac68..bf8daf8 100644 --- a/segget/pkg.cpp +++ b/segget/pkg.cpp @@ -25,6 +25,8 @@ */ #include "pkg.h" +Tpkg **Ppkg_array; +Tpkg proxy_fetcher_pkg; void Tpkg::push_back_distfile(json_object* json_distfile){ try{ diff --git a/segget/pkg.h b/segget/pkg.h index 480c24f..a47033f 100644 --- a/segget/pkg.h +++ b/segget/pkg.h @@ -57,7 +57,7 @@ class Tpkg{ void load_pkg_from_json(json_object* json_obj_pkg); }; -Tpkg **Ppkg_array; -Tpkg proxy_fetcher_pkg; +extern Tpkg **Ppkg_array; +extern Tpkg proxy_fetcher_pkg; #endif
\ No newline at end of file diff --git a/segget/segget.cpp b/segget/segget.cpp index 8aa11ce..865cca7 100644 --- a/segget/segget.cpp +++ b/segget/segget.cpp @@ -407,7 +407,6 @@ int main() } void *print_message_function(void *ptr){ - char * args = (char *) ptr; while (true){ ulong time_diff_msecs=time_left_from(stats.previous_time); if (time_diff_msecs >= settings.current_speed_time_interval_msecs){ diff --git a/segget/segget.h b/segget/segget.h index d2e9b2c..ac44294 100644 --- a/segget/segget.h +++ b/segget/segget.h @@ -35,22 +35,21 @@ #include <json/json.h> #include <ncurses.h> #include <pthread.h> -#include "checksum.cpp" -#include "config.cpp" -#include "connection.cpp" -#include "distfile.cpp" -#include "mirror.cpp" -#include "network.cpp" -#include "networkbroker.cpp" -#include "pkg.cpp" -#include "segment.cpp" -#include "settings.cpp" -#include "stats.cpp" -#include "str.cpp" -#include "tui.cpp" -#include "utils.cpp" -#include "ui_server.cpp" -#include "proxyfetcher.cpp" +#include "checksum.h" +#include "config.h" +#include "distfile.h" +#include "mirror.h" +#include "network.h" +#include "networkbroker.h" +#include "pkg.h" +#include "segment.h" +#include "settings.h" +//#include "stats.h" +#include "str.h" +#include "tui.h" +#include "utils.h" +#include "ui_server.h" +#include "proxyfetcher.h" using namespace std; diff --git a/segget/segment.cpp b/segget/segment.cpp index 6606bc8..45116cf 100644 --- a/segget/segment.cpp +++ b/segget/segment.cpp @@ -26,6 +26,8 @@ #include "segment.h" +Tsegment *segments_in_progress[MAX_CONNECTS]={0}; + string statusToString(Tsegment_status the_status){ switch (the_status){ case SWAITING:return "SWAITING"; diff --git a/segget/segment.h b/segget/segment.h index 0c0ba83..af00f34 100644 --- a/segget/segment.h +++ b/segget/segment.h @@ -45,7 +45,7 @@ class Tdistfile; extern Tsettings settings; -unsigned long downloaded_bytes=0; +//unsigned long downloaded_bytes=0; size_t write_data(void *buffer, size_t size, size_t nmemb, void *cur_segment); enum Tsegment_status{SWAITING, SDOWNLOADING, SDOWNLOADED, SFAILED}; @@ -90,8 +90,9 @@ class Tsegment{ int add_easy_handle_to_multi(CURLM *cm, uint network_num); }; -Tsegment *segments_in_progress[MAX_CONNECTS]={0}; +extern Tsegment *segments_in_progress[MAX_CONNECTS]; +string statusToString(Tsegment_status the_status); void show_progress(double time_diff); size_t write_data(void *buffer, size_t size, size_t nmemb, void *cur_segment); #endif
\ No newline at end of file diff --git a/segget/settings.cpp b/segget/settings.cpp index ddab8b9..329efb3 100644 --- a/segget/settings.cpp +++ b/segget/settings.cpp @@ -25,6 +25,9 @@ */ #include "settings.h" + +Tsettings settings; + void Tsettings::load_provide_mirror_files_restricted_patterns_vector(){ try{ ifstream file; diff --git a/segget/settings.h b/segget/settings.h index ede0a7a..bfe9c02 100644 --- a/segget/settings.h +++ b/segget/settings.h @@ -127,5 +127,5 @@ class Tsettings{ void init(); }; -Tsettings settings; +extern Tsettings settings; #endif
\ No newline at end of file diff --git a/segget/shorttypes.h b/segget/shorttypes.h new file mode 100644 index 0000000..af0b982 --- /dev/null +++ b/segget/shorttypes.h @@ -0,0 +1,32 @@ +/* +* Copyright (C) 2010 Robin H.Johnson, Ovechko Kostyantyn <fastinetserver@gmail.com>. +* +* Project: IDFetch. +* Developer: Ovechko Kostyantyn Olexandrovich (Kharkiv State Technical University of Construction and Architecture, Ukraine). +* Mentor: Robin H. Johnson (Gentoo Linux: Developer, Trustee & Infrastructure Lead). +* Mentoring organization: Gentoo Linux. +* Sponsored by GSOC 2010. +* +* This file is part of Segget. +* +* Segget is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* Segget is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with Segget; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _TYPES_H_ +#define _TYPES_H_ + +typedef unsigned long ulong; + +#endif
\ No newline at end of file diff --git a/segget/stats.cpp b/segget/stats.cpp index bd782ca..1a0a271 100644 --- a/segget/stats.cpp +++ b/segget/stats.cpp @@ -26,6 +26,8 @@ #include "stats.h" +Tstats stats; + void Tstats::inc_dld_distfiles_count(){ try{ dld_distfiles_count++; diff --git a/segget/stats.h b/segget/stats.h index dd14160..2cb78a3 100644 --- a/segget/stats.h +++ b/segget/stats.h @@ -64,5 +64,6 @@ class Tstats{ void reset_previous_time(); }; -Tstats stats; +extern Tstats stats; + #endif
\ No newline at end of file diff --git a/segget/str.cpp b/segget/str.cpp index a9f652f..83eaa42 100644 --- a/segget/str.cpp +++ b/segget/str.cpp @@ -25,14 +25,19 @@ */ #include "str.h" -using namespace std; +string toString(uint t){ + stringstream s; + s << t; + return s.str(); +} +/* template<typename T> string toString(T t){ stringstream s; s << t; return s.str(); } - +*/ template<typename T> string field(string prefix,T t, int width){ try{ stringstream s1,s2; @@ -47,6 +52,20 @@ template<typename T> string field(string prefix,T t, int width){ } } +string field(string prefix,ulong t, int width){ + try{ + stringstream s1,s2; + s1 << t; + width=width+prefix.length(); + s2.width(width); + s2 << prefix+s1.str(); + return s2.str(); + }catch(...){ + error_log("Error in str.cpp: field()"); + return ""; + } +} + int lower_char(int c){ try{ return tolower((unsigned char)c); diff --git a/segget/str.h b/segget/str.h index 438117e..c88303a 100644 --- a/segget/str.h +++ b/segget/str.h @@ -28,12 +28,18 @@ #define __STR_H__ #include <string> #include <algorithm> +#include <sstream> +#include "tui.h" using namespace std; -template<typename T> string toString(T t); -template<typename T> string field(string prefix,T t, int width); +//template<typename T> string toString(T t); +//template<typename T> string field(string prefix,T t, int width); string trim(std::string const& source, char const* delims = " \t\r\n"); int lower_char(int c); string noupper(string s); + +string toString(uint t); +string field(string prefix,ulong t, int width); + #endif
\ No newline at end of file diff --git a/segget/tui.h b/segget/tui.h index a09f4e3..baf718f 100644 --- a/segget/tui.h +++ b/segget/tui.h @@ -26,6 +26,7 @@ #ifndef __TUI_H__ #define __TUI_H__ +#include <ncurses.h> #include "settings.h" #include "ui_server.h" diff --git a/segget/ui_server.cpp b/segget/ui_server.cpp index 2ba19d9..dda3da4 100644 --- a/segget/ui_server.cpp +++ b/segget/ui_server.cpp @@ -26,6 +26,10 @@ #include "ui_server.h" +uint max_published_screenline_num; +Tui_server ui_server; +string screenlines[DEBUG_LINE_NUM+1]; + void Tui_server::init(){ socklen_t server_len; struct sockaddr_in server_address; diff --git a/segget/ui_server.h b/segget/ui_server.h index e33e94a..a4c1fa8 100644 --- a/segget/ui_server.h +++ b/segget/ui_server.h @@ -36,7 +36,8 @@ #include <sys/ioctl.h> #include <unistd.h> #include <stdlib.h> -#include <string.h> +#include <string> +#include "settings.h" using namespace std; @@ -48,8 +49,8 @@ const uint LOG_LINE_NUM=MAX_LINES+2; const uint DEBUG_LINE_NUM=MAX_LINES+3; //const uint MAX_LINES=200; -string screenlines[DEBUG_LINE_NUM+1]; -uint max_published_screenline_num; +extern string screenlines[DEBUG_LINE_NUM+1]; +extern uint max_published_screenline_num; class Tui_server{ public: @@ -62,7 +63,7 @@ class Tui_server{ void send_all_clients(uint y, string msg); }; -Tui_server ui_server; +extern Tui_server ui_server; void *run_ui_server(void * ptr); diff --git a/segget/utils.h b/segget/utils.h index d32208f..b897402 100644 --- a/segget/utils.h +++ b/segget/utils.h @@ -28,6 +28,10 @@ #define __UTILS_H__ #include "sys/time.h" +#include "shorttypes.h" +#include "tui.h" + +using namespace std; ulong time_left_from(timeval from_time); |