Esempio n. 1
0
static rc_t ShowFiles(const KConfig* cfg, const Params* prm) {
    rc_t rc = 0;
    bool hasAny = false;
    uint32_t count = 0;
    KNamelist* names = NULL;
    rc = KConfigListIncluded(cfg, &names);
    if (rc == 0)
    {   rc = KNamelistCount(names, &count); }
    if (rc == 0) {
        uint32_t i = 0;

        if (prm->showMultiple) {
            OUTMSG(("<!-- Configuration files -->\n"));
            hasAny = true;
        }

        for (i = 0; i < count && rc == 0; ++i) {
            const char* name = NULL;
            if (rc == 0)
            {   rc = KNamelistGet(names, i, &name); }
            if (rc == 0) {
                OUTMSG(("%s\n", name));
                hasAny = true;
            }
        }
    }
    if (rc == 0 && hasAny)
    {   OUTMSG(("\n")); }

    RELEASE(KNamelist, names);

    return rc;
}
Esempio n. 2
0
static rc_t CC scan_mod_dir(const KDirectory* dir,
    uint32_t type, const char* name, void* data)
{
    rc_t rc = 0;
    const char ext[] = SHLX;

    assert(data);

    if (strlen(name) > strlen(ext) + 1 &&
        name[strlen(name) - strlen(ext) - 1] == '.')
    {
        char buf[PATH_MAX + 1];
        rc = KDirectoryResolvePath
            (dir, true, buf, sizeof buf, "%s/%s", data, name);

        while (rc == 0) {
            uint32_t type = KDirectoryPathType(dir, buf);
            if (type & kptAlias) {
                rc = KDirectoryResolveAlias
                    (dir, true, buf, sizeof buf, buf);
                DISP_RC(rc, name);
            }
            else if (rc == 0) {
                if (type == kptNotFound || type == kptBadPath) {
                    OUTMSG(("%s: %s\n", buf,
                        type == kptNotFound ? "not found" : "bad path"));
                }
                else { OUTMSG(("%s\n", buf)); }
                break;
            }
        }
    }

    return rc;
}
Esempio n. 3
0
static void ShowEnv(const Params* prm) {
    bool hasAny = false;
    const char * env_list [] = {
        "KLIB_CONFIG",
        "VDB_CONFIG",
        "VDBCONFIG",
        "LD_LIBRARY_PATH"
    };
    int i = 0;

    if (prm->showMultiple) {
        OUTMSG(("<!-- Environment -->\n"));
        hasAny = true;
    }

    for (i = 0; i < sizeof env_list / sizeof env_list [ 0 ]; ++ i ) {
        const char *eval = getenv ( env_list [ i ] );
        if (eval) {
            OUTMSG(("%s=%s\n", env_list [ i ], eval));
            hasAny = true;
        }
    }
    if (hasAny)
    {      OUTMSG(("\n")); }
    else { OUTMSG(("Environment variables are not found\n")); }
}
Esempio n. 4
0
    rc_t CC Usage ( struct Args const * args )
    {
        rc_t rc = 0;
        const char* progname = UsageDefaultName;
        const char* fullpath = UsageDefaultName;

        if (args == NULL)
            rc = RC(rcExe, rcArgv, rcAccessing, rcSelf, rcNull);
        else
            rc = ArgsProgram(args, &fullpath, &progname);

        UsageSummary (progname);


        OUTMSG (("\nInput: the stream of lines in the format: <key> <tab> <input variation>\n\n"));
        OUTMSG (("\nOptions:\n"));

        HelpOptionLine (NULL, VarExpand::OPTION_ALG, "value", VarExpand::USAGE_ALG);

        XMLLogger_Usage();

        HelpOptionsStandard ();

        HelpVersion (fullpath, KAppVersion());

        return rc;
    }
