/** * Returns the path of the memory-file corresponding to a server and a multicast * group. * * @param[in] servAddr The address of the server associated with the multicast * group. * @param[in] feedtype Feedtype of multicast group. * @retval NULL Failure. `log_start()` called. * @return The path of the corresponding memory-file. The caller * should free when it's no longer needed. */ static char* getSessionPath( const ServiceAddr* const servAddr, const feedtypet feedtype) { char* path; char* const servAddrStr = sa_format(servAddr); if (servAddrStr) { path = ldm_format(256, "%s/%s_%s.yaml", getLdmLogDir(), servAddrStr, s_feedtypet(feedtype)); free(servAddrStr); } return path; }
/** * Returns the absolute pathname of the file that contains the process-ID of * the multicast LDM sender corresponding to a multicast group identifier. * * @param[in] info Information on the multicast group. * @retval NULL Error. `log_add()` called. * @return The absolute pathname of the PID file. The caller should * free when it's no longer needed. */ static char* getPidPathname( const McastInfo* const info) { char* pathname; const char* const filename = mi_asFilename(info); if (filename == NULL) { pathname = NULL; } else { pathname = ldm_format(256, "%s/%s.pid", getLdmVarRunDir(), filename); } return pathname; }
static void sa_parse_test( const char* const inetId, const unsigned short port) { ServiceAddr* sa; char* buf = ldm_format(80, strchr(inetId, ':') ? "[%s]:%d" : "%s:%d", inetId, port); int status; CU_ASSERT_PTR_NOT_NULL_FATAL(buf); status = sa_parse(&sa, buf); log_flush_error(); CU_ASSERT_EQUAL_FATAL(status, 0); CU_ASSERT_STRING_EQUAL(sa_getInetId(sa), inetId); CU_ASSERT_EQUAL(sa_getPort(sa), port); sa_free(sa); }
/** * Returns the pathname of the memory-file corresponding to a server and a * multicast group. This function is reentrant. * * @param[in] servAddr The address of the server associated with the multicast * group. * @param[in] feedtype Feedtype of multicast group. * @retval NULL Failure. `log_start()` called. * @return The path of the corresponding memory-file. The caller * should free when it's no longer needed. */ static char* getSessionPath( const ServiceAddr* const servAddr, const feedtypet feedtype) { char* path; char ftBuf[256]; if (sprint_feedtypet(ftBuf, sizeof(ftBuf), feedtype) < 0) { LOG_START0("sprint_feedtypet() failure"); path = NULL; } else { path = ldm_format(256, "%s/%s_%s.yaml", getLdmLogDir(), servAddr->inetId, ftBuf); } return path; }
/** * Returns the path of the temporary memory-file corresponding to the path of a * canonical memory-file. * * @param[in] path The path of a canonical memory-file. The caller may free * when it's no longer needed. * @retval NULL Failure. `log_start()` called. * @return The path of the corresponding temporary memory-file. The * caller should free when it's no longer needed. */ static char* makeTempPath( char* const restrict path) { char* const tmpPath = ldm_format(256, "%s%s", path, ".new"); if (tmpPath == NULL) LOG_ADD0("Couldn't create path of temporary memory-file"); return tmpPath; } static inline const char* yamlParserErrMsg( const yaml_parser_t* const parser) { return parser->problem; } static inline unsigned long