예제 #1
0
파일: kplex.c 프로젝트: bakerkj/kplex
/* Add tag data
 * Args: Interface pointer, buffer for tags
 * Returns: Length of tag buffer on success
 */
size_t gettag(iface_t *ifa, char *buf, senblk_t *sptr)
{
    char *ptr=buf;
    char *nameptr;
    int first=1;
    struct timeval tv;
    unsigned char cksum;
    size_t len;

    *ptr++='\\';
    if (ifa->tagflags & TAG_SRC){
        first=0;
        memcpy(ptr,"s:",2);
        ptr+=2;
        if (ifa->tagflags & TAG_ISRC) {
            if ((nameptr=idlookup(sptr->src))==NULL)
                nameptr=DEFSRCNAME;
        } else
            nameptr=(ifa->name)?ifa->name:DEFSRCNAME;

        for (len=0;*nameptr && len < 15; len++)
            *ptr++=*nameptr++;
    }

    if (ifa->tagflags & TAG_TS) {
        if (!first)
            *ptr++=',';
        memcpy(ptr,"c:",2);
        ptr+=2;
        (void) gettimeofday(&tv,NULL);
        ptr+=sprintf(ptr,"%010u",(unsigned) tv.tv_sec);
        if (ifa->tagflags & TAG_MS)
            ptr += sprintf(ptr,"%03u",((unsigned) tv.tv_usec+500)/1000);
    }
    /* Don't include initial '/' */
    cksum=calcsum(buf+1,(len=ptr-buf)-1);
    len+=sprintf(ptr,"*%02X\\",cksum);
    return(len);
}
예제 #2
0
EXPORT jint Test_fastjni(JNIEnv* env, jobject java_this, jbyteArray array) {
    return calcsum(env, array);
}