f67f6898c6
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.
113 lines
3.7 KiB
Plaintext
113 lines
3.7 KiB
Plaintext
$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);
|
|
}
|