Esempio n. 1
0
File: os.c Progetto: wimpunk/inadyn
/**
 * Opens the dbg output for the required destination.
 *
 * WARNING : Open and Close bg output are quite error prone!
 * They should be called din pairs!
 * TODO:
 *  some simple solution that involves storing the dbg output device name (and filename)
 */
int os_open_dbg_output(int dest, const char *name, const char *logfile)
{
	int rc = 0;
	FILE *pF;

	set_dbg_dest(dest);

	switch (get_dbg_dest()) {
	case DBG_SYS_LOG:
		if (name == NULL) {
			rc = RC_INVALID_POINTER;
			break;
		}
		rc = os_syslog_open(name);
		break;

	case DBG_FILE_LOG:
		if (logfile == NULL) {
			rc = RC_INVALID_POINTER;
			break;
		}

		pF = freopen(logfile, "ab", stdout);
		if (pF == NULL)
			rc = RC_FILE_IO_OPEN_ERROR;
		break;

	case DBG_STD_LOG:
	default:
		rc = 0;
	}

	return rc;
}
Esempio n. 2
0
/**
 * Opens the dbg output for the required destination.
 * 
 * WARNING : Open and Close bg output are quite error prone!
 * They should be called din pairs!
 * TODO: 
 *  some simple solution that involves storing the dbg output device name (and filename)
 */
RC_TYPE os_open_dbg_output(DBG_DEST dest, const char *p_prg_name, const char *p_logfile_name)
{
    RC_TYPE rc = RC_OK;
    set_dbg_dest(dest);

    switch (get_dbg_dest())
    {
    case DBG_SYS_LOG:
        if (p_prg_name == NULL)
        {
            rc = RC_INVALID_POINTER;
            break;
        }
        rc = os_syslog_open(p_prg_name);
        break;

    case DBG_FILE_LOG:
        if (p_logfile_name == NULL)
        {
            rc = RC_INVALID_POINTER;
            break;
        }
        {        
            FILE *pF = freopen(p_logfile_name, "wb", stdout);
            if (pF == NULL)
            {
                rc = RC_FILE_IO_OPEN_ERROR;
            }
            break;
        }
    case DBG_STD_LOG:
    default:
        rc = RC_OK;
    }
    return rc;
}