示例#1
0
static n_string object_file_read_string(n_file * file)
{
    n_string return_string = 0L;
    n_string_block block_string = {0};
    n_int          location = 0;
    if (file->data[file->location] != '"')  // TODO: Replace with smart char handling
    {
        (void)SHOW_ERROR("json not string as expected");
        return return_string;
    }
    
    tracking_string_quote = 1;
    
    file->location ++;
    do{
        CHECK_FILE_SIZE("end of json file reach unexpectedly");
        if(file->data[file->location] != '"')
        {
            block_string[location] = (char)file->data[file->location];
            location++;
            file->location++;
        }
    }while (file->data[file->location] != '"');
    if (location == 0)
    {
        (void)SHOW_ERROR("blank string in json file");
        return 0L;
    }
    tracking_string_quote = 0;
    file->location++;
    CHECK_FILE_SIZE("end of json file reach unexpectedly");
    return_string = io_string_copy(block_string);
    return return_string;
}
示例#2
0
errno_t sockaddr_unix2int( i4sockaddr *internal, const struct sockaddr *name, socklen_t namelen )
{
    struct sockaddr_in *iname = (struct sockaddr_in *)name;

    if( namelen < (int)sizeof(struct sockaddr_in) )
    {
        SHOW_ERROR( 1, "namelen < %d", namelen );
        return EINVAL;
    }

    if( iname->sin_len < sizeof(struct sockaddr_in) )
    {
        SHOW_ERROR( 1, "sin_len < %d", iname->sin_len );
        return EINVAL;
    }

    if( iname->sin_family != PF_INET )
    {
        SHOW_ERROR( 1, "not inet addr, pf = %d", iname->sin_family );
        return EINVAL;
    }

    internal->port                  = ntohs(iname->sin_port);
    NETADDR_TO_IPV4(internal->addr) = ntohl(iname->sin_addr.s_addr);

    SHOW_FLOW( 8, "port %d, ip %s", internal->port, inet_itoa(htonl(NETADDR_TO_IPV4(internal->addr))) );
    return 0;
}
示例#3
0
n_int network_open(n_string ip, n_byte2 port, n_c_int * network_connection)
{
    struct sockaddr_in addr; /* Local address */
    /* Create socket for incoming connections */
    if ((*network_connection = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
    {
        return SHOW_ERROR("Failed to set up socket");
    }
    /* Construct local address structure */
    io_erase((n_byte *)&addr, sizeof(addr));
    addr.sin_family = AF_INET;                /* Internet address family */
    if (ip)
    {
        addr.sin_addr.s_addr = inet_addr(ip);   /* Server IP address */
    }
    else
    {
        addr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */
    }
    addr.sin_port = htons(port);      /* Local port */

    /* Bind to the local address */
    if (bind(*network_connection, (struct sockaddr *) &addr, sizeof(addr)) < 0)
    {
        return SHOW_ERROR("Failed to set up bind");
    }
    return 0;
}
示例#4
0
// Cancel the process number obtained from
// the top of the stack
int32_t threadKill(ContextType *context,int32_t value)
 {
 UNUSED(value);

 int32_t nth;

 // Try to get the thread number
 if (PstackPop(context,&nth)) return 0;

 // Check number range
 if ((nth<1)||(nth>MAX_THREADS))
       {
	   if (SHOW_ERROR(context))
		   runtimeErrorMessage(context,"Invalid thread number");
	   return 0;
       }

 // Check if this thread is active
 if (FThreads[nth-1].status==FTS_NONE)
       {
	   if (SHOW_ERROR(context))
		   consoleErrorMessage(context,"This thread is not running");
	   return 0;
       }

 // Set abort bit
 (FThreads[nth-1].context.Flags)|=CFLAG_ABORT;

 // Show info if enabled
 if (SHOW_INFO(context))
      consolePrintf("Thread [%d] set to abort%s",nth,BREAK);

 return 0;
 }
示例#5
0
ssize_t usys_recvfrom(int *err, uuprocess_t *u, int fd, void *buf, size_t buflen, int flags,
                      struct sockaddr *from, socklen_t *fromlen)
{
    if( u == 0 )
    {
        *err = ENOTSOCK; // TODO correct?
        return -1;
    }

    CHECK_FD(fd);
    struct uufile *f = GETF(fd);

    struct uusocket *us = f->impl;

    if( *fromlen < (int)sizeof(struct sockaddr_in) )
    {
        *err = EINVAL;
        return -1;
    }

    if( ! (f->flags & UU_FILE_FLAG_NET))
    {
        *err = ENOTSOCK;
        return -1;
    }

    if( flags )
        SHOW_ERROR( 0, "I don't know this flag %d", flags );

    i4sockaddr tmp_addr;
    //struct sockaddr_in *sfrom = (struct sockaddr_in *)from;

    // FIXME TODO ERR allways times out in 5 sec
    int len = udp_recvfrom( us->prot_data, buf, buflen, &tmp_addr, SOCK_FLAG_TIMEOUT, 5000000L );
    if( len < 0 )
    {
        SHOW_ERROR( 7, "ret = %d", len );
        *err = -len;
        goto ret;
    }

    SHOW_FLOW( 8, "flags %x", flags );
    /*
    SHOW_FLOW( 7, "port %d, ip %s", tmp_addr.port, inet_itoa(htonl(NETADDR_TO_IPV4(tmp_addr.addr))) );

    sfrom->sin_port = htons(tmp_addr.port);
    sfrom->sin_addr.s_addr = htonl(NETADDR_TO_IPV4(tmp_addr.addr));
    sfrom->sin_family = PF_INET;
    sfrom->sin_len = sizeof(struct sockaddr_in);

    *fromlen = sfrom->sin_len;
    */
    errno_t rc = sockaddr_int2unix( from, fromlen, &tmp_addr );
    if( rc )
        *fromlen = 0;

ret:
    return *err ? -1 : len;
}
示例#6
0
static errno_t threads_test()
{

    hal_cond_init(&c, "threadTest");
    hal_mutex_init(&m, "threadTest");
    hal_sem_init(&s, "threadTest");

    int i = 40;
    n_t_empty = i;
    while(i-- > 0)
        phantom_create_thread( t_empty, "Empty", 0 );

    pressEnter("will create thread");
    phantom_create_thread( thread1, "__T1__", 0 );
    phantom_create_thread( thread1, "__T2__", 0 );
    //phantom_create_thread( thread1, "__T3__" );

    //phantom_create_thread( t_wait, "__TW__" );
    int tid = hal_start_kernel_thread_arg( t_wait, "__TW__" );

    i = 40;
    while(i-- > 0)
    {
        if(TEST_CHATTY) pressEnter("will yield");
        YIELD();

        if(TEST_CHATTY) printf("!! back in main\n");
    }

    t_kill_thread( tid );
    hal_sleep_msec( 30 );

    thread_stop_request = 1;
    hal_sleep_msec( 10 );

    thread_activity_counter = 0;
    hal_sleep_msec( 1000 );
    if( thread_activity_counter )
    {
        SHOW_ERROR0( 0, "Can't stop thread" );
        return -1;
    }

    while(n_t_empty > 0)
    {
        SHOW_FLOW( 0, "wait for %d threads", n_t_empty );
        hal_sleep_msec(500);
    }

    if(p._ah.refCount != 1)
    {
        SHOW_ERROR( 0, "p._ah.refCount = %d", p._ah.refCount );
        test_fail_msg( -1, "refcount" );
    }
    else
        SHOW_ERROR( 0, "p._ah.refCount = %d, SUCCESS", p._ah.refCount );

    return 0;
}
示例#7
0
static n_int object_file_read_number(n_file * file, n_int * with_error)
{
    n_int return_number = 0;
    n_string_block block_string = {0};
    n_int          location = 0;
    n_byte         read_char = file->data[file->location];
    n_int          char_okay = (ASCII_NUMBER(read_char) || (read_char == '-'));
    *with_error = 1;

    if (!char_okay)
    {
        (void)SHOW_ERROR("first character not number or minus");
        return 0;
    }
    
    CHECK_FILE_SIZE("end of json file reach unexpectedly for number");
    
    block_string[location] = (char)read_char;
    file->location++;
    location++;
    
    
    do{
        read_char = file->data[file->location];
        char_okay = ASCII_NUMBER(read_char);
        
        CHECK_FILE_SIZE("end of json file reach unexpectedly for number");

        if(char_okay)
        {
            block_string[location] = (char)read_char;
            location++;
            file->location++;
        }

    }while (char_okay);
    
    {
        n_int actual_value = 1;
        n_int decimal_divisor = 1;
        n_int error_number = io_number((n_string)block_string, &actual_value, &decimal_divisor);

        
        if (error_number == -1)
        {
            return 0;
        }
        
        if (decimal_divisor != 0)
        {
            (void)SHOW_ERROR("decimal number in json file");
            return 0;
        }
        return_number = actual_value;
    }
    *with_error = 0;
    return return_number;
}
示例#8
0
文件: bootp.c 项目: animotron/animos
static errno_t
bootprecv( struct bootp_state *bstate, void *udp_sock, struct bootp *bp, size_t len, size_t *retlen )
{
    SHOW_FLOW0( 3, "bootp_recv");

    sockaddr dest_addr;
    dest_addr.port = IPPORT_BOOTPS; // dest port

    dest_addr.addr.len = 4;
    dest_addr.addr.type = ADDR_TYPE_IP;
    // INADDR_BROADCAST
    //NETADDR_TO_IPV4(dest_addr.addr) = IPV4_DOTADDR_TO_ADDR(0xFF, 0xFF, 0xFF, 0xFF);
    NETADDR_TO_IPV4(dest_addr.addr) = IPV4_DOTADDR_TO_ADDR(0, 0, 0, 0);

    int n = udp_recvfrom(udp_sock, bp, len, &dest_addr, SOCK_FLAG_TIMEOUT, 2000000l);

    if( 0 >= n )
    {
        SHOW_ERROR( 0, "UDP recv err = %d", n);
        return ETIMEDOUT; // TODO errno
    }

    if (n == -1 || n < (int)(sizeof(struct bootp) - BOOTP_VENDSIZE))
        goto bad;

    SHOW_FLOW( 3, "bootprecv: recv %d bytes", n);

    if (bp->bp_xid != htonl(xid)) {
        SHOW_ERROR( 1, "bootprecv: expected xid 0x%x, got 0x%x",
                   xid, ntohl(bp->bp_xid));
        goto bad;
    }

    SHOW_FLOW0( 3, "bootprecv: got one!");

    /* Suck out vendor info */
    if (bcmp(vm_rfc1048, bp->bp_vend, sizeof(vm_rfc1048)) == 0) {
        if(vend_rfc1048(bstate, bp->bp_vend, sizeof(bp->bp_vend)) != 0)
            goto bad;
    }
#ifdef BOOTP_VEND_CMU
    else if (bcmp(vm_cmu, bp->bp_vend, sizeof(vm_cmu)) == 0)
        vend_cmu(bstate,bp->bp_vend);
#endif
    else
        SHOW_ERROR( 0, "bootprecv: unknown vendor 0x%lx", (long)bp->bp_vend);

    if(retlen) *retlen = n;

    return 0;
bad:
    //errno = 0;
    return EINVAL;
}
示例#9
0
static void trfs_recv_thread(void *arg)
{
    (void) arg;

    u_int8_t    buf[TRFS_MAX_PKT];

    t_current_set_name("TRFS Recv");

    while(connect_trfs())
    {
        SHOW_ERROR0( 1, "Unable to connect" );
        hal_sleep_msec(20000);
        //return;
    }
    while(1)
    {
        int rc;
        if( ( rc = trfs_recv( &buf, TRFS_MAX_PKT)) <= 0 )
        {
            SHOW_ERROR( 1, "recv err %d", rc );
        again:
            hal_sleep_msec( 100 ); // Against tight loop
            continue;
        }

        if( rc < (int)sizeof(trfs_pkt_t) )
        {
            SHOW_ERROR( 1, "recv pkt size %d < required %d", rc, sizeof(trfs_pkt_t) );
            goto again;
        }

        trfs_pkt_t *rq = (trfs_pkt_t *)buf;

        SHOW_FLOW( 6, "got pkt type %d", rq->type );

        if(rq->sessionId != sessionId)
        {
            trfs_reset_session(rq->sessionId);
            if(rq->type != PKT_T_Error)
                continue;
        }

        switch(rq->type)
        {
        case PKT_T_Error:    		recvError(rq);          break;
    	case PKT_T_ReadReply:        	recvReadReply(rq);      break;
    	case PKT_T_FindReply:        	recvFindReply(rq);      break;

        default:
            SHOW_ERROR( 0, "TRFS: unknown packet type %d", rq->type);

        }
    }
}
示例#10
0
static void reopen_stdioe(uuprocess_t *u, const char *fname)
{
    int err;
    usys_close( &err, u, 0 );
    usys_close( &err, u, 1 );
    usys_close( &err, u, 2 );

    if( usys_open( &err, u, fname, O_RDONLY, 0 ) != 0 )
        SHOW_ERROR( 0, "can't open %s for stdin, %d", fname, err );

    if( usys_open( &err, u, fname, O_WRONLY, 0 ) != 1 )
        SHOW_ERROR( 0, "can't open %s for stdout, %d", fname, err );

    if( usys_open( &err, u, fname, O_WRONLY, 0 ) != 2 )
        SHOW_ERROR( 0, "can't open %s for stderr, %d", fname, err );
}
示例#11
0
bool
create_temp_sg(scsi_ccb *ccb)
{
	physical_entry *temp_sg;
	status_t res;

	SHOW_FLOW(3, "ccb=%p, data=%p, data_length=%" B_PRIu32, ccb, ccb->data,
		ccb->data_length);

	ccb->sg_list = temp_sg = (physical_entry*)locked_pool->alloc(temp_sg_pool);
	if (temp_sg == NULL) {
		SHOW_ERROR0(2, "cannot allocate memory for IO request!");
		return false;
	}

	res = lock_memory(ccb->data, ccb->data_length, B_DMA_IO
		| ((ccb->flags & SCSI_DIR_MASK) == SCSI_DIR_IN ? B_READ_DEVICE : 0));

	if (res != B_OK) {
		SHOW_ERROR(2, "cannot lock memory for IO request (%s)", strerror(res));
		goto err;
	}

	if (fill_temp_sg(ccb))
		// this is the success path
		return true;

	unlock_memory(ccb->data, ccb->data_length, B_DMA_IO
		| ((ccb->flags & SCSI_DIR_MASK) == SCSI_DIR_IN ? B_READ_DEVICE : 0));

err:
	locked_pool->free(temp_sg_pool, temp_sg);
	return false;
}
示例#12
0
static errno_t rm_mount( const char* name, int flags )
{
    (void) flags;

    if( *name == '/' ) name++;

    errno_t rc = unlink_dir_name( &root_root, name );
    if( rc )
    {
        SHOW_ERROR( 1, "can't unlink %s", name );
        return rc;
    }

    hal_mutex_lock ( &mm );

    int i;
    for( i = 0; i < FS_MAX_MOUNT; i++ )
    {
        // unused
        if( mount[i].fs == 0 )
            continue;

        if( 0 == strcmp( mount[i].path, name ) )
        {
            mount[i].fs = 0;
            hal_mutex_unlock ( &mm );
            return 0;
        }

    }

    hal_mutex_unlock ( &mm );
    return ENOENT;
}
示例#13
0
static void * object_write_primitive(n_file * file, n_array * primitive)
{
    switch (object_type(primitive))
    {
        case OBJECT_NUMBER:
        {
            n_int * int_data = (n_int *)&primitive->data;
            io_writenumber(file, int_data[0],1,0);
        }
            break;
        case OBJECT_STRING:
            io_write(file, "\"", 0);
            io_write(file, primitive->data, 0);
            io_write(file, "\"", 0);
            break;
        case OBJECT_OBJECT:
            object_top_object(file, (n_object *)primitive->data);
            break;
        case OBJECT_ARRAY:
            object_top_array(file, (n_array *)primitive->data);
            break;
        default:
            (void)SHOW_ERROR("Object kind not found");
            return 0L;
    }
    if (primitive->next)
    {
        io_write(file, ",", 0);
    }
    return primitive->next;
}
示例#14
0
ssize_t usys_sendmsg(int *err, uuprocess_t *u, int fd, const struct msghdr *msg, int flags)
{
    (void) msg;

    if( u == 0 )
    {
        *err = ENOTSOCK; // TODO correct?
        return -1;
    }

    CHECK_FD(fd);
    struct uufile *f = GETF(fd);
    int len = 0;

    struct uusocket *us = f->impl;
    (void) us;

    // TODO implement me

    if( ! (f->flags & UU_FILE_FLAG_NET))
    {
        *err = ENOTSOCK;
        return -1;
    }

    if( flags )
        SHOW_ERROR( 0, "I don't know this flag %d", flags );




    *err = ENOSYS;
    return *err ? -1 : len;
}
示例#15
0
static bool
scsi_alloc_dma_buffer_sg_orig(dma_buffer *buffer, size_t size)
{
	// free old list first
	scsi_free_dma_buffer_sg_orig(buffer);

	size = (size * sizeof(physical_entry) + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);

	buffer->sg_orig = create_area("S/G to original data",
		(void **)&buffer->sg_list_orig,
		B_ANY_KERNEL_ADDRESS, size,
		B_NO_LOCK, 0);
	if (buffer->sg_orig < 0) {
		SHOW_ERROR(2, "Cannot S/G list buffer to original data of %" B_PRIuSIZE
			" bytes", size);
		return false;
	}

	buffer->sg_count_max_orig = size / sizeof(physical_entry);

	SHOW_INFO(3, "Got up to %" B_PRIuSIZE " S/G entries to original data",
		buffer->sg_count_max_orig);

	return true;
}
示例#16
0
文件: fs_cd.c 项目: animotron/animos
errno_t cd_read_file( cdfs_t *impl, iso_dir_entry *e, u_int32_t start_sector, size_t nsect, void *buf )
{
    //phantom_disk_partition_t *p = impl->p;

    SHOW_FLOW( 4, "CDFS file @ sect %d, sz %d", e->dataStartSector[0], e->dataLength[0] );

    int file_start_sect = e->dataStartSector[0];
    size_t file_size = e->dataLength[0];

    size_t file_sectors = CD_BYTES_TO_SECTORS(file_size);

    if( start_sector + nsect > file_sectors )
        nsect = file_sectors - start_sector;

    if( nsect <= 0 )
        return EINVAL;

    // Reasonable limit?
    if( nsect > 1024 ) return EINVAL;

    int sect = file_start_sect+start_sector;

    SHOW_FLOW( 9, "CDFS file read @ sect %d, nsect %d", sect, nsect );

    errno_t err = cd_read_sectors( impl, buf, sect, nsect );

    if( err )
    {
        SHOW_ERROR( 1, "CDFS file sect read err %d", err );
        return err;
    }

    return 0;
}
示例#17
0
void recvError(trfs_pkt_t *rq)
{
    SHOW_ERROR( 0, "error %d received, '%.*s'",
           rq->error.errorId,
           rq->error.textLen,
           rq->error.text
          );
}
示例#18
0
 void Parent::textbox_add(int id){
   get_element(tex,gui::Textbox,gui::GUI_TYPE::TEXTBOX,id);
   if (tex.parent_id != -1){
     SHOW_ERROR("BasicGUI: Textbox with ID "+to_string(id)+" already has a parent with ID "+to_string(tex.parent_id)+"! Parenting not done!\n");
   }
   child_elements.push_back(id);
   tex.parent_id = element_id;
 }
示例#19
0
文件: fs_map.c 项目: animotron/animos
errno_t lookup_fs(phantom_disk_partition_t *p)
{
    char pname[128];
    partGetName( p, pname, sizeof(pname) );

    SHOW_INFO( 0, "Look for filesystems on partition %s", pname );
    unsigned int i;
    for( i = 0; i < sizeof(fs_drivers)/sizeof(fs_probe_t); i++ )
    {
        fs_probe_t *fp = &fs_drivers[i];

        SHOW_INFO( 0, "probe %s fs on %s", fp->name, pname );

        errno_t ret = fp->probe_f( p );
        if( ret ) continue;

        SHOW_INFO( 0, "%s file sysem found on partition %s", fp->name, pname );

        if(!fp->use_f)
        {
            SHOW_ERROR( 0, "%s file sysem is not implemented yet", fp->name );
            continue;
        }

#if FS_START_THREAD
        // BUG HACK - activate phantom fs syncronously, or else we will die attempting to use it
        if(fp->use_f == fs_use_phantom)
            fp->use_f( p );
        else
            hal_start_kernel_thread_arg( (void (*)(void *))fp->use_f, p );
#else
        ret = fp->use_f( p );
        if( ret )
        {
            SHOW_ERROR( 0, "%s file sysem driver rejected partition %s", fp->name, pname );
            continue;
        }

        SHOW_INFO( 0, "%s file sysem driver occupies partition %s", fp->name, pname );
#endif
        return 0;
    }

    return EINVAL;
}
示例#20
0
errno_t cn_url_do_operation( int op_no, struct data_area_4_connection *c, struct data_area_4_thread *t, pvm_object_t o )
{
    (void) t;
    (void) c;
    (void) o;

    SHOW_ERROR( 1, "no op %d", op_no );
    return EINVAL;
}
示例#21
0
文件: PCI_GART.c 项目: luciang/haiku
static status_t createGARTBuffer( GART_info *gart, size_t size )
{
	physical_entry map[1];
	void *unaligned_addr, *aligned_phys;

	SHOW_FLOW0( 3, "" );

	gart->buffer.size = size = (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);

	// we allocate an contiguous area having twice the size
	// to be able to find an aligned, contiguous range within it;
	// the graphics card doesn't care, but the CPU cannot
	// make an arbitrary area WC'ed, at least elder ones
	// question: is this necessary for a PCI GART because of bus snooping?
	gart->buffer.unaligned_area = create_area( "Radeon PCI GART buffer",
		&unaligned_addr, B_ANY_KERNEL_ADDRESS,
		2 * size, B_CONTIGUOUS/*B_FULL_LOCK*/, B_READ_AREA | B_WRITE_AREA | B_USER_CLONEABLE_AREA );
		// TODO: Physical aligning can be done without waste using the
		// private create_area_etc().
	if (gart->buffer.unaligned_area < 0) {
		SHOW_ERROR( 1, "cannot create PCI GART buffer (%s)",
			strerror( gart->buffer.unaligned_area ));
		return gart->buffer.unaligned_area;
	}

	get_memory_map( unaligned_addr, B_PAGE_SIZE, map, 1 );

	aligned_phys =
		(void **)((map[0].address + size - 1) & ~(size - 1));

	SHOW_FLOW( 3, "aligned_phys=%p", aligned_phys );

	gart->buffer.area = map_physical_memory( "Radeon aligned PCI GART buffer",
		(addr_t)aligned_phys,
		size, B_ANY_KERNEL_BLOCK_ADDRESS | B_MTR_WC,
		B_READ_AREA | B_WRITE_AREA, &gart->buffer.ptr );

	if( gart->buffer.area < 0 ) {
		SHOW_ERROR0( 3, "cannot map buffer with WC" );
		gart->buffer.area = map_physical_memory( "Radeon aligned PCI GART buffer",
			(addr_t)aligned_phys,
			size, B_ANY_KERNEL_BLOCK_ADDRESS,
			B_READ_AREA | B_WRITE_AREA, &gart->buffer.ptr );
	}

	if( gart->buffer.area < 0 ) {
		SHOW_ERROR0( 1, "cannot map GART buffer" );
		delete_area( gart->buffer.unaligned_area );
		gart->buffer.unaligned_area = -1;
		return gart->buffer.area;
	}

	memset( gart->buffer.ptr, 0, size );

	return B_OK;
}
示例#22
0
errno_t cache_set_writeback( cache_t *c, writeback_f_t *func, void *opaque )
{
    if(c->writeback_f)
        SHOW_ERROR( 3, "Reset wback f for %p", c );

    c->writeback_f = func;
    c->writeback_a = opaque;

    return 0;
}
示例#23
0
BOOL CAuthTest::Test_UnblockPIN()
{
    SHOW_PROCESS("UnblockPIN");
    if (NULL == g_hApp)
    {
        printf("OPen application first!\n");
        return FALSE;
    }

    char szSoPIN[256] = {0};
    printf("Input administrator's PIN\n");

    fflush(stdin);
    gets(szSoPIN);


    char szNewUserPIN[256] = {0};
    printf("Input new user's PIN\n");

    fflush(stdin);
    gets(szNewUserPIN);

    ULONG ulRetryCount = 0;
    ULONG ulReval = 0;
    do
    {
        ulReval = SKF_UnblockPIN(g_hApp, (LPSTR)szSoPIN, (LPSTR)szNewUserPIN, &ulRetryCount);
        SHOW_ERROR(ulReval);
        if (SAR_PIN_INCORRECT == ulReval)
        {
            printf("Wrong PIN!\n");
            break;
        }

        if (SAR_PIN_INVALID == ulReval)
        {
            printf("Invalid PIN!\n");
            break;
        }

        if (SAR_PIN_LEN_RANGE == ulReval)
        {
            printf("Wrong PIN Length!\n");
            break;
        }

        if (SAR_PIN_LOCKED == ulReval)
        {
            printf("Your PIN has been locked!\n");
            break;
        }
    } while (0);

    return (SAR_OK == ulReval);
}
示例#24
0
ssize_t usys_sendto(int *err, uuprocess_t *u, int fd, const void *buf, size_t buflen, int flags, const struct sockaddr *to, socklen_t tolen)
{
    if( u == 0 )
    {
        *err = ENOTSOCK; // TODO correct?
        return -1;
    }

    CHECK_FD(fd);
    struct uufile *f = GETF(fd);

    struct uusocket *us = f->impl;
	(void) us;

    if( tolen < (int)sizeof(struct sockaddr_in) )
    {
        *err = EINVAL;
        return -1;
    }

    if( ! (f->flags & UU_FILE_FLAG_NET))
    {
        *err = ENOTSOCK;
        return -1;
    }

    if( flags )
        SHOW_ERROR( 0, "I don't know this flag %d", flags );

    /*
    struct sockaddr_in *sto = (struct sockaddr_in *)to;

    if( sto->sin_family != PF_INET )
        SHOW_ERROR0( 0, "not inet addr?");
    */

    i4sockaddr tmp_addr;
    errno_t rc = sockaddr_unix2int( &tmp_addr, to, tolen );
    if( rc )
    {
        *err = rc;
        return -1;
    }

    //tmp_addr.port = ntohs(sto->sin_port);
    //NETADDR_TO_IPV4(tmp_addr.addr) = ntohl(sto->sin_addr.s_addr);

    SHOW_FLOW( 8, "flags %x", flags );
    //SHOW_FLOW( 7, "port %d, ip %s", tmp_addr.port, inet_itoa(htonl(NETADDR_TO_IPV4(tmp_addr.addr))) );
    int ret = udp_sendto( us->prot_data, buf, buflen, &tmp_addr);
    if( ret < 0 )
        *err = -ret;

    return *err ? -1 : ret;
}
示例#25
0
void phantom_thread_sleep_worker( struct data_area_4_thread *thda )
{
    if(phantom_virtual_machine_stop_request)
    {
        SHOW_FLOW0( 5, "VM thread will die now");
        hal_exit_kernel_thread();
    }

    SHOW_FLOW0( 5, "VM thread will sleep for sleep");
    hal_mutex_lock( &interlock_mutex );

    phantom_virtual_machine_threads_stopped++;
    hal_cond_broadcast( &phantom_snap_wait_4_vm_enter );
    //SHOW_FLOW0( 5, "VM thread reported sleep, will wait now");

    if( thda->spin_to_unlock )
    {
        VM_SPIN_UNLOCK( (*thda->spin_to_unlock) );
        thda->spin_to_unlock = 0;
    }
    else
    {
        if(thda->sleep_flag)
            SHOW_ERROR(0, "Warn: vm th (da %x) sleep, no spin unlock requested", thda);
    }


    //while(thda->sleep_flag)        hal_cond_wait( &(thda->wakeup_cond), &interlock_mutex );
    while(thda->sleep_flag)
    {
        SHOW_ERROR(0, "Warn: old vm sleep used, th (da %x)", thda);
        hal_cond_wait( &vm_thread_wakeup_cond, &interlock_mutex );
    }

// TODO if snap is active someone still can wake us up - resleep for snap then!

    //SHOW_FLOW0( 5, "VM thread awaken, will report wakeup");
    phantom_virtual_machine_threads_stopped--;

    hal_mutex_unlock( &interlock_mutex );
    SHOW_FLOW0( 5, "VM thread awaken");
}
示例#26
0
void sendRequest(trfs_queue_t *qe)
{
    if( qe->type == TRFS_QEL_TYPE_READ )
        sendReadRq(qe);
    else
    if( qe->type == TRFS_QEL_TYPE_WRITE )
        sendWriteRq(qe);
    else
        SHOW_ERROR( 0, "unknown req type %d", qe->type );

}
示例#27
0
int LoggerSingleton::LogWrite(const std::string& level, const std::string& module, const std::string& format, va_list ap)
{
	Switch::Tool::ErrorInfo err;

    if (Switch::Tool::Logger::LogWrite(err, level, module, format, ap) != 0)
	{
		SHOW_ERROR(err);
		return -1;
	}
    return 0;
}
示例#28
0
static void __cfree(int tobe, int ln)
{
    int real = nfree();

    if( tobe == real )
        return;

    SHOW_ERROR( 0, "free is %d, must be %d, diff = %d  @line %d", real, tobe, real-tobe, ln );

    test_fail_msg( EINVAL, "free count is wrong" );
}
示例#29
0
文件: fs_cd.c 项目: animotron/animos
errno_t cd_scan_dir( cdfs_t *impl, iso_dir_entry *e, const char *path_to_find, iso_dir_entry *found_entry )
{
    //phantom_disk_partition_t *p = impl->p;

    SHOW_FLOW( 7, "CDFS dir @ sect %d, sz %d, look for '%s'", e->dataStartSector[0], e->dataLength[0], path_to_find );

    int sect = e->dataStartSector[0];
    int left = e->dataLength[0];

    const char *name_to_find;
    const char *path_rest;

    size_t namelen = 1;

    const char *slash = index( path_to_find, '/' );
    if( slash == 0 )
    {
        name_to_find = path_to_find;
        path_rest = 0;
    }
    else
    {
        namelen = slash-path_to_find;
    }

    char name[namelen+1];

    if( slash )
    {
        strlcpy( name, path_to_find, namelen+1 );
        name_to_find = name;
        path_rest = slash+1;
    }

    SHOW_FLOW( 8, "name = '%s', rest = '%s'", name_to_find, path_rest );

    char buf[CD_SECT_SIZE];

    while( left > 0 )
    {
        errno_t err = cd_read_sectors( impl, buf, sect++, 1 );
        left -= CD_SECT_SIZE;

        if( err )
            SHOW_ERROR( 0, "CDFS dir sect read err %d != 2048, not supported", err );
        else
        {
            err = cd_scan_dir_sect( impl, buf, name_to_find, path_rest, found_entry );
            if( 0 == err ) return err;
        }
    }

    return ENOENT;
}
示例#30
0
文件: trfsc.c 项目: animotron/animos
static errno_t trfs_send(void *pkt, int pktsize)
{
    if(trfs_failed || !phantom_tcpip_active)
        return ENOTCONN;

    if(debug_level_flow >= 11) hexdump( pkt, pktsize, "TRFS send pkt", 0 );

    SHOW_FLOW0( 1, "sending" );
    int rc;
    if( 0 == (rc = udp_sendto(trfs_socket, pkt, pktsize, &trfs_addr)) )
        return 0;

    if(rc == ERR_NET_NO_ROUTE)
    {
        SHOW_ERROR( 0, "No route", rc);
        return EHOSTUNREACH;
    }
    else
        SHOW_ERROR( 0, "can't send, rc = %d", rc);
    return EIO;
}