Esempio n. 5
0
rc_t CC Usage( const Args* args )
{
    rc_t rc;
    int i;
    const char* progname = UsageDefaultName;
    const char* fullname = UsageDefaultName;

    rc = ArgsProgram(args, &fullname, &progname);

    UsageSummary(progname);

    for(i = 0; i < MainArgsQty; i++ ) {
        if( MainArgs[i].required && MainArgs[i].help[0] != NULL ) {
            HelpOptionLine(MainArgs[i].aliases, MainArgs[i].name, NULL, MainArgs[i].help);
        }
    }
    OUTMSG(("\nOptions:\n"));
    for(i = 0; i < MainArgsQty; i++ ) {
        if( !MainArgs[i].required && MainArgs[i].help[0] != NULL ) {
            HelpOptionLine(MainArgs[i].aliases, MainArgs[i].name, NULL, MainArgs[i].help);
        }
    }
    XMLLogger_Usage();
    OUTMSG(("\n"));
    HelpOptionsStandard();
    HelpVersion(fullname, KAppVersion());
    return rc;
}
Esempio n. 6
0
rc_t PrintOS(bool xml) {
    const char *b = xml ? "  <Os>"  : "Operating system: '";
    const char *e = xml ? "</Os>" :                   "'\n";

    OSVERSIONINFO osvi;
    ZeroMemory(&osvi, sizeof osvi);
    osvi.dwOSVersionInfoSize = sizeof osvi;

    if (GetVersionEx(&osvi)) {
        if (osvi.dwPlatformId == 2) {
            return OUTMSG((
                "%sMicrosoft Windows. Version %d.%d (Build %d: %s)%s\n", b,
                osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber,
                osvi.szCSDVersion, e));
        }
        else {
            return OUTMSG((
         "%sMicrosoft Windows. Version %d.%d (Build %d: %s). PlatformId %d%s\n",
              b,
                osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber,
                osvi.szCSDVersion, osvi.dwPlatformId, e));
        }
    }
    else {
        return OUTMSG(("%sGetLastError(GetVersionEx()) = %d%s\n",
            b, GetLastError(), e));
    }
}
Esempio n. 7
0
rc_t CC Usage(const Args* args)
{
    const char * progname = UsageDefaultName;
    const char * fullpath = UsageDefaultName;
    rc_t rc;
    int i;

    if (args == NULL)
        rc = RC (rcApp, rcArgv, rcAccessing, rcSelf, rcNull);
    else
        rc = ArgsProgram (args, &fullpath, &progname);

    OUTMSG(( "\nUsage:\n\t%s [options] <table>\n\n", progname));

    for(i = 0; i < MainArgsQty; i++ ) {
        if( MainArgs[i].required && MainArgs[i].help ) {
            HelpOptionLine(MainArgs[i].aliases, MainArgs[i].name, MainParams[i], MainArgs[i].help);
        }
    }
    OUTMSG(("\nOptions:\n"));
    for(i = 0; i < MainArgsQty; i++ ) {
        if( !MainArgs[i].required && MainArgs[i].help ) {
            HelpOptionLine(MainArgs[i].aliases, MainArgs[i].name, MainParams[i], MainArgs[i].help);
        }
    }
    OUTMSG(("\n"));
    HelpOptionsStandard();
    HelpVersion(fullpath, KAppVersion());
    return rc;
}
Esempio n. 8
0
rc_t CC Usage (const Args * args)
{
    rc_t rc;
    int i;
    const char * progname = UsageDefaultName;
    const char * fullpath = UsageDefaultName;
    const size_t argsQty = sizeof(Options) / sizeof(Options[0]);

    if (args == NULL)
        rc = RC (rcApp, rcArgv, rcAccessing, rcSelf, rcNull);
    else
        rc = ArgsProgram (args, &fullpath, &progname);
    if (rc)
        progname = fullpath = UsageDefaultName;

    UsageSummary (progname);

    for(i = 0; i < argsQty; i++ ) {
        if( Options[i].required && Options[i].help[0] != NULL ) {
            HelpOptionLine(Options[i].aliases, Options[i].name, OptHelpParam[i], Options[i].help);
        }
    }
    OUTMSG(("\nOptions:\n"));
    for(i = 0; i < argsQty; i++ ) {
        if( !Options[i].required && Options[i].help[0] != NULL ) {
            HelpOptionLine(Options[i].aliases, Options[i].name, OptHelpParam[i], Options[i].help);
        }
    }
    XMLLogger_Usage();
    OUTMSG(("\n"));
    HelpOptionsStandard ();
    HelpVersion (fullpath, KAppVersion());
    return rc;
}
Esempio n. 9
0
static rc_t In(const char* prompt, const char* def, char** read) {
    rc_t rc = 0;
    char buf[PATH_MAX + 1];
    assert(prompt && read);
    *read = NULL;
    while (rc == 0 && (*read == NULL || read[0] == '\0')) {
        OUTMSG(("%s", prompt));
        if (def)
        {   OUTMSG((" [%s]", def)); }
        OUTMSG((": "));
        rc = ReadStdinLine(buf, sizeof buf);
        if (rc == 0) {
            while (strlen(buf) > 0) {
                char c = buf[strlen(buf) - 1];
                if (c == '\n' || c == '\r')
                {   buf[strlen(buf) - 1] = '\0'; }
                else
                {   break; }
            }
            if (buf[0] == '\0' && def)
            {   strcpy(buf, def); }
            if (buf[0]) {
                *read = strdup(buf);
                if (*read == NULL) {
                    rc = RC
                        (rcExe, rcStorage, rcAllocating, rcMemory, rcExhausted);
                }
            }
        }
    }
    return rc;
}
Esempio n. 10
0
static int _tee_shm_attach_dma_buf(struct dma_buf *dmabuf,
					struct device *dev,
					struct dma_buf_attachment *attach)
{
	struct tee_shm_attach *tee_shm_attach;
	struct tee_shm *shm;
	struct tee *tee;

