Exemple #1
0
int check_package(fmsg_pack *p)
{
    if (p == NULL)
        err_common("bad package");

    if (p->from == NULL || p->to == NULL || p->fmsg == NULL)
        err_common("bad package");

    return 0;
}
Exemple #2
0
Fichier : log.c Projet : hekun/dsc
/*
    打印日志信息。
*/
void log_msg (const char*file,const Int32_t line,const char *text, ...)
{
    va_list arg;
    char buf[LINE_LEN];
    memset(buf,'\0',sizeof(buf));
    if((file != NULL) && (line>0))
    {
        snprintf(buf,sizeof(buf),"%s:%d %s",file,line,text);
    }
    else
    {
        memcpy(buf,text,strlen(text));
    }
    va_start (arg, text);
    err_common (B_FALSE, buf, arg);
    va_end (arg);
}
Exemple #3
0
int msg_receive(fmsg_pack *q, int fdself)
{

    if (q == NULL)
        err_common("bad address");

    //lock fdself
    if (lockf(fdself, 1, 0) == -1)
        sys_quit("lock failed");

    if (read(fdself, q, sizeof(fmsg_pack)) < 0)
        sys_quit("error occured while attempted to read :");

    //unlock fdself
    if (lockf(fdself, 0, 0) == -1)
        sys_quit("unlock failed");

    if (check_package(q))
        return -1;

    return 0;
}