Ejemplo n.º 1
0
BOOL Subsets_fMonitorServer (LPSUBSET sub, LPIDENT lpiServer)
{
   BOOL fMonitor = TRUE;

   TCHAR szLong[ cchNAME ];
   TCHAR szShort[ cchNAME ];
   lpiServer->GetLongServerName (szLong);
   lpiServer->GetShortServerName (szShort);

   if (sub)
      {
      if (sub->pszMonitored)
         {
         fMonitor = FALSE;  // unless it shows up here.

         for (LPTSTR psz = sub->pszMonitored; !fMonitor && *psz; psz += 1+lstrlen(psz))
            {
            if (!lstrcmpi (psz, szLong))
               fMonitor = TRUE;
            else if (!lstrcmpi (psz, szShort))
               fMonitor = TRUE;
            }
         }
      else if (sub->pszUnmonitored)
         {
         for (LPTSTR psz = sub->pszUnmonitored; fMonitor && *psz; psz += 1+lstrlen(psz))
            {
            if (!lstrcmpi (psz, szLong))
               fMonitor = FALSE;
            else if (!lstrcmpi (psz, szShort))
               fMonitor = FALSE;
            }
         }
      }

   return fMonitor;
}
Ejemplo n.º 2
0
LPSUBSET Subsets_SetMonitor (LPSUBSET sub, LPIDENT lpiServer, BOOL fMonitor)
{
   if (sub == NULL)
      {
      sub = New (SUBSET);
      memset (sub, 0x00, sizeof(SUBSET));
      }

   if (fMonitor != Subsets_fMonitorServer (sub, lpiServer))
      {
      sub->fModified = TRUE;

      TCHAR szLong[ cchNAME ];
      TCHAR szShort[ cchNAME ];
      lpiServer->GetShortServerName (szShort);
      lpiServer->GetLongServerName (szLong);

      // First ensure that the server name doesn't appear anywhere
      // in the subset.
      //
      LPTSTR pszMonitoredNew = NULL;
      LPTSTR pszUnmonitoredNew = NULL;

      if (sub->pszMonitored)
         {
         for (LPTSTR psz = sub->pszMonitored; *psz; psz += 1+lstrlen(psz))
            {
            if (lstrcmpi (psz, szLong) && lstrcmpi (psz, szShort))
               {
               FormatMultiString (&pszMonitoredNew, TRUE, TEXT("%1"), TEXT("%s"), psz);
               }
            }
         }
      else if (sub->pszUnmonitored)
         {
         for (LPTSTR psz = sub->pszUnmonitored; *psz; psz += 1+lstrlen(psz))
            {
            if (lstrcmpi (psz, szLong) && lstrcmpi (psz, szShort))
               {
               FormatMultiString (&pszUnmonitoredNew, TRUE, TEXT("%1"), TEXT("%s"), psz);
               }
            }
         }

      // Then ensure it shows up only where necessary.
      //
      if (sub->pszMonitored && fMonitor)
         {
         FormatMultiString (&pszMonitoredNew, TRUE, TEXT("%1"), TEXT("%s"), szLong);
         }
      else if (!sub->pszMonitored && !fMonitor)
         {
         FormatMultiString (&pszUnmonitoredNew, TRUE, TEXT("%1"), TEXT("%s"), szLong);
         }

      if (sub->pszMonitored && !pszMonitoredNew)
         {
         pszMonitoredNew = AllocateString (2);
         pszMonitoredNew[0] = TEXT('\0');
         pszMonitoredNew[1] = TEXT('\0');
         }
      if (sub->pszUnmonitored && !pszUnmonitoredNew)
         {
         pszUnmonitoredNew = AllocateString (2);
         pszUnmonitoredNew[0] = TEXT('\0');
         pszUnmonitoredNew[1] = TEXT('\0');
         }

      // Finally, update the subset's members.
      //
      if (sub->pszMonitored)
         FreeString (sub->pszMonitored);
      if (sub->pszUnmonitored)
         FreeString (sub->pszUnmonitored);

      sub->pszMonitored = pszMonitoredNew;
      sub->pszUnmonitored = pszUnmonitoredNew;
      }

   return sub;
}