	shm = dmabuf->priv;
	tee = shm->tee;

	INMSG();

	tee_shm_attach = devm_kzalloc(_DEV(tee),
			sizeof(*tee_shm_attach), GFP_KERNEL);
	if (!tee_shm_attach) {
		OUTMSG(-ENOMEM);
		return -ENOMEM;
	}

	tee_shm_attach->dir = DMA_NONE;
	attach->priv = tee_shm_attach;

	OUTMSG(0);
	return 0;
}
Esempio n. 11
0
static void _tee_shm_detach_dma_buf(struct dma_buf *dmabuf,
					struct dma_buf_attachment *attach)
{
	struct tee_shm_attach *tee_shm_attach = attach->priv;
	struct sg_table *sgt;
	struct tee_shm *shm;
	struct tee *tee;

	shm = dmabuf->priv;
	tee = shm->tee;

	INMSG();

	if (!tee_shm_attach) {
		OUTMSG(0);
		return;
	}

	sgt = &tee_shm_attach->sgt;

	if (tee_shm_attach->dir != DMA_NONE)
		dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents,
			tee_shm_attach->dir);

	sg_free_table(sgt);
	devm_kfree(_DEV(tee), tee_shm_attach);
	attach->priv = NULL;
	OUTMSG(0);
}
Esempio n. 12
0
rc_t PrintOS(bool xml) {
    int ret = 1;

    struct utsname unameData;
    memset(&unameData, 0, sizeof unameData);

    errno = 0;
    ret = uname(&unameData);
    if (ret != 0) {
        if (xml) {
            OUTMSG(("  <Os>"));
            perror("uname returned : ");
            OUTMSG(("</Os>\n"));
        }
        else {
            perror("uname returned : ");
        }

        return 0;
    }
    else {
        const char *b = xml ? "  <Os>"  : "Operating system: '";
        const char *e = xml ? "</Os>" :                   "'\n";

        return OUTMSG(("%s%s %s %s %s %s%s\n", b,
            unameData.sysname, unameData.nodename, unameData.release,
            unameData.version, unameData.machine, e));
    }
}
Esempio n. 13
0
static void print_digest( uint8_t digest [ 16 ] )
{
    uint8_t i;

    OUTMSG(( "md5-sum: " ));
    for ( i = 0; i < 16; ++i )
        OUTMSG(( "%.02x", digest[ i ] ));
    OUTMSG(( "\n" ));
}
Esempio n. 14
0
static void CoreUsage( const char* prog, const SRADumperFmt* fmt, bool brief, int exit_status )
{
    OUTMSG(( "\n"
             "Usage:\n"
             "  %s [options] <path [path...]>\n"
             "  %s [options] [ -A ] <accession>\n"
             "\n", prog, prog));

    if ( !brief )
    {
        if ( fmt->usage )
        {
            rc_t rc = fmt->usage( fmt, KMainArgs, 1 );
            if ( rc != 0 )
            {
                LOGERR(klogErr, rc, "Usage print failed");
            }
        }
        else
        {
            int k, i;
            const SRADumperFmt_Arg* d[ 2 ] = { KMainArgs, NULL };

            d[ 1 ] = fmt->arg_desc;
            for ( k = 0; k < ( sizeof( d ) / sizeof( d[0] ) ); k++ )
            {
                for ( i = 1;
                      d[k] != NULL && ( d[ k ][ i ].abbr != NULL || d[ k ][ i ].full != NULL );
                      ++ i )
                {
                    if ( ( !fmt->gzip && strcmp( d[ k ][ i ].full, "gzip" ) == 0 ) ||
                         ( !fmt->bzip2 && strcmp (d[ k ][ i ].full, "bzip2" ) == 0 ) )
                    {
                        continue;
                    }
                    if ( k > 0 && i == 0 )
                    {
                        OUTMSG(("\nFormat options:\n\n"));
                    }
                    HelpOptionLine( d[ k ][ i ].abbr, d[ k ][ i ].full,
                                    d[ k ][ i ].param, (const char**)( d[ k ][ i ].descr ) );
                    if ( k == 0 && i == 0 )
                    {
                        OUTMSG(( "\nOptions:\n\n" ));
                    }
                }
            }
        }
    }
    else
    {
        OUTMSG(( "Use option --help for more information\n" ));
    }
    HelpVersion( prog, KAppVersion() );
    exit( exit_status );
}
Esempio n. 15
0
static rc_t walk_ref_iter_position( ReferenceIterator *ref_iter,
                                    struct ReferenceObj const * refobj,
                                    bool skip_empty,
                                    bool nodebug )
{
    INSDC_coord_zero pos;
    uint32_t depth;
    INSDC_4na_bin base;

    rc_t rc = ReferenceIteratorPosition ( ref_iter, &pos, &depth, &base );
    if ( rc != 0 )
    {
        if ( GetRCState( rc ) != rcDone )
            LOGERR( klogInt, rc, "ReferenceIteratorNextPos() failed" );
    }
    else
    {
        rc_t rc1 = 0;
        const char * reference_name = NULL;
        char c = _4na_to_ascii( base, false );
        rc = ReferenceObj_SeqId( refobj, &reference_name );
        if ( rc == 0 )
        {
            OUTMSG(( "%s\t%u\t%c\t%u", reference_name, pos, c, depth ));
            if ( depth > 0 )
            {
                const PlacementRecord *rec;
                rc1 = ReferenceIteratorNextPlacement ( ref_iter, &rec );
                if ( rc1 == 0 )
                {
                    uint8_t qualities[ 4096 ];
                    uint32_t i = 0;
                    OUTMSG(( "\t" ));
                    while ( rc1 == 0 )
                    {
                        handle_base_pos( ref_iter, rec, &( qualities[ i++ ] ), nodebug );
                        rc1 = ReferenceIteratorNextPlacement ( ref_iter, &rec );
                    }
                    OUTMSG(( "\t" ));
                    for ( i = 0; i < depth; ++i )
                    {
                        char c = ( qualities[ i ] + 33 );
                        OUTMSG(( "%c", c ));
                    }
                }
            }
            OUTMSG(( "\n" ));
        }
        if ( GetRCState( rc1 ) == rcDone ) rc1 = 0;
        rc = rc1;
    } 
    return rc;
}
Esempio n. 16
0
static void progress(const char *acc, uint64_t sz,
                     uint64_t srcSz, uint64_t hSrc, char sfSrc, KTime_t date)
{
    if (sz > 0) {
        if (srcSz > 0) {
            uint64_t p = 100 * sz / srcSz;
            char sf = 'B';
            uint64_t fr = 0;
            uint64_t h = humanize(sz, &sf, &fr);
            if (p > 0) {
                if (sfSrc != 'B' && sf != 'B') {
                    if (fr == 0) {
                        if (date == 0) {
                            OUTMSG(("%s %,ld/%,ld %ld%c/%,ld%c %ld%%        \r",
                                    acc, sz, srcSz, h,sf,hSrc,sfSrc,p));
                        }
                        else {
                            OUTMSG(("%s %,ld/%,ld %ld%c/%,ld%c %ld%% %ld    \r",
                                    acc, sz, srcSz, h,sf,hSrc,sfSrc,p,
                                    KTimeStamp() - date));
                        }
                    }
                    else {
                        OUTMSG(("%s %,ld/%,ld %ld.%03ld%c/%,ld%c %ld%%      \r",
                                acc, sz, srcSz,h,fr,sf,hSrc,sfSrc,p));
                    }
                }
                else {
                    OUTMSG(("%s %,ld/%,ld %ld%%                             \r",
                            acc, sz, srcSz, p));
                }
            }
            else {
                if (sfSrc != 'B' && sf != 'B') {
                    if (fr == 0) {
                        OUTMSG((
                                   "%s %,ld/%,ld %ld%c/%ld%c                           \r",
                                   acc, sz,srcSz,h, sf,hSrc,sfSrc));
                    }
                    else {
                        OUTMSG((
                                   "%s %,ld/%,ld %ld.%03ld%c/%ld%c                     \r",
                                   acc, sz,srcSz,h, fr,sf,hSrc,sfSrc));
                    }
                }
                else {
                    OUTMSG(("%s %,ld/%,ld                 \r", acc, sz, srcSz));
                }
            }
        }
        else {
            OUTMSG(("%s %,ld                                     \r", acc, sz));
        }
    }
    else {
        OUTMSG(("                                                \r%s\r", acc));
    }
}
Esempio n. 17
0
void print_ro( const int32_t * RO, uint32_t ro_count )
{
    uint32_t i;

    OUTMSG(( "RO  : { " ));
    for ( i = 0; i < ro_count; ++i)
    {
        if ( i > 0 )
            OUTMSG(( ", %i", RO[i] ));
        else
            OUTMSG(( "%i", RO[i] ));
    }
    OUTMSG(( " }\n" ));
}
Esempio n. 18
0
/* Reverse to KTimePrint for tools/copycat/cctree-dump.c */
static
rc_t CC StrToKTime(const char* str, KTime_t* t)
{
    rc_t rc = 0;

    assert(t);

    if (str) {
        int y, m, d, hr, mn, sc;
        struct tm gmt;
        memset(&gmt, 0, sizeof gmt);
        sscanf(str, "%04d-%02d-%02dT%02d:%02d:%02dZ",
                                &y, &m, &d, &hr, &mn, &sc);
        gmt.tm_year = y - 1900;
        gmt.tm_mon  = m - 1;
        gmt.tm_mday = d;
        gmt.tm_hour = hr;
        gmt.tm_min  = mn;
        gmt.tm_sec  = sc;
        *t = timegm(&gmt);

        if (DEBUG_PRINT) {
            time_t t2 = ( time_t ) * t;
            size_t len;
            char buffer [ 64 ];

            struct tm gmt;
#if SUN
	    gmt = * gmtime ( & t2 );
#else
            gmtime_r ( & t2, & gmt );
#endif
            rc = string_printf ( buffer, sizeof buffer, & len
                , "%04d-%02d-%02dT%02d:%02d:%02dZ"
                , gmt . tm_year + 1900
                , gmt . tm_mon + 1
                , gmt . tm_mday
                , gmt . tm_hour
                , gmt . tm_min
                , gmt . tm_sec
            );
            
            OUTMSG((">> %s\n", str));
            OUTMSG(("<< %s\n", buffer));
        }
    }

    return rc;
}
Esempio n. 19
0
rc_t CC KMain(int argc, char *argv[]) {
    OUTMSG((
"WARNING: vdb-passwd IS OBSOLETE AND SHOULD NOT BE USED.\n"
"\n"
"\n"
"To access dbGaP data you need:\n"
"\n"
"- Make sure you have the latest version of SRA Toolkit installed:\n"
"https://github.com/ncbi/sra-tools/wiki/Downloads\n"
"\n"
"- Have permission to access controlled-access data for a dbGaP project;\n"
"\n"
"- Get dbGaP repository key (ngc file);\n"
"\n"
"- Import the dbGaP repository key to SRA Toolkit.\n"
"  It will set up the project's workspace directory.\n"
"\n"
"- Change directory to the project's workspace.\n"
"\n"
"N.B. MAKE SURE YOU DO NOT HAVE A VDB_PWFILE ENVIRONMENT VARIABLE SET !!!\n"
"\n"
"Now you should be able to work with encrypted data.\n"
"The SRA Toolkit will work with encrypted SRA data files,\n"
"there is no need to decrypt the read data.\n"
"\n"
"The complete instructions are:\n"
"http://www.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?view=toolkit_doc&f=dbgap_use\n"
"\n"
"Send questions/bug reports to [email protected]\n"));
    return RC(rcExe, rcProcess, rcExecuting, rcProcess, rcUnsupported);
}
Esempio n. 20
0
static int _tee_shm_dma_buf_mmap(struct dma_buf *dmabuf,
				struct vm_area_struct *vma)
{
	struct tee_shm *shm = dmabuf->priv;
	size_t size = vma->vm_end - vma->vm_start;
	struct tee *tee;
	int ret;
	pgprot_t prot;
	unsigned long pfn;

