Import dctc 0.68.0; submitted by Nils Nordman <nino@nforced.com>.
DCTC is a Direct Connect clone, allowing users to share their files and talk (like IRC but more software sharing oriented) using a proprietary protocol.
This commit is contained in:
parent
10c193e213
commit
f67f6898c6
33
net/dctc/Makefile
Normal file
33
net/dctc/Makefile
Normal file
@ -0,0 +1,33 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2002/01/31 12:21:53 naddy Exp $
|
||||
|
||||
COMMENT= "Direct Connect clone"
|
||||
|
||||
DISTNAME= dctc-0.68.0
|
||||
CATEGORIES= net
|
||||
NEED_VERSION= 1.504
|
||||
HOMEPAGE= http://ac2i.tzo.com/dctc/
|
||||
|
||||
MAINTAINER= Nils Nordman <nino@nforced.com>
|
||||
|
||||
# GPL
|
||||
PERMIT_PACKAGE_CDROM= Yes
|
||||
PERMIT_PACKAGE_FTP= Yes
|
||||
PERMIT_DISTFILES_CDROM= Yes
|
||||
PERMIT_DISTFILES_FTP= Yes
|
||||
|
||||
MASTER_SITES= ${HOMEPAGE}
|
||||
|
||||
LIB_DEPENDS= glib.1.2,gthread.1.2::devel/glib
|
||||
|
||||
SEPARATE_BUILD= concurrent
|
||||
CONFIGURE_STYLE= autoconf
|
||||
CONFIGURE_ENV= CPPFLAGS="-DMSG_NOSIGNAL=0"
|
||||
|
||||
post-configure:
|
||||
@cd ${WRKSRC}; touch Makefile.in src/Makefile.in aclocal.m4 stamp-h.in
|
||||
|
||||
post-install:
|
||||
@${INSTALL_DATA_DIR} ${PREFIX}/share/doc/dctc; \
|
||||
cp -R ${WRKSRC}/Documentation/* ${PREFIX}/share/doc/dctc/
|
||||
|
||||
.include <bsd.port.mk>
|
3
net/dctc/distinfo
Normal file
3
net/dctc/distinfo
Normal file
@ -0,0 +1,3 @@
|
||||
MD5 (dctc-0.68.0.tar.gz) = d9cb04541b0c246d40673e90de79fff1
|
||||
RMD160 (dctc-0.68.0.tar.gz) = dd95e7f381686609a42192736efe0d5800ea24d5
|
||||
SHA1 (dctc-0.68.0.tar.gz) = aeef7d545b0b032d29dfabd0f2a30e52aace81dc
|
28
net/dctc/patches/patch-config_h_in
Normal file
28
net/dctc/patches/patch-config_h_in
Normal file
@ -0,0 +1,28 @@
|
||||
$OpenBSD: patch-config_h_in,v 1.1.1.1 2002/01/31 12:21:54 naddy Exp $
|
||||
--- config.h.in.orig Sun Jan 13 17:19:20 2002
|
||||
+++ config.h.in Sun Jan 13 17:19:22 2002
|
||||
@@ -27,6 +27,9 @@
|
||||
/* Define if you have the getcwd function. */
|
||||
#undef HAVE_GETCWD
|
||||
|
||||
+/* Define if you have the getopt_long function. */
|
||||
+#undef HAVE_GETOPT_LONG
|
||||
+
|
||||
/* Define if you have the getpagesize function. */
|
||||
#undef HAVE_GETPAGESIZE
|
||||
|
||||
@@ -63,8 +66,14 @@
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
+/* Define if you have the <getopt.h> header file. */
|
||||
+#undef HAVE_GETOPT_H
|
||||
+
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
+
|
||||
+/* Define if you have the <linux/sem.h> header file. */
|
||||
+#undef HAVE_LINUX_SEM_H
|
||||
|
||||
/* Define if you have the <ndir.h> header file. */
|
||||
#undef HAVE_NDIR_H
|
20
net/dctc/patches/patch-configure_in
Normal file
20
net/dctc/patches/patch-configure_in
Normal file
@ -0,0 +1,20 @@
|
||||
$OpenBSD: patch-configure_in,v 1.1.1.1 2002/01/31 12:21:54 naddy Exp $
|
||||
--- configure.in.orig Sun Jan 20 13:27:03 2002
|
||||
+++ configure.in Tue Jan 29 15:57:59 2002
|
||||
@@ -26,7 +27,7 @@ AM_PATH_GLIB(1.2.0, , , glib gthread)
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
-AC_CHECK_HEADERS(fcntl.h limits.h strings.h sys/file.h sys/ioctl.h sys/time.h unistd.h)
|
||||
+AC_CHECK_HEADERS(fcntl.h limits.h strings.h sys/file.h sys/ioctl.h sys/time.h unistd.h linux/sem.h getopt.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
@@ -39,6 +40,6 @@ AC_STRUCT_TM
|
||||
dnl Checks for library functions.
|
||||
AC_FUNC_MEMCMP
|
||||
AC_FUNC_MMAP
|
||||
-AC_CHECK_FUNCS(getcwd mkdir select socket strdup strerror strstr strtod strtoul uname)
|
||||
+AC_CHECK_FUNCS(getcwd mkdir select socket strdup strerror strstr strtod strtoul uname getopt_long)
|
||||
|
||||
AC_OUTPUT(Makefile src/Makefile)
|
153
net/dctc/patches/patch-src_db_c
Normal file
153
net/dctc/patches/patch-src_db_c
Normal file
@ -0,0 +1,153 @@
|
||||
$OpenBSD: patch-src_db_c,v 1.1.1.1 2002/01/31 12:21:54 naddy Exp $
|
||||
--- src/db.c.orig Sat Jan 26 09:05:21 2002
|
||||
+++ src/db.c Mon Jan 28 12:12:27 2002
|
||||
@@ -45,7 +45,7 @@
|
||||
/* list of shared directories */
|
||||
/******************************/
|
||||
G_LOCK_DEFINE_STATIC(shared_dirs);
|
||||
-GPtrArray *shared_dirs=NULL;
|
||||
+GSList *shared_dirs=NULL;
|
||||
|
||||
/********************************************************************/
|
||||
/* database containing the list of all shared files with their type */
|
||||
@@ -398,6 +398,29 @@ static GArray *rebuild_dir_database(GArr
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
+/* determines the level for the next dir given the previous */
|
||||
+/* dir, based on the common part of the both dirs. */
|
||||
+/***************************************************************/
|
||||
+/* output: lvl contains the correct level to use for the next */
|
||||
+/* dir. Returns the starting point to use with nextdir */
|
||||
+/***************************************************************/
|
||||
+char * get_level_for_next_dir(char *prevdir, char *nextdir, int *lvl)
|
||||
+{
|
||||
+ char *startp = nextdir;
|
||||
+
|
||||
+ *lvl = 0;
|
||||
+ while( *nextdir && *nextdir == *prevdir ) {
|
||||
+ if( *nextdir == '/' && nextdir != startp ) /* ignore the first '/' */
|
||||
+ (*lvl)++;
|
||||
+ nextdir++;
|
||||
+ prevdir++;
|
||||
+ }
|
||||
+ while( nextdir != startp && *(nextdir - 1) != '/' )
|
||||
+ nextdir--;
|
||||
+ return nextdir;
|
||||
+}
|
||||
+
|
||||
+/***************************************************************/
|
||||
/* fully rebuild shared file database */
|
||||
/* this rebuilding can be done even if a search is in progress */
|
||||
/***************************************************************/
|
||||
@@ -410,6 +433,10 @@ void rebuild_database(void)
|
||||
GByteArray *nw_he3;
|
||||
GByteArray *old_he3;
|
||||
GString *ls_format=NULL;
|
||||
+ char *prevdir = NULL;
|
||||
+ char *nextdir;
|
||||
+ int lvl;
|
||||
+ GSList *li;
|
||||
|
||||
/* rebuild a new database */
|
||||
ls_format=g_string_sized_new(65536);
|
||||
@@ -419,12 +446,18 @@ void rebuild_database(void)
|
||||
new_shared=g_array_new(FALSE,FALSE,sizeof(DB_ENTRY));
|
||||
if(shared_dirs!=NULL)
|
||||
{
|
||||
- for(i=0;i<shared_dirs->len;i++)
|
||||
+ lvl = 0;
|
||||
+ li = shared_dirs;
|
||||
+ while( li != NULL )
|
||||
{
|
||||
- int lvl=0;
|
||||
- add_initial_dir_to_ls(&ls_format,&lvl,g_ptr_array_index(shared_dirs,i));
|
||||
-
|
||||
- new_shared=rebuild_dir_database(new_shared,&sod,g_ptr_array_index(shared_dirs,i),&ls_format,lvl);
|
||||
+ nextdir = li->data;
|
||||
+ if(prevdir)
|
||||
+ nextdir = get_level_for_next_dir(prevdir, nextdir, &lvl );
|
||||
+
|
||||
+ add_initial_dir_to_ls(&ls_format,&lvl,nextdir);
|
||||
+ new_shared=rebuild_dir_database(new_shared,&sod,li->data,&ls_format,lvl);
|
||||
+ prevdir = li->data;
|
||||
+ li = g_slist_next(li);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,6 +505,14 @@ void rebuild_database(void)
|
||||
}
|
||||
|
||||
/*****************************************************/
|
||||
+/* comparison function for GSList, char * */
|
||||
+/*****************************************************/
|
||||
+gint string_compare(gconstpointer a, gconstpointer b)
|
||||
+{
|
||||
+ return strcmp( (char *)a, (char *)b );
|
||||
+}
|
||||
+
|
||||
+/*****************************************************/
|
||||
/* add a directory to the list of shared directories */
|
||||
/**********************************************************/
|
||||
/* due to the fact this function runs in the main thread, */
|
||||
@@ -484,9 +525,6 @@ void add_shared_directory(char *dir)
|
||||
struct stat st;
|
||||
char *str;
|
||||
|
||||
- if(shared_dirs==NULL)
|
||||
- shared_dirs=g_ptr_array_new();
|
||||
-
|
||||
if(stat(dir,&st))
|
||||
{
|
||||
disp_msg(ERR_MSG,"add_shared_directory","invalid dir",dir,NULL);
|
||||
@@ -509,7 +547,7 @@ void add_shared_directory(char *dir)
|
||||
|
||||
/* add this directory to the list and rebuild database */
|
||||
G_LOCK(shared_dirs);
|
||||
- g_ptr_array_add(shared_dirs,str);
|
||||
+ shared_dirs=g_slist_insert_sorted(shared_dirs,str, &string_compare);
|
||||
G_UNLOCK(shared_dirs);
|
||||
|
||||
rebuild_database();
|
||||
@@ -532,15 +570,8 @@ void remove_shared_directory(char *dir)
|
||||
|
||||
/* remove this directory to the list and rebuild database */
|
||||
G_LOCK(shared_dirs);
|
||||
- for(i=0;i<shared_dirs->len;i++)
|
||||
- {
|
||||
- if(!strcmp(dir, g_ptr_array_index(shared_dirs,i)) )
|
||||
- {
|
||||
- g_ptr_array_remove_index_fast(shared_dirs,i);
|
||||
- disp_msg(DEBUG_MSG,NULL,"unsharing",dir,NULL);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ disp_msg(DEBUG_MSG,NULL,"unsharing",dir,NULL);
|
||||
+ shared_dirs=g_slist_remove( shared_dirs, dir );
|
||||
G_UNLOCK(shared_dirs);
|
||||
|
||||
rebuild_database();
|
||||
@@ -554,17 +585,20 @@ void remove_shared_directory(char *dir)
|
||||
GString *get_shared_directory_list(void)
|
||||
{
|
||||
GString *lst;
|
||||
+ GSList *li;
|
||||
int i;
|
||||
|
||||
lst=g_string_new("");
|
||||
G_LOCK(shared_dirs);
|
||||
if(shared_dirs!=NULL)
|
||||
{
|
||||
- for(i=0;i<shared_dirs->len;i++)
|
||||
+ li = shared_dirs;
|
||||
+ while( li != NULL )
|
||||
{
|
||||
- if(i!=0)
|
||||
+ if(li!=shared_dirs)
|
||||
lst=g_string_append_c(lst,'|');
|
||||
- g_string_sprintfa(lst,"%s",(char*)g_ptr_array_index(shared_dirs,i));
|
||||
+ g_string_sprintfa(lst,"%s", li->data);
|
||||
+ li = g_slist_next(li);
|
||||
}
|
||||
}
|
||||
G_UNLOCK(shared_dirs);
|
151
net/dctc/patches/patch-src_dc_manage_c
Normal file
151
net/dctc/patches/patch-src_dc_manage_c
Normal file
@ -0,0 +1,151 @@
|
||||
$OpenBSD: patch-src_dc_manage_c,v 1.1.1.1 2002/01/31 12:21:53 naddy Exp $
|
||||
--- src/dc_manage.c.orig Fri Jan 25 17:39:48 2002
|
||||
+++ src/dc_manage.c Mon Jan 28 18:26:10 2002
|
||||
@@ -69,6 +69,16 @@ typedef enum
|
||||
MY_DIR_UPLOAD=1, /* what we should do on the connection: Upload */
|
||||
} MY_DIR;
|
||||
|
||||
+
|
||||
+/* compability macros for reading/writing to sockets */
|
||||
+#ifdef __OpenBSD__
|
||||
+# define sock_read(sck, buf, size, flags) read(sck, buf, size)
|
||||
+# define sock_write(sck, buf, size, flags) write(sck, buf, size)
|
||||
+#else
|
||||
+# define sock_read(sck, buf, size, flags) recv(sck, buf, size, flags)
|
||||
+# define sock_write(sck, buf, size, flags) send(sck, buf, size, flags)
|
||||
+#endif
|
||||
+
|
||||
int hub_logged=0; /* set to 1 when dctc is logged on the hub */
|
||||
|
||||
/********************************************************/
|
||||
@@ -294,13 +304,13 @@ static int send_file_data(int sck,char *
|
||||
act->last_touch=time(NULL);
|
||||
|
||||
get_slices(bl_semid,sizeof(buf)/512); /* obtain upload authorization */
|
||||
- res=send(sck,buf,sizeof(buf),MSG_NOSIGNAL /* |MSG_WAITALL */ );
|
||||
+ res=sock_write(sck,buf,sizeof(buf),MSG_NOSIGNAL /* |MSG_WAITALL */ );
|
||||
|
||||
act->last_touch=time(NULL);
|
||||
if(res!=sizeof(buf))
|
||||
goto abrt;
|
||||
|
||||
- sprintf(ul_stat,"%lu:%d/%lu/%lu/%lu",act->thread_id,start_pos,file_len,(i+1)*sizeof(buf),a);
|
||||
+ snprintf(ul_stat, sizeof(ul_stat), "%lu:%d/%lu/%lu/%lu",act->thread_id,start_pos,file_len,(i+1)*sizeof(buf),a);
|
||||
disp_msg(XFER_UL_STAT,NULL,ul_stat,NULL);
|
||||
}
|
||||
|
||||
@@ -317,7 +327,7 @@ static int send_file_data(int sck,char *
|
||||
act->last_touch=time(NULL);
|
||||
|
||||
get_slices(bl_semid,(remain+511)/512); /* obtain upload authorization */
|
||||
- res=send(sck,buf,remain,MSG_NOSIGNAL /* |MSG_WAITALL */ );
|
||||
+ res=sock_write(sck,buf,remain,MSG_NOSIGNAL /* |MSG_WAITALL */ );
|
||||
|
||||
act->last_touch=time(NULL);
|
||||
if(res!=remain)
|
||||
@@ -351,7 +361,7 @@ static int send_array_data(int sck,GByte
|
||||
act->last_touch=time(NULL);
|
||||
|
||||
get_slices(bl_semid,BLOCK_SIZE/512); /* obtain upload authorization */
|
||||
- res=send(sck,ba->data+cur_pos,BLOCK_SIZE,MSG_NOSIGNAL /* |MSG_WAITALL */ );
|
||||
+ res=sock_write(sck,ba->data+cur_pos,BLOCK_SIZE,MSG_NOSIGNAL /* |MSG_WAITALL */ );
|
||||
|
||||
act->last_touch=time(NULL);
|
||||
if(res!=BLOCK_SIZE)
|
||||
@@ -369,7 +379,7 @@ static int send_array_data(int sck,GByte
|
||||
act->last_touch=time(NULL);
|
||||
|
||||
get_slices(bl_semid,(remain+511)/512); /* obtain upload authorization */
|
||||
- res=send(sck,ba->data+cur_pos,remain,MSG_NOSIGNAL /* |MSG_WAITALL */ );
|
||||
+ res=sock_write(sck,ba->data+cur_pos,remain,MSG_NOSIGNAL /* |MSG_WAITALL */ );
|
||||
|
||||
act->last_touch=time(NULL);
|
||||
if(res!=remain)
|
||||
@@ -454,17 +464,18 @@ static int com_up_get_list_len_process(c
|
||||
|
||||
disp_msg(DEBUG_MSG,"reply",out->str,NULL);
|
||||
|
||||
- res=send(sck,out->str,out->len,MSG_NOSIGNAL);
|
||||
+ res=sock_write(sck,out->str,out->len,MSG_NOSIGNAL);
|
||||
res=(res!=out->len);
|
||||
g_string_free(out,TRUE);
|
||||
- if(res)
|
||||
+
|
||||
+ if(res || !strcmp(cmd,"$GetListLen"))
|
||||
{
|
||||
if(cpy_data!=NULL)
|
||||
g_byte_array_free(cpy_data,TRUE);
|
||||
LOCK_WRITE(user_info);
|
||||
free_dl_slot++;
|
||||
UNLOCK_WRITE(user_info);
|
||||
- return 1;
|
||||
+ return strcmp(cmd,"$GetListLen");
|
||||
}
|
||||
|
||||
/* get command */
|
||||
@@ -480,7 +491,9 @@ static int com_up_get_list_len_process(c
|
||||
g_string_sprintfa(out,"%lu|",(unsigned long)100000+rand()%500000);
|
||||
else
|
||||
g_string_sprintfa(out,"%lu|",(unsigned long)cpy_data->len);
|
||||
- res=send(sck,out->str,out->len,MSG_NOSIGNAL);
|
||||
+
|
||||
+ res=sock_write(sck,out->str,out->len,MSG_NOSIGNAL);
|
||||
+
|
||||
res=(res!=out->len);
|
||||
g_string_free(out,TRUE);
|
||||
if(res)
|
||||
@@ -685,7 +698,7 @@ static int com_up_get_process(const char
|
||||
disp_msg(XFER_UL_START,"",act->remote_nick->str,fullpathname,NULL);
|
||||
{
|
||||
char tmp[510];
|
||||
- sprintf(tmp,"%lu",(unsigned long)(act->thread_id));
|
||||
+ snprintf(tmp, sizeof(tmp), "%lu",(unsigned long)(act->thread_id));
|
||||
disp_msg(XFER_UL_RUN,NULL,tmp,act->remote_nick->str,act->disp_info->str,NULL);
|
||||
}
|
||||
|
||||
@@ -885,8 +898,9 @@ static int copie_fd_to_file(int remote,
|
||||
|
||||
/* touch the action slot to avoid timeout */
|
||||
act->last_touch=time(NULL);
|
||||
- ret=recv(remote,buf,nb,MSG_WAITALL|MSG_NOSIGNAL);
|
||||
-
|
||||
+
|
||||
+ ret=sock_read(remote,buf,nb,MSG_WAITALL|MSG_NOSIGNAL);
|
||||
+
|
||||
if((ret==-1)||(ret==0))
|
||||
{ /* error or nothing received */
|
||||
disp_msg(ERR_MSG,"copie_fd_to_file","connection closed (1)",NULL);
|
||||
@@ -1298,7 +1312,8 @@ static int start_a_xdownload(WAIT_ACT *a
|
||||
break;
|
||||
|
||||
act->last_touch=time(NULL);
|
||||
- ret=recv(act->sock_fd,buf,amount,MSG_WAITALL|MSG_NOSIGNAL);
|
||||
+ ret=sock_read(act->sock_fd,buf,amount,MSG_WAITALL|MSG_NOSIGNAL);
|
||||
+
|
||||
if((ret==-1)||(ret==0))
|
||||
{ /* error or nothing received */
|
||||
goto end_on_error;
|
||||
@@ -1388,12 +1403,9 @@ static int copie_fd_to_bytearray(int rem
|
||||
|
||||
/* touch the action slot to avoid timeout */
|
||||
act->last_touch=time(NULL);
|
||||
-#if 0
|
||||
- ret=recv(remote,(*ba)->data+pos,nb,MSG_WAITALL|MSG_NOSIGNAL);
|
||||
-#else
|
||||
- ret=recv(remote,(*ba)->data+pos,nb,MSG_NOSIGNAL);
|
||||
+ ret=sock_read(remote,(*ba)->data+pos,nb,MSG_NOSIGNAL /*MSG_NOSIGNAL*/);
|
||||
+
|
||||
printf("%d (nb:%lu, amount: %lu)\n",ret,nb,amount);
|
||||
-#endif
|
||||
|
||||
if((ret==-1)||(ret==0))
|
||||
{ /* error or nothing received */
|
||||
@@ -3109,7 +3121,7 @@ void get_dc_line_and_process(int sck)
|
||||
static int call_counter=0;
|
||||
char tmp[512];
|
||||
|
||||
- sprintf(tmp,"call counter: %d",call_counter++);
|
||||
+ snprintf(tmp, sizeof(tmp), "call counter: %d",call_counter++);
|
||||
|
||||
disp_msg(DEBUG_MSG,"get_dc_lines_until_no_more",tmp,NULL);
|
||||
|
65
net/dctc/patches/patch-src_display_c
Normal file
65
net/dctc/patches/patch-src_display_c
Normal file
@ -0,0 +1,65 @@
|
||||
$OpenBSD: patch-src_display_c,v 1.1.1.1 2002/01/31 12:21:53 naddy Exp $
|
||||
--- src/display.c.orig Sat Jan 5 09:46:07 2002
|
||||
+++ src/display.c Sun Jan 13 17:07:12 2002
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "var.h"
|
||||
|
||||
/* this mutex provides a lock for stdout to avoid display conflict between thread */
|
||||
-G_LOCK_DEFINE_STATIC(stdout);
|
||||
+G_LOCK_DEFINE_STATIC(stdout_lock);
|
||||
|
||||
static FILE *log_fd=NULL;
|
||||
static FILE *errlog_fd=NULL;
|
||||
@@ -121,7 +121,7 @@ void disp_msg(DISP_MSG_TYPE msg_type,con
|
||||
return;
|
||||
|
||||
o_str=g_string_new("");
|
||||
- G_LOCK(stdout);
|
||||
+ G_LOCK(stdout_lock);
|
||||
|
||||
va_start(ap,fnc_name);
|
||||
|
||||
@@ -248,7 +248,7 @@ void disp_msg(DISP_MSG_TYPE msg_type,con
|
||||
va_end(ap);
|
||||
|
||||
fflush(stdout); /* flush stdout before unlocking */
|
||||
- G_UNLOCK(stdout);
|
||||
+ G_UNLOCK(stdout_lock);
|
||||
}
|
||||
|
||||
/***********************************/
|
||||
@@ -259,7 +259,7 @@ void disp_msg(DISP_MSG_TYPE msg_type,con
|
||||
void change_logfile(char *filename)
|
||||
{
|
||||
/* to avoid potential access conflict, we lock the display */
|
||||
- G_LOCK(stdout);
|
||||
+ G_LOCK(stdout_lock);
|
||||
|
||||
/* close the previously existing FILE */
|
||||
if(log_fd!=NULL)
|
||||
@@ -277,7 +277,7 @@ void change_logfile(char *filename)
|
||||
disp_msg(ERR_MSG,"change_logfile",strerror(errno),NULL);
|
||||
}
|
||||
}
|
||||
- G_UNLOCK(stdout);
|
||||
+ G_UNLOCK(stdout_lock);
|
||||
}
|
||||
|
||||
/***************************************/
|
||||
@@ -288,7 +288,7 @@ void change_logfile(char *filename)
|
||||
void change_errlogfile(char *filename)
|
||||
{
|
||||
/* to avoid potential access conflict, we lock the display */
|
||||
- G_LOCK(stdout);
|
||||
+ G_LOCK(stdout_lock);
|
||||
|
||||
/* close the previously existing FILE */
|
||||
if(errlog_fd!=NULL)
|
||||
@@ -306,6 +306,6 @@ void change_errlogfile(char *filename)
|
||||
disp_msg(ERR_MSG,"change_errlogfile",strerror(errno),NULL);
|
||||
}
|
||||
}
|
||||
- G_UNLOCK(stdout);
|
||||
+ G_UNLOCK(stdout_lock);
|
||||
}
|
||||
|
12
net/dctc/patches/patch-src_gdl_c
Normal file
12
net/dctc/patches/patch-src_gdl_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-src_gdl_c,v 1.1.1.1 2002/01/31 12:21:53 naddy Exp $
|
||||
--- src/gdl.c.orig Fri Jan 25 17:37:57 2002
|
||||
+++ src/gdl.c Mon Jan 28 12:12:27 2002
|
||||
@@ -583,7 +583,7 @@ static int append_this_range_entry_to_fi
|
||||
}
|
||||
if(have!=want)
|
||||
{
|
||||
- a=ENODATA; /* set the error message to "no data available */
|
||||
+ a=EIO; /* set the error message to "Input/output error" */
|
||||
break;
|
||||
}
|
||||
|
12
net/dctc/patches/patch-src_gts_c
Normal file
12
net/dctc/patches/patch-src_gts_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-src_gts_c,v 1.1.1.1 2002/01/31 12:21:54 naddy Exp $
|
||||
--- src/gts.c.orig Mon Jan 28 16:52:25 2002
|
||||
+++ src/gts.c Mon Jan 28 16:52:42 2002
|
||||
@@ -431,7 +431,7 @@ void list_gts_content(void)
|
||||
if(mapped_gts[i].slot_status==0) /* empty slot */
|
||||
continue;
|
||||
|
||||
- sprintf(tmp,"%lu|%lu",mapped_gts[i].id,mapped_gts[i].next_try);
|
||||
+ snprintf(tmp, sizeof(tmp), "%lu|%lu",mapped_gts[i].id,mapped_gts[i].next_try);
|
||||
disp_msg(CMD_KB,NULL,tmp,mapped_gts[i].cmd,NULL);
|
||||
}
|
||||
|
160
net/dctc/patches/patch-src_keyboard_c
Normal file
160
net/dctc/patches/patch-src_keyboard_c
Normal file
@ -0,0 +1,160 @@
|
||||
$OpenBSD: patch-src_keyboard_c,v 1.1.1.1 2002/01/31 12:21:54 naddy Exp $
|
||||
--- src/keyboard.c.orig Wed Jan 23 15:06:08 2002
|
||||
+++ src/keyboard.c Mon Jan 28 16:57:20 2002
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sem.h>
|
||||
+#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <glib.h>
|
||||
|
||||
@@ -222,7 +223,7 @@ static void keyb_do_download(const char
|
||||
{ /* we have a full access, the remote side will be able to contact us */
|
||||
char tmp[512];
|
||||
|
||||
- sprintf(tmp,"%s:%hu",host_ip,com_port);
|
||||
+ snprintf(tmp, sizeof(tmp), "%s:%hu",host_ip,com_port);
|
||||
send_dc_line(sck,"$ConnectToMe",nick,tmp,NULL);
|
||||
disp_msg(DEBUG_MSG,"","/DL in $ConnectToMe",NULL);
|
||||
}
|
||||
@@ -310,7 +311,7 @@ static void keyb_do_xdownload(const char
|
||||
{ /* we have a full access, the remote side will be able to contact us */
|
||||
char tmp[512];
|
||||
|
||||
- sprintf(tmp,"%s:%hu",host_ip,com_port);
|
||||
+ snprintf(tmp, sizeof(tmp), "%s:%hu",host_ip,com_port);
|
||||
send_dc_line(sck,"$ConnectToMe",fields[2],tmp,NULL);
|
||||
disp_msg(DEBUG_MSG,"","/XDL in $ConnectToMe",NULL);
|
||||
}
|
||||
@@ -903,7 +904,7 @@ static void keyb_do_xfer(const char *cmd
|
||||
if(nw==NULL)
|
||||
continue;
|
||||
|
||||
- sprintf(tmp,"%lu",(unsigned long)(nw->thread_id));
|
||||
+ snprintf(tmp,sizeof(tmp),"%lu",(unsigned long)(nw->thread_id));
|
||||
if(nw->remote_nick==NULL)
|
||||
{
|
||||
disp_msg(XFER_LST_R,NULL,tmp,"",NULL);
|
||||
@@ -941,7 +942,7 @@ static void keyb_do_xfer(const char *cmd
|
||||
|
||||
nw=&(g_array_index(sim_input,SIM_INPUT,i));
|
||||
|
||||
- sprintf(tmp,"%lu|%lu",nw->id,nw->min_start_time);
|
||||
+ snprintf(tmp,sizeof(tmp),"%lu|%lu",nw->id,nw->min_start_time);
|
||||
disp_msg(CMD_KB,NULL,tmp,nw->keyb_string->str,NULL);
|
||||
}
|
||||
|
||||
@@ -1246,7 +1247,7 @@ static void keyb_do_kill(const char *cmd
|
||||
}
|
||||
|
||||
/* modify our nick name locally */
|
||||
- id=strtoul(t,NULL,10);
|
||||
+ id=(pthread_t)strtoul(t,NULL,10);
|
||||
|
||||
/* to shutdown a thread, it is very easy, we just close the socket it uses */
|
||||
/* thus, it will abort himself, freeing all ressources it allocates */
|
||||
@@ -1628,7 +1629,7 @@ static void keyb_do_ls(const char *cmd,
|
||||
{ /* we have a full access, the remote side will be able to contact us */
|
||||
char tmp[512];
|
||||
|
||||
- sprintf(tmp,"%s:%hu",host_ip,com_port);
|
||||
+ snprintf(tmp, sizeof(tmp), "%s:%hu",host_ip,com_port);
|
||||
send_dc_line(sck,"$ConnectToMe",nick,tmp,NULL);
|
||||
disp_msg(INFO_MSG,"","/LS in $ConnectToMe",NULL);
|
||||
}
|
||||
@@ -2065,25 +2066,25 @@ static void keyb_do_vars(const char *cmd
|
||||
disp_msg(VAR_MSG,NULL,"cnx_type",cnx_type,NULL);
|
||||
disp_msg(VAR_MSG,NULL,"email",email,NULL);
|
||||
|
||||
- sprintf(buf,"%lf",offset_sizeof_data);
|
||||
+ snprintf(buf,sizeof(buf),"%lf",offset_sizeof_data);
|
||||
disp_msg(VAR_MSG,NULL,"offset",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%u",recon_delay);
|
||||
+ snprintf(buf,sizeof(buf),"%u",recon_delay);
|
||||
disp_msg(VAR_MSG,NULL,"recon_delay",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%d",ttl_dl_slot);
|
||||
+ snprintf(buf,sizeof(buf),"%d",ttl_dl_slot);
|
||||
disp_msg(VAR_MSG,NULL,"dl_slot",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%d",dl_on);
|
||||
+ snprintf(buf,sizeof(buf),"%d",dl_on);
|
||||
disp_msg(VAR_MSG,NULL,"dl_on",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%u",auto_rebuild_delay);
|
||||
+ snprintf(buf,sizeof(buf),"%u",auto_rebuild_delay);
|
||||
disp_msg(VAR_MSG,NULL,"auto_rebuild_delay",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%d",behind_fw);
|
||||
+ snprintf(buf,sizeof(buf),"%d",behind_fw);
|
||||
disp_msg(VAR_MSG,NULL,"behind_fw",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%u",com_port);
|
||||
+ snprintf(buf,sizeof(buf),"%u",com_port);
|
||||
disp_msg(VAR_MSG,NULL,"com_port",buf,NULL);
|
||||
|
||||
disp_msg(VAR_MSG,NULL,"hostip",host_ip,NULL);
|
||||
@@ -2099,7 +2100,7 @@ static void keyb_do_vars(const char *cmd
|
||||
/* else, we are connected */
|
||||
if(main_sck>-1)
|
||||
{
|
||||
- sprintf(buf,"%d",main_sck);
|
||||
+ snprintf(buf,sizeof(buf),"%d",main_sck);
|
||||
disp_msg(VAR_MSG,NULL,"main_sck",buf,NULL);
|
||||
}
|
||||
else
|
||||
@@ -2108,12 +2109,12 @@ static void keyb_do_vars(const char *cmd
|
||||
|
||||
if(find_sim_input_delay("/RECON",&s_time))
|
||||
{
|
||||
- sprintf(buf,"=>%ld",s_time);
|
||||
+ snprintf(buf,sizeof(buf),"=>%ld",s_time);
|
||||
disp_msg(VAR_MSG,NULL,"main_sck",buf,NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
- sprintf(buf,"%d",main_sck);
|
||||
+ snprintf(buf,sizeof(buf),"%d",main_sck);
|
||||
disp_msg(VAR_MSG,NULL,"main_sck",buf,NULL);
|
||||
}
|
||||
}
|
||||
@@ -2126,29 +2127,29 @@ static void keyb_do_vars(const char *cmd
|
||||
g_string_free(shared_dir,TRUE);
|
||||
}
|
||||
|
||||
- sprintf(buf,"%d",when_done);
|
||||
+ snprintf(buf,sizeof(buf),"%d",when_done);
|
||||
disp_msg(VAR_MSG,NULL,"when_done",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%d",((int)cnx_opt)&255);
|
||||
+ snprintf(buf,sizeof(buf),"%d",((int)cnx_opt)&255);
|
||||
disp_msg(VAR_MSG,NULL,"cnx_opt",buf,NULL);
|
||||
UNLOCK_READ(user_info);
|
||||
|
||||
- sprintf(buf,"%d",semctl(bl_semid,2,GETVAL));
|
||||
+ snprintf(buf,sizeof(buf),"%d",semctl(bl_semid,2,GETVAL));
|
||||
disp_msg(VAR_MSG,NULL,"ubl",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%u",wanna_emode);
|
||||
+ snprintf(buf,sizeof(buf),"%u",wanna_emode);
|
||||
disp_msg(VAR_MSG,NULL,"wanted_emode",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%u",having_emode);
|
||||
+ snprintf(buf,sizeof(buf),"%u",having_emode);
|
||||
disp_msg(VAR_MSG,NULL,"current_emode",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%d",follow_force_move);
|
||||
+ snprintf(buf,sizeof(buf),"%d",follow_force_move);
|
||||
disp_msg(VAR_MSG,NULL,"follow_force_move",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%d",with_md5sum);
|
||||
+ snprintf(buf,sizeof(buf),"%d",with_md5sum);
|
||||
disp_msg(VAR_MSG,NULL,"with_md5sum",buf,NULL);
|
||||
|
||||
- sprintf(buf,"%d",with_ddl);
|
||||
+ snprintf(buf,sizeof(buf),"%d",with_ddl);
|
||||
disp_msg(VAR_MSG,NULL,"with_ddl",buf,NULL);
|
||||
|
||||
display_cnx_status();
|
112
net/dctc/patches/patch-src_main_c
Normal file
112
net/dctc/patches/patch-src_main_c
Normal file
@ -0,0 +1,112 @@
|
||||
$OpenBSD: patch-src_main_c,v 1.1.1.1 2002/01/31 12:21:53 naddy Exp $
|
||||
--- src/main.c.orig Tue Jan 22 14:47:39 2002
|
||||
+++ src/main.c Mon Jan 28 17:05:52 2002
|
||||
@@ -34,9 +34,16 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/un.h>
|
||||
-#include <linux/sem.h> /* for the value of SEMVMX */
|
||||
+
|
||||
+#ifdef HAVE_LINUX_SEM_H
|
||||
+# include <linux/sem.h> /* for the value of SEMVMX */
|
||||
+#endif
|
||||
+
|
||||
+#ifdef HAVE_GETOPT_H
|
||||
+# include <getopt.h>
|
||||
+#endif
|
||||
+
|
||||
#include <errno.h>
|
||||
-#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <pthread.h>
|
||||
@@ -204,7 +211,7 @@ void display_cnx_status(void)
|
||||
if(cnx_in_progress==0)
|
||||
val+=2;
|
||||
|
||||
- sprintf(buf,"%d",val);
|
||||
+ snprintf(buf,sizeof(buf),"%d",val);
|
||||
disp_msg(VAR_MSG,NULL,"cnx_status",buf,NULL);
|
||||
}
|
||||
|
||||
@@ -247,14 +254,14 @@ void hub_disconnect(HUBDISC_FLAG exit_fl
|
||||
disp_msg(INFO_MSG,"hub_disconnect","have xfer ?",NULL);
|
||||
G_LOCK(waiting_action);
|
||||
|
||||
- sprintf(tmp,"%d xfer",waiting_action->len);
|
||||
+ snprintf(tmp,sizeof(tmp),"%d xfer",waiting_action->len);
|
||||
disp_msg(INFO_MSG,NULL,tmp,NULL);
|
||||
while(waiting_action->len!=0) /* all thread done ? */
|
||||
{
|
||||
G_UNLOCK(waiting_action);
|
||||
sleep(1);
|
||||
G_LOCK(waiting_action);
|
||||
- sprintf(tmp,"%d xfer",waiting_action->len);
|
||||
+ snprintf(tmp,sizeof(tmp),"%d xfer",waiting_action->len);
|
||||
disp_msg(INFO_MSG,NULL,tmp,NULL);
|
||||
|
||||
if(user_wants_to_quit) /* wait except if the user wants to leave now */
|
||||
@@ -937,6 +944,10 @@ static void display_usage(char *fname)
|
||||
"Be careful, most of the information you provide can't contain the following\n"
|
||||
"characters because Direct Connect uses them internally: | $\n"
|
||||
,fname,dc_version);
|
||||
+
|
||||
+#ifndef HAVE_GETOPT_LONG
|
||||
+ fprintf(stderr,"\nNOTE: Long options are not available on this platform\n");
|
||||
+#endif
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
@@ -1061,7 +1072,9 @@ static void start_rebuild_db_thread(void
|
||||
/* beginning of the code */
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
- static struct option optab[]= {
|
||||
+#ifdef HAVE_GETOPT_LONG
|
||||
+
|
||||
+ static struct option optab[]= {
|
||||
{"help",no_argument,NULL,'h'}, /* get help */
|
||||
{"nick",required_argument,NULL,'n'}, /* nickname */
|
||||
{"info",required_argument,NULL,'i'}, /* user description */
|
||||
@@ -1085,7 +1098,9 @@ int main(int argc,char **argv)
|
||||
{"nomd5sum",no_argument,NULL,'5'}, /* don't compute md5 sum for each file of the database */
|
||||
{NULL,0,NULL,'\0'} /* last option */
|
||||
};
|
||||
- static const char *short_opt="hn:i:c:e:d:s:o:a:p:g:fxwtlv:u:m:b:5";
|
||||
+#endif
|
||||
+
|
||||
+ static const char *short_opt="hn:i:c:e:d:s:o:a:p:g:fxwtlv:u:m:b:5";
|
||||
|
||||
int ch;
|
||||
int detach_from_tty=0;
|
||||
@@ -1129,7 +1144,11 @@ int main(int argc,char **argv)
|
||||
pre_gsc=g_string_chunk_new(128);
|
||||
pre_gpa=g_ptr_array_new();
|
||||
|
||||
+#ifdef HAVE_GETOPT_LONG
|
||||
while((ch=getopt_long(argc,argv,short_opt,optab,NULL))!=EOF)
|
||||
+#else
|
||||
+ while((ch=getopt(argc,argv,short_opt))!= -1)
|
||||
+#endif
|
||||
{
|
||||
switch(ch)
|
||||
{
|
||||
@@ -1448,7 +1467,8 @@ int main(int argc,char **argv)
|
||||
struct sockaddr_un name;
|
||||
|
||||
name.sun_family=AF_UNIX;
|
||||
- strcpy(name.sun_path,local_dctc_sock_path->str);
|
||||
+ strncpy(name.sun_path,local_dctc_sock_path->str,sizeof(name.sun_path) - 1);
|
||||
+ name.sun_path[sizeof(name.sun_path) - 1] = 0x0;
|
||||
if(bind(local_sck,(void *)&name,sizeof(struct sockaddr_un)))
|
||||
{
|
||||
perror("local_sck - bind");
|
||||
@@ -1502,7 +1522,7 @@ int main(int argc,char **argv)
|
||||
if(p!=NULL)
|
||||
{
|
||||
char tmp_str[512];
|
||||
- sprintf(tmp_str,"%.2f",cur_pos);
|
||||
+ snprintf(tmp_str,sizeof(tmp_str),"%.2f",cur_pos);
|
||||
disp_msg(PROGRESS_BAR,"","init_share",tmp_str,"Initialize shared file database",p,NULL);
|
||||
add_shared_directory(p);
|
||||
}
|
12
net/dctc/patches/patch-src_md_c
Normal file
12
net/dctc/patches/patch-src_md_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-src_md_c,v 1.1.1.1 2002/01/31 12:21:54 naddy Exp $
|
||||
--- src/md.c.orig Mon Jan 28 17:00:06 2002
|
||||
+++ src/md.c Mon Jan 28 17:00:51 2002
|
||||
@@ -222,7 +222,7 @@ void md5tostr(const unsigned char md5sum
|
||||
for(i=0;i<MD5SUMLEN;i++)
|
||||
{
|
||||
unsigned int v=md5sum[i];
|
||||
- sprintf(str+3*i,"%1u%1u%1u",v/100,(v%100)/10,v%10);
|
||||
+ snprintf(str+3*i,sizeof(str),"%1u%1u%1u",v/100,(v%100)/10,v%10);
|
||||
}
|
||||
}
|
||||
|
24
net/dctc/patches/patch-src_network_c
Normal file
24
net/dctc/patches/patch-src_network_c
Normal file
@ -0,0 +1,24 @@
|
||||
$OpenBSD: patch-src_network_c,v 1.1.1.1 2002/01/31 12:21:53 naddy Exp $
|
||||
--- src/network.c.orig Sun Jan 13 17:10:07 2002
|
||||
+++ src/network.c Sun Jan 13 17:12:42 2002
|
||||
@@ -231,11 +231,17 @@ GString *get_default_host_ip(void)
|
||||
char buf[512];
|
||||
|
||||
/* the following script does this: */
|
||||
- /* 1) extract the interface used by the default route: netstat -rn | grep ^0.0.0.0 | awk '{print $8;} */
|
||||
- /* 2) obtain the IP of this interface: netstat xxx | fgrep inet | cut -d : -f 2 | awk '{print $1;}' */
|
||||
+ /* 1) extract the interface used by the default route from netstat */
|
||||
+ /* 2) obtain the IP of this interface from ifconfig */
|
||||
+
|
||||
+#ifdef __OpenBSD__
|
||||
+ const char *cmd=
|
||||
+ "/sbin/ifconfig `netstat -rn | grep ^default | awk '{print $7;}'` | fgrep 'inet ' | awk '{print $2;}'";
|
||||
+#else
|
||||
const char *cmd=
|
||||
"/sbin/ifconfig `netstat -rn | grep ^0.0.0.0 | awk '{print $8;}'` | fgrep inet | cut -d : -f 2 | awk '{print $1;}'";
|
||||
-
|
||||
+#endif
|
||||
+
|
||||
f=popen(cmd,"r");
|
||||
if(f==NULL)
|
||||
{
|
12
net/dctc/patches/patch-src_sema_c
Normal file
12
net/dctc/patches/patch-src_sema_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-src_sema_c,v 1.1.1.1 2002/01/31 12:21:53 naddy Exp $
|
||||
--- src/sema.c.orig Sat Jan 12 18:05:46 2002
|
||||
+++ src/sema.c Sun Jan 13 16:45:12 2002
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "sema.h"
|
||||
|
||||
-#if !(defined(BSD) && (BSD >= 199103))
|
||||
+#if !(defined(BSD) && (BSD >= 199103)) && !defined(__OpenBSD__)
|
||||
#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
|
||||
/* union semun is defined by including <sys/sem.h> */
|
||||
#else
|
12
net/dctc/patches/patch-src_uaddr_c
Normal file
12
net/dctc/patches/patch-src_uaddr_c
Normal file
@ -0,0 +1,12 @@
|
||||
$OpenBSD: patch-src_uaddr_c,v 1.1.1.1 2002/01/31 12:21:53 naddy Exp $
|
||||
--- src/uaddr.c.orig Mon Jan 28 17:01:03 2002
|
||||
+++ src/uaddr.c Mon Jan 28 17:01:19 2002
|
||||
@@ -768,7 +768,7 @@ void list_uaddr_content(void)
|
||||
if(mapped_uaddr[i].slot_status==0) /* empty slot */
|
||||
continue;
|
||||
|
||||
- sprintf(tmp,"%lu",mapped_uaddr[i].register_time);
|
||||
+ snprintf(tmp,sizeof(tmp),"%lu",mapped_uaddr[i].register_time);
|
||||
disp_msg(CMD_KB,NULL,tmp,mapped_uaddr[i].dl_addr,NULL);
|
||||
}
|
||||
|
5
net/dctc/pkg/DESCR
Normal file
5
net/dctc/pkg/DESCR
Normal file
@ -0,0 +1,5 @@
|
||||
DCTC is a Direct Connect clone, allowing users to share their files
|
||||
and talk (like IRC but more software sharing oriented) using a
|
||||
proprietary protocol.
|
||||
|
||||
WWW: ${HOMEPAGE}
|
12
net/dctc/pkg/PLIST
Normal file
12
net/dctc/pkg/PLIST
Normal file
@ -0,0 +1,12 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2002/01/31 12:21:54 naddy Exp $
|
||||
bin/dctc
|
||||
bin/hublist
|
||||
share/doc/dctc/DCextensions/p2p_capabilities
|
||||
share/doc/dctc/DCextensions/search_by_content
|
||||
share/doc/dctc/GDL
|
||||
share/doc/dctc/VAR
|
||||
share/doc/dctc/commands
|
||||
share/doc/dctc/output
|
||||
share/doc/dctc/programs
|
||||
@dirrm share/doc/dctc/DCextensions
|
||||
@dirrm share/doc/dctc
|
4
net/dctc/pkg/SECURITY
Normal file
4
net/dctc/pkg/SECURITY
Normal file
@ -0,0 +1,4 @@
|
||||
This package used sprintf and strcpy in various places, they were
|
||||
all replaced with the safe counterparts snprintf and strncpy.
|
||||
dctc does not require any privileges and should not be run as root,
|
||||
just specify another port to listen on instead of the default (412).
|
Loading…
Reference in New Issue
Block a user