Skip to content

Commit

Permalink
Add info details to updatinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Priyesh Padmavilasom committed May 20, 2016
1 parent 1a43f9c commit ba755ef
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 5 deletions.
31 changes: 31 additions & 0 deletions client/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,15 +879,19 @@ TDNFUpdateInfo(
int nCount = 0;
int iPkg = 0;
int iAdv = 0;
time_t dwUpdated = 0;

PTDNF_UPDATEINFO pUpdateInfos = NULL;
PTDNF_UPDATEINFO pInfo = NULL;
const char* pszTemp = NULL;
const int DATELEN = 200;
char szDate[DATELEN];

HyPackage hPkg = NULL;
HyPackageList hPkgList = NULL;
HyAdvisoryList hAdvList = NULL;
HyAdvisory hAdv = NULL;
struct tm* pLocalTime = NULL;

if(!pTdnf || !ppszPackageNameSpecs || !ppUpdateInfo)
{
Expand Down Expand Up @@ -930,6 +934,33 @@ TDNFUpdateInfo(
dwError = TDNFAllocateString(pszTemp, &pInfo->pszID);
BAIL_ON_TDNF_ERROR(dwError);
}
pszTemp = hy_advisory_get_description(hAdv);
if(pszTemp)
{
dwError = TDNFAllocateString(pszTemp, &pInfo->pszDescription);
BAIL_ON_TDNF_ERROR(dwError);
}

dwUpdated = hy_advisory_get_updated(hAdv);
if(dwUpdated > 0)
{
pLocalTime = localtime(&dwUpdated);
if(!pLocalTime)
{
dwError = errno;
BAIL_ON_TDNF_SYSTEM_ERROR(dwError);
}
memset(szDate, 0, DATELEN);
dwError = strftime(szDate, DATELEN, "%c", pLocalTime);
if(dwError == 0)
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_SYSTEM_ERROR(dwError);
}
dwError = TDNFAllocateString(szDate, &pInfo->pszDate);
BAIL_ON_TDNF_ERROR(dwError);
}


dwError = TDNFGetUpdateInfoPackages(hAdv, &pInfo->pPackages);
BAIL_ON_TDNF_ERROR(dwError);
Expand Down
1 change: 1 addition & 0 deletions client/includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <stdbool.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
//
#include <sys/utsname.h>
//glib
Expand Down
8 changes: 4 additions & 4 deletions client/packageutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@ TDNFGetInstalled(

*phPkgList = hPkgList;
cleanup:
if(hQuery)
{
hy_query_free(hQuery);
}
return dwError;

error:
if(phPkgList)
{
*phPkgList = NULL;
}
if(hQuery)
{
hy_query_free(hQuery);
}
goto cleanup;
}

Expand Down
6 changes: 6 additions & 0 deletions tools/cli/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ TDNFCliUpdateInfoCommand(
PTDNF pTdnf,
PTDNF_CMD_ARGS pCmdArgs
);

uint32_t
TDNFCliUpdateInfoInfo(
PTDNF_UPDATEINFO pInfo
);

//help.c
void
TDNFCliShowUsage(
Expand Down
48 changes: 47 additions & 1 deletion tools/cli/updateinfocmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "includes.h"



char*
TDNFGetUpdateInfoType(
int nType
Expand Down Expand Up @@ -79,6 +78,11 @@ TDNFCliUpdateInfoCommand(
dwError = TDNFCliUpdateInfoList(pUpdateInfo);
BAIL_ON_CLI_ERROR(dwError);
}
else if(pInfoArgs->nMode == OUTPUT_INFO)
{
dwError = TDNFCliUpdateInfoInfo(pUpdateInfo);
BAIL_ON_CLI_ERROR(dwError);
}
}
cleanup:
if(pInfoArgs)
Expand Down Expand Up @@ -174,3 +178,45 @@ TDNFCliUpdateInfoList(
error:
goto cleanup;
}

uint32_t
TDNFCliUpdateInfoInfo(
PTDNF_UPDATEINFO pInfo
)
{
uint32_t dwError = 0;
PTDNF_UPDATEINFO_PKG pPkg = NULL;

if(!pInfo)
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_CLI_ERROR(dwError);
}

while(pInfo)
{
pPkg = pInfo->pPackages;
while(pPkg)
{
fprintf(stdout, " Name : %s\n",
pPkg->pszFileName);
fprintf(stdout, " Update ID : %s\n",
pInfo->pszID);
fprintf(stdout, " Type : %s\n",
TDNFGetUpdateInfoType(pInfo->nType));
fprintf(stdout, " Updated : %s\n",
pInfo->pszDate);
fprintf(stdout, "Description : %s\n",
pInfo->pszDescription);

pPkg = pPkg->pNext;
}
pInfo = pInfo->pNext;
}

cleanup:
return dwError;

error:
goto cleanup;
}

0 comments on commit ba755ef

Please sign in to comment.