2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
14 #include <afs/param.h>
23 * SERVICE-VIEW COLUMNS _______________________________________________________
27 void Services_SetDefaultView (LPVIEWINFO lpvi
)
29 lpvi
->lvsView
= FLS_VIEW_LIST
;
30 lpvi
->nColsAvail
= nSERVICECOLUMNS
;
32 for (size_t iCol
= 0; iCol
< nSERVICECOLUMNS
; ++iCol
)
34 lpvi
->cxColumns
[ iCol
] = SERVICECOLUMNS
[ iCol
].cxWidth
;
35 lpvi
->idsColumns
[ iCol
] = SERVICECOLUMNS
[ iCol
].idsColumn
;
38 lpvi
->iSort
= svccolNAME
;
41 lpvi
->aColumns
[0] = (int)svccolNAME
;
42 lpvi
->aColumns
[1] = (int)svccolSTATUS
;
43 lpvi
->aColumns
[2] = (int)svccolDATE_STARTSTOP
;
48 * ROUTINES ___________________________________________________________________
52 size_t Services_GetAlertCount (LPSERVICE lpService
)
54 return Alert_GetCount (lpService
->GetIdentifier());
58 LPTSTR
Services_GetColumnText (LPIDENT lpi
, SERVICECOLUMN svccol
, BOOL fShowServerName
)
60 static TCHAR aszBuffer
[ nSERVICECOLUMNS
][ cchRESOURCE
];
61 static size_t iBufferNext
= 0;
62 LPTSTR pszBuffer
= aszBuffer
[ iBufferNext
++ ];
63 if (iBufferNext
== nSERVICECOLUMNS
)
65 *pszBuffer
= TEXT('\0');
67 LPSERVICESTATUS lpss
= NULL
;
69 if ((lpsp
= (LPSERVICE_PREF
)lpi
->GetUserParam()) != NULL
)
76 lpi
->GetServiceName (pszBuffer
);
79 TCHAR szNameSvr
[ cchNAME
];
80 TCHAR szNameSvc
[ cchNAME
];
81 lpi
->GetServerName (szNameSvr
);
82 lpi
->GetServiceName (szNameSvc
);
83 LPTSTR pszName
= FormatString (IDS_SERVER_SERVICE
, TEXT("%s%s"), szNameSvr
, szNameSvc
);
84 lstrcpy (pszBuffer
, pszName
);
92 if (lpss
->type
== SERVICETYPE_SIMPLE
)
93 GetString (pszBuffer
, IDS_SERVICETYPE_SIMPLE
);
94 else if (lpss
->type
== SERVICETYPE_FS
)
95 GetString (pszBuffer
, IDS_SERVICETYPE_FS
);
97 GetString (pszBuffer
, IDS_SERVICETYPE_CRON
);
104 lstrncpy (pszBuffer
, lpss
->szParams
, cchRESOURCE
-1);
105 pszBuffer
[ cchRESOURCE
-1 ] = TEXT('\0');
107 for (LPTSTR pch
= pszBuffer
; *pch
; ++pch
)
109 if (*pch
== TEXT('\r') || *pch
== TEXT('\t') || *pch
== TEXT('\n'))
118 lstrncpy (pszBuffer
, lpss
->szNotifier
, cchRESOURCE
-1);
119 pszBuffer
[ cchRESOURCE
-1 ] = TEXT('\0');
121 for (LPTSTR pch
= pszBuffer
; *pch
; ++pch
)
123 if (*pch
== TEXT('\r') || *pch
== TEXT('\t') || *pch
== TEXT('\n'))
132 if (lpss
->state
== SERVICESTATE_RUNNING
)
133 GetString (pszBuffer
, IDS_SERVICESTATE_RUNNING
);
134 else if (lpss
->state
== SERVICESTATE_STOPPING
)
135 GetString (pszBuffer
, IDS_SERVICESTATE_STOPPING
);
136 else if (lpss
->state
== SERVICESTATE_STARTING
)
137 GetString (pszBuffer
, IDS_SERVICESTATE_STARTING
);
139 GetString (pszBuffer
, IDS_SERVICESTATE_STOPPED
);
143 case svccolDATE_START
:
146 if (!FormatTime (pszBuffer
, TEXT("%s"), &lpss
->timeLastStart
))
147 pszBuffer
[0] = TEXT('\0');
151 case svccolDATE_STOP
:
154 if (!FormatTime (pszBuffer
, TEXT("%s"), &lpss
->timeLastStop
))
155 pszBuffer
[0] = TEXT('\0');
159 case svccolDATE_STARTSTOP
:
164 if ((lpss
->state
== SERVICESTATE_RUNNING
) || (lpss
->state
== SERVICESTATE_STARTING
))
166 ids
= IDS_SERVICE_STARTDATE
;
167 pst
= &lpss
->timeLastStart
;
171 ids
= IDS_SERVICE_STOPDATE
;
172 pst
= &lpss
->timeLastStop
;
175 TCHAR szDate
[ cchRESOURCE
];
176 if (FormatTime (szDate
, TEXT("%s"), pst
))
178 LPTSTR psz
= FormatString (ids
, TEXT("%s"), szDate
);
179 lstrcpy (pszBuffer
, psz
);
185 case svccolDATE_FAILED
:
188 if (!FormatTime (pszBuffer
, TEXT("%s"), &lpss
->timeLastFail
))
189 pszBuffer
[0] = TEXT('\0');
193 case svccolLASTERROR
:
196 LPTSTR psz
= FormatString (IDS_SERVICE_LASTERROR
, TEXT("%ld"), lpss
->dwErrLast
);
197 lstrcpy (pszBuffer
, psz
);