	tee = shm->ctx->tee;

	pfn = shm->paddr >> PAGE_SHIFT;

	INMSG();

	if (shm->flags & TEE_SHM_CACHED)
		prot = vma->vm_page_prot;
	else
		prot = pgprot_noncached(vma->vm_page_prot);

	ret =
	    remap_pfn_range(vma, vma->vm_start, pfn, size, prot);
	if (!ret)
		vma->vm_private_data = (void *)shm;

	dev_dbg(_DEV(shm->ctx->tee), "%s: map the shm (p@=%p,s=%dKiB) => %x\n",
		__func__, (void *)shm->paddr, (int)size / 1024,
		(unsigned int)vma->vm_start);

	OUTMSG(ret);
	return ret;
}
Esempio n. 21
0
static rc_t compress_loop( const KFile *src, KFile *dst )
{
    rc_t rc = 0;
    uint64_t pos = 0;
    size_t bsize = 4096;
    size_t num_read = 1;

    char * buffer = malloc( bsize );
    if ( buffer == NULL )
        return RC( rcExe, rcFile, rcPacking, rcMemory, rcExhausted );

    while ( rc == 0 && num_read > 0 )
    {
        rc = KFileRead ( src, pos, buffer, bsize, &num_read );
        DISP_RC( rc, "KFileRead() failed" );
        if ( rc == 0 && num_read > 0 )
        {
            size_t num_writ;
            rc = KFileWrite ( dst, pos, buffer, num_read, &num_writ );
            DISP_RC( rc, "KFilewrite() failed" );
            pos += num_read;
        }
    }
    OUTMSG (( "%lu bytes copied\n", pos ));
    free( buffer );
    return rc;
}
Esempio n. 22
0
static rc_t walk_ref_iter_reference( ReferenceIterator *ref_iter,
                                     struct ReferenceObj const * refobj,
                                     bool skip_empty,
                                     bool nodebug )
{
    rc_t rc = 0;
    while ( rc == 0 )
    {
        INSDC_coord_zero first_pos;
        INSDC_coord_len len;
        rc = ReferenceIteratorNextWindow ( ref_iter, &first_pos, &len );
        if ( rc != 0 )
        {
            if ( GetRCState( rc ) != rcDone )
                LOGERR( klogInt, rc, "ReferenceIteratorNextWindow() failed" );
        }
        else
        {
            OUTMSG(( "walking ref-iter on window: ( from %u to %u )\n",
                     first_pos, first_pos + len - 1 ));
            rc = walk_ref_iter_window( ref_iter, refobj, skip_empty, nodebug );
        }
    }
    if ( GetRCState( rc ) == rcDone ) rc = 0;
    return rc;
}
Esempio n. 23
0
/* Resume all artificially suspended threads if we are continuing
   execution.  */
