-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hey!

 licq outputs all errors to stdout instead of stderr. This isn't what one 
expects (errors goes to stderr). Also if you try to redirect (-o switch) 
output using the console plugin, you will see that the plugin prints its 
screen to the file instead of stdout.

the boring patches attached fix this issue.

- -- 
Buenos Aires, Argentina
-----BEGIN PGP SIGNATURE-----

iD8DBQE9sJI1UMlRieHkprgRAhoWAJwMp0WKCA4+kYPIQBqQ9Ej3jCK5jACgukPn
zNT3xYFId9RRM36RV559W2c=
=8AuY
-----END PGP SIGNATURE-----
Index: include/licq_log.h
===================================================================
RCS file: /cvsroot/licq/licq/include/licq_log.h,v
retrieving revision 1.7
diff -u -d -p -r1.7 licq_log.h
--- include/licq_log.h	11 Sep 2002 18:14:16 -0000	1.7
+++ include/licq_log.h	18 Oct 2002 21:54:12 -0000
@@ -39,10 +39,10 @@ const char L_ENDxSTR[]     = "[END] ";
 const char L_FIFOxSTR[]    = "[FIF] ";
 const char L_SSLxSTR[]     = "[SSL] ";
 
-const unsigned short S_STDOUT   = 1;
+const unsigned short S_STDERR   = 1;
 const unsigned short S_FILE     = 2;
 const unsigned short S_PLUGIN   = 4;
-const unsigned short S_ALL	= S_STDOUT | S_FILE | S_PLUGIN;
+const unsigned short S_ALL	= S_STDERR | S_FILE | S_PLUGIN;
 
 const unsigned short LOG_PREFIX_OFFSET = 10;
 
@@ -76,11 +76,11 @@ protected:
 };
 
 
