Permalink
Browse files

Backport fixes from openSUSE (pbleser)

  • Loading branch information...
1 parent d88f242 commit ac2ac2cf2d17b133f72c1763cff3c9b5b012ba6a ec429 committed Jul 5, 2011
Showing with 21 additions and 17 deletions.
  1. +4 −3 config.c
  2. +1 −1 config.h
  3. +1 −2 input.c
  4. +9 −10 irc.c
  5. +6 −1 quirc.c
View
7 config.c
@@ -22,10 +22,11 @@ int def_config(void)
portno=strdup("6667");
char *eu=getenv("USER");
username=strdup(eu?eu:"quirc");
- fname=(char *)malloc(64+strlen(VERSION_TXT));
+ fname=malloc(64+strlen(VERSION_TXT));
nick=strdup(eu?eu:"ac");
- sprintf(fname, "quIRC %hhu.%hhu.%hhu%s%s : http://github.com/ec429/quIRC", VERSION_MAJ, VERSION_MIN, VERSION_REV, VERSION_TXT[0]?"-":"", VERSION_TXT);
- sprintf(version, "%hhu.%hhu.%hhu%s%s", VERSION_MAJ, VERSION_MIN, VERSION_REV, VERSION_TXT[0]?"-":"", VERSION_TXT);
+ snprintf(fname, 64+strlen(VERSION_TXT), "quIRC %hhu.%hhu.%hhu%s%s : http://github.com/ec429/quIRC", VERSION_MAJ, VERSION_MIN, VERSION_REV, VERSION_TXT[0]?"-":"", VERSION_TXT);
+ version=malloc(16+strlen(VERSION_TXT));
+ snprintf(version, 16+strlen(VERSION_TXT), "%hhu.%hhu.%hhu%s%s", VERSION_MAJ, VERSION_MIN, VERSION_REV, VERSION_TXT[0]?"-":"", VERSION_TXT);
return(0);
}
View
2 config.h
@@ -46,7 +46,7 @@ bool autojoin;
char *username, *fname, *nick, *portno;
servlist *servs;
name *igns;
-char version[16+strlen(VERSION_TXT)];
+char *version;
int conf_check(void); // writes diagnostics to start-buffer
int def_config(void); // set these to their defaults
View
3 input.c
@@ -63,8 +63,7 @@ int inputchar(iline *inp, int *state)
sp--;
name *curr=bufs[cbuf].nlist;
name *found=NULL;
- int count=0;
- int mlen;
+ int count=0, mlen=0;
while(curr)
{
if((inp->left.i==sp) || (irc_strncasecmp(inp->left.data+sp, curr->data, inp->left.i-sp, bufs[cbuf].casemapping)==0))
View
19 irc.c
@@ -16,37 +16,36 @@ void handle_sigpipe(int sig)
int irc_connect(char *server, char *portno, fd_set *master, int *fdmax)
{
- int serverhandle;
+ int serverhandle=0;
struct addrinfo hints, *servinfo;
// Look up server
memset(&hints, 0, sizeof(hints));
hints.ai_family=AF_INET;
hints.ai_socktype = SOCK_STREAM; // TCP stream sockets
int rv;
- if((rv = getaddrinfo(server, portno, &hints, &servinfo)) != 0)
+ if((rv=getaddrinfo(server, portno, &hints, &servinfo))!=0)
{
- char *err=(char *)gai_strerror(rv);
- add_to_buffer(0, c_err, err, "getaddrinfo: ");
+ add_to_buffer(0, c_err, (char *)gai_strerror(rv), "getaddrinfo: ");
return(0); // 0 indicates failure as rv is new serverhandle value
}
char sip[INET_ADDRSTRLEN];
struct addrinfo *p;
// loop through all the results and connect to the first we can
- for(p = servinfo; p != NULL; p = p->ai_next)
+ for(p=servinfo;p;p=p->ai_next)
{
inet_ntop(p->ai_family, &(((struct sockaddr_in*)p->ai_addr)->sin_addr), sip, sizeof(sip));
- if((serverhandle = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1)
+ if((serverhandle=socket(p->ai_family, p->ai_socktype, p->ai_protocol))==-1)
{
add_to_buffer(0, c_err, strerror(errno), "socket: ");
continue;
}
- if(fcntl(serverhandle, F_SETFD, O_NONBLOCK) == -1)
+ if(fcntl(serverhandle, F_SETFD, O_NONBLOCK)==-1)
{
close(serverhandle);
add_to_buffer(0, c_err, strerror(errno), "fcntl: ");
continue;
}
- if(connect(serverhandle, p->ai_addr, p->ai_addrlen) == -1)
+ if(connect(serverhandle, p->ai_addr, p->ai_addrlen)==-1)
{
if(errno!=EINPROGRESS)
{
@@ -63,12 +62,12 @@ int irc_connect(char *server, char *portno, fd_set *master, int *fdmax)
sprintf(cmsg, "fd=%d, ip=%s", serverhandle, sip);
add_to_buffer(0, c_status, cmsg, "DBG connect: ");
}
- if (p == NULL)
+ if(!p)
{
add_to_buffer(0, c_err, "failed to connect to server", "/connect: ");
return(0); // 0 indicates failure as rv is new serverhandle value
}
- freeaddrinfo(servinfo); // don't need this any more
+ freeaddrinfo(servinfo);
FD_SET(serverhandle, master);
*fdmax=max(*fdmax, serverhandle);
View
7 quirc.c
@@ -74,7 +74,12 @@ int main(int argc, char *argv[])
if(qfld)
{
sprintf(qfld, "%s/.quirc", home);
- chdir(qfld);
+ if(chdir(qfld))
+ {
+ fprintf(stderr, "Failed to change directory into %s: %s", qfld, strerror(errno));
+ push_buffer();
+ return(1);
+ }
free(qfld);
}
else

0 comments on commit ac2ac2c

Please sign in to comment.