static int
continue_one_thread (struct inferior_list_entry *this_thread, void *id_ptr)
{
  struct thread_info *thread = (struct thread_info *) this_thread;
  int thread_id = * (int *) id_ptr;
  win32_thread_info *th = inferior_target_data (thread);

  if ((thread_id == -1 || thread_id == th->tid)
      && th->suspended)
    {
      if (th->context.ContextFlags)
	{
	  win32_set_thread_context (th);
	  th->context.ContextFlags = 0;
	}

      if (ResumeThread (th->h) == (DWORD) -1)
	{
	  DWORD err = GetLastError ();
	  OUTMSG (("warning: ResumeThread failed in continue_one_thread, "
		   "(error %d): %s\n", (int) err, strwinerror (err)));
	}
      th->suspended = 0;
    }

  return 0;
}
Esempio n. 24
0
/* Find a thread record given a thread id.  If GET_CONTEXT is set then
   also retrieve the context for this thread.  */
static win32_thread_info *
thread_rec (ptid_t ptid, int get_context)
{
  struct thread_info *thread;
  win32_thread_info *th;

  thread = (struct thread_info *) find_inferior_id (&all_threads, ptid);
  if (thread == NULL)
    return NULL;

  th = inferior_target_data (thread);
  if (get_context && th->context.ContextFlags == 0)
    {
      if (!th->suspended)
	{
	  if (SuspendThread (th->h) == (DWORD) -1)
	    {
	      DWORD err = GetLastError ();
	      OUTMSG (("warning: SuspendThread failed in thread_rec, "
		       "(error %d): %s\n", (int) err, strwinerror (err)));
	    }
	  else
	    th->suspended = 1;
	}

      win32_get_thread_context (th);
    }

  return th;
}
Esempio n. 25
0
static rc_t walk_ref_iter( ReferenceIterator *ref_iter,
                           bool skip_empty,
                           bool nodebug )
{
    rc_t rc = 0;
    while( rc == 0 )
    {
        struct ReferenceObj const * refobj;
        INSDC_coord_zero first_pos;
        INSDC_coord_len len;
        rc = ReferenceIteratorNextReference( ref_iter, &first_pos, &len, &refobj );
        if ( rc == 0 && refobj != NULL )
        {
            const char *name;
            rc = ReferenceObj_SeqId( refobj, &name );
            if ( rc != 0 )
                LOGERR( klogInt, rc, "ReferenceObj_SeqId() failed" );
            else
            {
                OUTMSG(( "walking ref-iter on reference: >%s< ( from %u to %u )\n",
                         name, first_pos, first_pos + len - 1 ));
                rc = walk_ref_iter_reference( ref_iter, refobj, skip_empty, nodebug );
            }
        }
    }
    if ( GetRCState( rc ) == rcDone ) rc = 0;
    return rc;
}
Esempio n. 26
0
/*
 * This function initializes a new TEE Context, connecting this Client
 * application to the TEE identified by the name name.
 *
 * name == NULL will give the default TEE.
 */