-//-----StdOut-------------------------------------------------------------------
-class CLogService_StdOut : public CLogService
+//-----StdErr-------------------------------------------------------------------
+class CLogService_StdErr : public CLogService
 {
 public:
-  CLogService_StdOut(unsigned short _nLogTypes, bool _bUseColor);
+  CLogService_StdErr(unsigned short _nLogTypes, bool _bUseColor);
   virtual void LogMessage(const char *_szPrefix, const char *_szMessage, 
 			  unsigned short _nLogType);
 protected:
Index: plugins/qt-gui/src/mainwin.cpp
===================================================================
RCS file: /cvsroot/licq/qt-gui/src/mainwin.cpp,v
retrieving revision 1.246
diff -u -d -p -r1.246 mainwin.cpp
--- plugins/qt-gui/src/mainwin.cpp	16 Oct 2002 06:10:28 -0000	1.246
+++ plugins/qt-gui/src/mainwin.cpp	18 Oct 2002 21:54:14 -0000
@@ -2552,7 +2552,7 @@ void CMainWindow::changeDebug(int _nId)
   int nLevel = mnuDebug->indexOf(_nId);
   if (nLevel == MNUxITEM_DEBUGxALL)
   {
-    gLog.ModifyService(S_STDOUT, L_ALL);
+    gLog.ModifyService(S_STDERR, L_ALL);
     for (int i = 0; i < 5; i++)
       mnuDebug->setItemChecked(mnuDebug->idAt(i), true);
     return;
@@ -2560,7 +2560,7 @@ void CMainWindow::changeDebug(int _nId)
 
   if (nLevel == MNUxITEM_DEBUGxNONE)
   {
-    gLog.ModifyService(S_STDOUT, L_NONE);
+    gLog.ModifyService(S_STDERR, L_NONE);
     for (int i = 0; i < 5; i++)
       mnuDebug->setItemChecked(mnuDebug->idAt(i), false);
     return;
@@ -2569,12 +2569,12 @@ void CMainWindow::changeDebug(int _nId)
   // First see if we are setting on or off the value
   if (mnuDebug->isItemChecked(_nId))
   {
-    gLog.RemoveLogTypeFromService(S_STDOUT, 1 << nLevel);
+    gLog.RemoveLogTypeFromService(S_STDERR, 1 << nLevel);
     mnuDebug->setItemChecked(_nId, false);
   }
   else
   {
-    gLog.AddLogTypeToService(S_STDOUT, 1 << nLevel);
+    gLog.AddLogTypeToService(S_STDERR, 1 << nLevel);
     mnuDebug->setItemChecked(_nId, true);
   }
 }
Index: src/fifo.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/fifo.cpp,v
retrieving revision 1.3
diff -u -d -p -r1.3 fifo.cpp
--- src/fifo.cpp	21 Sep 2002 14:28:54 -0000	1.3
+++ src/fifo.cpp	18 Oct 2002 21:54:14 -0000
@@ -69,7 +69,7 @@ static const char* const HELP_URL = 
 	"\t\tSend a url to the given buddy.\n";
 static const char* const HELP_REDIRECT = 
 	"\tredirect <file>\n"
-	"\t\tRedirects the stdout and stderr for\n"
+	"\t\tRedirects the stderr for\n"
 	"\t\tlicq to the given file\n";
 static const char* const HELP_DEBUGLVL = 
 	"\tdebuglvl <level>\n"
@@ -316,7 +316,7 @@ fifo_debuglvl ( int argc, const char *co
 	if( (nRet = (argc == 1)) )
 		ReportMissingParams(argv[0]);
 	else
-		gLog.ModifyService( S_STDOUT, atoi(argv[1]));
+		gLog.ModifyService( S_STDERR, atoi(argv[1]));
 
 	return -nRet;
 }
Index: src/icqd-srv.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqd-srv.cpp,v
retrieving revision 1.70
diff -u -d -p -r1.70 icqd-srv.cpp
--- src/icqd-srv.cpp	6 Oct 2002 05:52:56 -0000	1.70
+++ src/icqd-srv.cpp	18 Oct 2002 21:54:16 -0000
@@ -3991,7 +3991,7 @@ bool CICQDaemon::ProcessCloseChannel(CBu
 {
   int nSD = m_nTCPSrvSocketDesc;
   if (nSD < 0) {
-    printf("nsd <0 !\n");
+    fprintf(stderr,"nsd <0 !\n");
   }
   else {
     m_nTCPSrvSocketDesc = -1;
Index: src/icqd-tcp.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqd-tcp.cpp,v
retrieving revision 1.44
diff -u -d -p -r1.44 icqd-tcp.cpp
--- src/icqd-tcp.cpp	18 Oct 2002 04:36:09 -0000	1.44
+++ src/icqd-tcp.cpp	18 Oct 2002 21:54:17 -0000
@@ -1221,7 +1221,7 @@ bool CICQDaemon::ProcessTcpPacket(TCPSoc
          && u->StatusToUser() != ICQ_STATUS_DND) )
     bAccept = true;
 
-  //printf("status: %04X (%04X)  msgtype: %04X\n", ackFlags, u->Status(), msgFlags);
+  //fprintf(stderr,"status: %04X (%04X)  msgtype: %04X\n", ackFlags, u->Status(), msgFlags);
 
   switch(command)
   {
@@ -1258,7 +1258,7 @@ bool CICQDaemon::ProcessTcpPacket(TCPSoc
         gLog.Warn("%sUnknown TCP status: %04X\n", L_WARNxSTR, msgFlags);
         break;
     }
-    //printf("%08lX\n", (u->StatusFull() & ICQ_STATUS_FxFLAGS) | ns);
+    //fprintf(stderr,"%08lX\n", (u->StatusFull() & ICQ_STATUS_FxFLAGS) | ns);
     /*if (!bNewUser && ns != ICQ_STATUS_OFFLINE &&
         !((ns & ICQ_STATUS_FxPRIVATE) && u->StatusOffline()))*/
     if (!bNewUser && ns != ICQ_STATUS_OFFLINE &&
Index: src/icqd-udp.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqd-udp.cpp,v
retrieving revision 1.33
diff -u -d -p -r1.33 icqd-udp.cpp
--- src/icqd-udp.cpp	15 Jul 2002 04:46:12 -0000	1.33
+++ src/icqd-udp.cpp	18 Oct 2002 21:54:18 -0000
@@ -894,10 +894,10 @@ unsigned short CICQDaemon::ProcessUdpPac
         while (!packet.End())
         {
           packet >> c1;
-          printf("%02X", c1);
+          fprintf(stderr,"%02X", c1);
           i++;
-          if (i % 4 == 0) printf(" | ");
-          if (i % 28 == 0) printf("\n");
+          if (i % 4 == 0) fprintf(" | ");
+          if (i % 28 == 0) fprintf("\n");
         }
       }
       else
@@ -906,13 +906,13 @@ unsigned short CICQDaemon::ProcessUdpPac
         for (unsigned short i = 46; i < bMultiPacket; i++)
         {
           packet >> c1;
-          printf("%02X", c1);
+          fprintf(stderr,"%02X", c1);
           j++;
-          if (j % 4 == 0) printf(" | ");
-          if (j % 28 == 0) { printf("\n"); }
+          if (j % 4 == 0) fprintf(stderr," | ");
+          if (j % 28 == 0) { fprintf(stderr,"\n"); }
         }
       }
-      printf("\n");
+      fprintf(stderr,"\n");
       */
       break;
     }
Index: src/icqpacket.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqpacket.cpp,v
retrieving revision 1.67
diff -u -d -p -r1.67 icqpacket.cpp
--- src/icqpacket.cpp	18 Oct 2002 04:36:09 -0000	1.67
+++ src/icqpacket.cpp	18 Oct 2002 21:54:20 -0000
@@ -44,7 +44,7 @@ unsigned short LengthField(const char *s
 }
 
 #define DEBUG_ENCRYPTION(x)
-//#define DEBUG_ENCRYPTION(x) printf x
+//#define DEBUG_ENCRYPTION(x) fprintf(stderr, x)
 
 #if ICQ_VERSION == 4
 static unsigned char icq_check_data[256] = {
@@ -148,7 +148,7 @@ void Encrypt_Server(CBuffer *buffer)
   chk2 ^= 0x00FF00FF;
   nCheckSum = chk1 ^ chk2;
   unsigned long key = l * 0x66756b65 + nCheckSum;
-  //printf("key: 0x%08x\n", key);
+  //fprintf(stderr,"key: 0x%08x\n", key);
 
   unsigned long k = 0;
   unsigned short n = (l + 3) >> 2;
Index: src/licq.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/licq.cpp,v
retrieving revision 1.59
diff -u -d -p -r1.59 licq.cpp
--- src/licq.cpp	15 Oct 2002 18:05:40 -0000	1.59
+++ src/licq.cpp	18 Oct 2002 21:54:21 -0000
@@ -201,7 +201,7 @@ bool CLicq::Init(int argc, char **argv)
         vszPlugins.push_back(strdup(optarg));
         bCmdLinePlugins = true;
         break;
-      case 'o':  // redirect stdout and stderr
+      case 'o':  // redirect stderr
         szRedirect = strdup(optarg);
         break;
       case 'f':  // fork
@@ -223,14 +223,14 @@ bool CLicq::Init(int argc, char **argv)
   if (szRedirect)
     bRedirect_ok = Redirect(szRedirect);
 
-  if(!isatty(STDOUT_FILENO))
+  if(!isatty(STDERR_FILENO))
     bUseColor = false;
 
   // Initialise the log server for standard output and dump all initial errors
   // and warnings to it regardless of DEBUG_LEVEL
-  gLog.AddService(new CLogService_StdOut(DEBUG_LEVEL | L_ERROR | L_WARN, bUseColor));
+  gLog.AddService(new CLogService_StdErr(DEBUG_LEVEL | L_ERROR | L_WARN, bUseColor));
 
-  // Redirect stdout and stderr if asked to
+  // Redirect stderr if asked to
   if (szRedirect) {
     if (bRedirect_ok)
       gLog.Info("%sOutput redirected to \"%s\".\n", L_INITxSTR, szRedirect);
@@ -675,7 +675,7 @@ int CLicq::Main()
     StartPlugin(*iter);
   }
 
-  gLog.ModifyService(S_STDOUT, DEBUG_LEVEL);
+  gLog.ModifyService(S_STDERR, DEBUG_LEVEL);
 
   unsigned short nExitId;
   int *nPluginResult;
@@ -764,7 +764,7 @@ void CLicq::PrintUsage()
          " -b : set the base directory for the config and data files (~/.licq by default)\n"
          " -I : force initialization of the given base directory\n"
          " -p : load the given plugin library\n"
-         " -o : redirect stdout and stderr to <file>, which can be a device (ie /dev/ttyp4)\n",
+         " -o : redirect stderr to <file>, which can be a device (ie /dev/ttyp4)\n",
          PACKAGE, VERSION);
 }
 
@@ -817,19 +817,19 @@ bool CLicq::Install()
   // Create the directory if necessary
   if (mkdir(BASE_DIR, 0700) == -1 && errno != EEXIST)
   {
-    printf("Couldn't mkdir %s: %s\n", BASE_DIR, strerror(errno));
+    fprintf(stderr,"Couldn't mkdir %s: %s\n", BASE_DIR, strerror(errno));
     return (false);
   }
   snprintf(cmd, sizeof(cmd) - 1, "%s/%s", BASE_DIR, HISTORY_DIR);
   if (mkdir(cmd, 0700) == -1 && errno != EEXIST)
   {
-    printf("Couldn't mkdir %s: %s\n", cmd, strerror(errno));
+    fprintf(stderr,"Couldn't mkdir %s: %s\n", cmd, strerror(errno));
     return (false);
   }
   snprintf(cmd, sizeof(cmd) - 1, "%s/%s", BASE_DIR, USER_DIR);
   if (mkdir(cmd, 0700) == -1 && errno != EEXIST)
   {
-    printf("Couldn't mkdir %s: %s\n", cmd, strerror(errno));
+    fprintf(stderr,"Couldn't mkdir %s: %s\n", cmd, strerror(errno));
     return (false);
   }
 
Index: src/log.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/log.cpp,v
retrieving revision 1.10
diff -u -d -p -r1.10 log.cpp
--- src/log.cpp	27 Sep 2002 21:49:47 -0000	1.10
+++ src/log.cpp	18 Oct 2002 21:54:21 -0000
@@ -88,26 +88,26 @@ void CLogService::RemoveLogType(unsigned
 
 
 
-//-----StdOut-------------------------------------------------------------------
-CLogService_StdOut::CLogService_StdOut(unsigned short _nLogTypes, bool _bUseColor)
+//-----StdErr-------------------------------------------------------------------
+CLogService_StdErr::CLogService_StdErr(unsigned short _nLogTypes, bool _bUseColor)
    : CLogService(_nLogTypes)
 {
-  m_nServiceType = S_STDOUT;
+  m_nServiceType = S_STDERR;
   m_bUseColor = _bUseColor;
 }
 
 
-void CLogService_StdOut::LogMessage(const char *_szPrefix, 
+void CLogService_StdErr::LogMessage(const char *_szPrefix, 
 				    const char *_szMessage,
 				    const unsigned short _nLogType)
 {
   if (m_bUseColor)
-    printf("%s%s%s", COLOR_PREFIX, _szPrefix, COLOR_MSG[_nLogType == L_MESSAGE ? L_INFO : _nLogType]);
+    fprintf(stderr,"%s%s%s", COLOR_PREFIX, _szPrefix, COLOR_MSG[_nLogType == L_MESSAGE ? L_INFO : _nLogType]);
   else
-    printf("%s", _szPrefix);
-  printf("%s", _szMessage);
-  if (m_bUseColor) printf("%s", COLOR_NORMAL);
-  fflush(stdout);
+    fprintf(stderr,"%s", _szPrefix);
+  fprintf(stderr,"%s", _szMessage);
+  if (m_bUseColor) fprintf(stderr,"%s", COLOR_NORMAL);
+  fflush(stderr);
 }
 
 
Index: src/support.c
===================================================================
RCS file: /cvsroot/licq/licq/src/support.c,v
retrieving revision 1.7
diff -u -d -p -r1.7 support.c
--- src/support.c	27 Sep 2002 21:50:40 -0000	1.7
+++ src/support.c	18 Oct 2002 21:54:21 -0000
@@ -108,7 +108,6 @@ int Redirect(const char *_szFile)
 {
   int fd = open(_szFile, O_WRONLY | O_CREAT | O_APPEND, 00660);
   if (fd == -1) return 0;
-  if (dup2(fd, STDOUT_FILENO) == -1) return 0;
   if (dup2(fd, STDERR_FILENO) == -1) return 0;
   return 1;
 }
Index: src/console.cpp
===================================================================
RCS file: /cvsroot/licq/console/src/console.cpp,v
retrieving revision 1.74
diff -u -d -p -r1.74 console.cpp
--- src/console.cpp	9 Sep 2002 23:11:37 -0000	1.74
+++ src/console.cpp	18 Oct 2002 21:54:53 -0000
@@ -267,10 +267,10 @@ int CLicqConsole::Run(CICQDaemon *_licqD
 
   log = new CPluginLog;
   unsigned long lt = L_MOST;
-  if (gLog.ServiceLogTypes(S_STDOUT) & L_PACKET)
+  if (gLog.ServiceLogTypes(S_STDERR) & L_PACKET)
     lt |= L_PACKET;
   gLog.AddService(new CLogService_Plugin(log, lt));
-  gLog.ModifyService(S_STDOUT, L_NONE);
+  gLog.ModifyService(S_STDERR, L_NONE);
 
   winMain = winCon[1];
   winLog = winCon[0];

Reply via email to