Skip to content

Commit

Permalink
Display full name of interface if it fits to window
Browse files Browse the repository at this point in the history
  • Loading branch information
kala13x committed Nov 27, 2024
1 parent 79f7928 commit 03a9d32
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions examples/async-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef struct {
uint16_t nPort;
xbool_t bUnix;
xbool_t bSSL;
} xunix_srv_args_t;
} xasync_client_args_t;

void signal_callback(int sig)
{
Expand Down Expand Up @@ -120,7 +120,7 @@ void display_usage(const char *pName)
printf(" -h # Version and usage\n\n");
}

xbool_t parse_args(xunix_srv_args_t *pArgs, int argc, char *argv[])
xbool_t parse_args(xasync_client_args_t *pArgs, int argc, char *argv[])
{
pArgs->sAddr[0] = XSTR_NUL;
pArgs->nPort = XSTDNON;
Expand Down Expand Up @@ -175,7 +175,7 @@ int main(int argc, char* argv[])
int nSignals[2] = { SIGTERM, SIGINT };
XSig_Register(nSignals, 2, signal_callback);

xunix_srv_args_t args;
xasync_client_args_t args;
if (!parse_args(&args, argc, argv))
{
display_usage(argv[0]);
Expand Down
8 changes: 4 additions & 4 deletions examples/async-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct {
xbool_t bForce;
xbool_t bUnix;
xbool_t bSSL;
} xunix_srv_args_t;
} xasync_srv_args_t;

void signal_callback(int sig)
{
Expand All @@ -48,7 +48,7 @@ int handle_status(xapi_ctx_t *pCtx, xapi_data_t *pData)
if (pCtx->nStatus == XAPI_DESTROY)
{
xapi_t *pApi = pCtx->pApi;
xunix_srv_args_t *pArgs = (xunix_srv_args_t*)pApi->pUserCtx;
xasync_srv_args_t *pArgs = (xasync_srv_args_t*)pApi->pUserCtx;
if (pArgs->bUnix) XPath_Remove(pArgs->sAddr);
}

Expand Down Expand Up @@ -122,7 +122,7 @@ void display_usage(const char *pName)
printf(" -h # Version and usage\n\n");
}

xbool_t parse_args(xunix_srv_args_t *pArgs, int argc, char *argv[])
xbool_t parse_args(xasync_srv_args_t *pArgs, int argc, char *argv[])
{
pArgs->sCertPath[0] = XSTR_NUL;
pArgs->sKeyPath[0] = XSTR_NUL;
Expand Down Expand Up @@ -201,7 +201,7 @@ int main(int argc, char* argv[])
int nSignals[2] = { SIGTERM, SIGINT };
XSig_Register(nSignals, 2, signal_callback);

xunix_srv_args_t args;
xasync_srv_args_t args;
if (!parse_args(&args, argc, argv))
{
display_usage(argv[0]);
Expand Down
2 changes: 2 additions & 0 deletions src/sys/xtop.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ int XTop_GetNetworkStats(xtop_stats_t *pStats, xarray_t *pIfaces)
if (pDstIface == NULL) continue;

memcpy(pDstIface, pSrcIface, sizeof(xnet_iface_t));
xstrncpy(pDstIface->sName, sizeof(pDstIface->sName), "sdfasdfasdfasfasdfasfasdfasfasdf");
xstrncpy(pDstIface->sIPAddr, sizeof(pDstIface->sIPAddr), "111.111.111.111");
if (XArray_AddData(pIfaces, pDstIface, 0) < 0) free(pDstIface);
}

Expand Down
2 changes: 1 addition & 1 deletion tools/xtop.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ XSTATUS XTOPApp_AddNetworkInfo(xcli_win_t *pWin, xtop_args_t *pArgs, xarray_t *p
!strncmp(pArgs->sName, pIface->sName, nTrackLen)) nTrackID = (int)i;

size_t nNextLength = strnlen(pIface->sName, sizeof(pIface->sName));
if (nNextLength > 12)
if (pWin->frame.nColumns < 132 && nNextLength > 12)
{
nNextLength = 12;
pIface->sName[9] = '.';
Expand Down

0 comments on commit 03a9d32

Please sign in to comment.