TEEC_Result TEEC_InitializeContext(const char *name, TEEC_Context *context)
{
	int name_size = 0;
	const char* _name = name;

	INMSG("%s", name);

	if (context == NULL)
		return TEEC_ERROR_BAD_PARAMETERS;

	/*
	 * Specification says that when no name is provided it should fall back
	 * on a predefined TEE.
	 */
	if (name == NULL)
		_name = TEE_TZ_DEVICE_NAME;

	name_size = snprintf(context->devname, TEEC_MAX_DEVNAME_SIZE,
			     "/dev/%s", _name);

	if (name_size >= TEEC_MAX_DEVNAME_SIZE)
		return TEEC_ERROR_BAD_PARAMETERS; /* Device name truncated */

	context->fd = open(context->devname, O_RDWR);
	if (context->fd == -1)
		return TEEC_ERROR_ITEM_NOT_FOUND;

	pthread_mutex_init(&mutex, NULL);

	OUTMSG("");
	return TEEC_SUCCESS;
}
Esempio n. 27
0
static rc_t write_statistic( statistic_writer *writer, statistic *data,
                             uint64_t * written, bool show_progress )
{
    writer_ctx ctx;
    uint64_t count;

    ctx.writer = writer;
    ctx.rc = 0;
    ctx.progress = NULL;

    if ( show_progress )
    {
        make_progressbar( &ctx.progress );
        ctx.entries = data->entries;
        ctx.fract_digits = progressbar_calc_fract_digits( ctx.entries );
        ctx.n = 0;
    }

    count = foreach_statistic( data, write_cb, &ctx );

    if ( show_progress )
    {
        destroy_progressbar( ctx.progress );
        OUTMSG(( "\n" ));
    }

    if ( written != NULL ) *written = count;

    return ctx.rc;
}
Esempio n. 28
0
rc_t CC Usage (const Args * args)
{
    const char * progname = UsageDefaultName;
    const char * fullpath = UsageDefaultName;
    rc_t rc;

    if (args == NULL)
        rc = RC (rcApp, rcArgv, rcAccessing, rcSelf, rcNull);
    else
        rc = ArgsProgram (args, &fullpath, &progname);

    UsageSummary (progname);

    OUTMSG (("Options:\n"));

    rc = string_printf (buff, sizeof buff, NULL, "%s", tablePath);

    HelpOptionLine (ALIAS_TABLE, OPTION_TABLE, "path", table_usage);

    rc = string_printf (buff, sizeof buff, NULL, "Number of Rows.  Defaults to %u", ROWS);

    HelpOptionLine (ALIAS_ROW, OPTION_ROW, "row", row_usage);

    HelpOptionsStandard ();

    HelpVersion (fullpath, KAppVersion());

    return rc;
}
Esempio n. 29
0
static void CC whack_ref_node( BSTNode *n, void *data )
{
    ref_node * node = ( ref_node * )n;
    bool * info = ( bool * )data;

    if ( *info )
    {
        OUTMSG(( "node >%S< used for %lu bytes (%lu active)\n",
                  node->name, node->bytes_requested, node->active_positions ));
    }

    if ( node->cur != NULL )
    {
        VCursorRelease( node->cur );
    }
    if ( node->tab != NULL )
    {
        VTableRelease( node->tab );
    }
    if ( node->name != NULL )
    {
        StringWhack ( node->name );
    }
    free( n );
}
Esempio n. 30
0
rc_t CC UsageSummary ( const char * progname )
{
    OUTMSG ( ("\n"
        "Usage:\n"
        "  %s writable_object(s)\n"
        "\n", progname) );
    return 0;
}