Example #1
0
/*
 * Convert node address to outbound base name
 */
char *bink_out_name(Node *node)
{
    static char buf[MAXPATH];
    char *out, *outbound;
    
#ifndef AMIGADOS_4D_OUTBOUND
    out = cf_zones_out(node->zone);
#else
    out = cf_zones_out(0);
#endif
    if(!out)
	return NULL;
    outbound = cf_p_btbasedir();
    if(!outbound)
	return NULL;

#ifdef AMIGADOS_4D_OUTBOUND
    str_printf(buf, sizeof(buf), "%s/%s/%d.%d.%d.%d.",
	       outbound, out, node->zone,
	       node->net, node->node, node->point);
#else    
    if(node->point > 0)
	str_printf(buf, sizeof(buf), "%s/%s/%04x%04x.pnt/0000%04x.",
		   outbound, out, node->net, node->node, node->point);
    else
	str_printf(buf, sizeof(buf), "%s/%s/%04x%04x.",
		   outbound, out, node->net, node->node);
#endif /**AMIGADOS_4D_OUTBOUND**/

    return buf;
}
Example #2
0
static void get_prompt_str(struct gstr *r, struct property *prop)
{
	int i, j;
	struct menu *submenu[8], *menu;

	str_printf(r, _("Prompt: %s\n"), _(prop->text));
	str_printf(r, _("  Defined at %s:%d\n"), prop->menu->file->name,
		prop->menu->lineno);
	if (!expr_is_yes(prop->visible.expr)) {
		str_append(r, _("  Depends on: "));
		expr_gstr_print(prop->visible.expr, r);
		str_append(r, "\n");
	}
	menu = prop->menu->parent;
	for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
		submenu[i++] = menu;
	if (i > 0) {
		str_printf(r, _("  Location:\n"));
		for (j = 4; --i >= 0; j += 2) {
			menu = submenu[i];
			str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
			if (menu->sym) {
				str_printf(r, " (%s [=%s])", menu->sym->name ?
					menu->sym->name : _("<choice>"),
					sym_get_string_value(menu->sym));
			}
			str_append(r, "\n");
		}
	}
}
Example #3
0
File: gpu.c Project: abhaykadam/vm
void vgpu_uop_get_markup(struct vgpu_uop_t *uop, char *buf_ptr, int buf_size)
{
	char vliw_elems[5] = { 'x', 'y', 'z', 'w', 't' };
	char *uop_color[3] = { "darkgreen", "red", "blue" };

	int i;

	if (uop->engine == VGPU_ENGINE_ALU)
	{
		str_printf(&buf_ptr, &buf_size, "<span color=\"%s\">",
			uop_color[uop->engine]);
		for (i = 0; i < 5; i++)
		{
			if (uop->vliw_slot[i][0])
				str_printf(&buf_ptr, &buf_size, "  <b>%c:</b> %s",
					vliw_elems[i], uop->vliw_slot[i]);
		}
		str_printf(&buf_ptr, &buf_size, "</span>");
	}
	else
	{
		str_printf(&buf_ptr, &buf_size, "<span color=\"%s\">%s</span>",
			uop_color[uop->engine], uop->name);
	}
}
Example #4
0
char * playback_get_title (void)
{
    g_return_val_if_fail (playing, NULL);
    wait_until_ready ();

    char s[32];

    if (current_length)
    {
        int len = current_length / 1000;

        if (len < 3600)
            snprintf (s, sizeof s, get_bool (NULL, "leading_zero") ?
             " (%02d:%02d)" : " (%d:%02d)", len / 60, len % 60);
        else
            snprintf (s, sizeof s, " (%d:%02d:%02d)", len / 3600, (len / 60) %
             60, len % 60);
    }
    else
        s[0] = 0;

    if (get_bool (NULL, "show_numbers_in_pl"))
        return str_printf ("%d. %s%s", 1 + playlist_get_position
         (playlist_get_playing ()), current_title, s);

    return str_printf ("%s%s", current_title, s);
}
Example #5
0
void mips_inst_dump_RD(char **inst_str_ptr, int *inst_str_size,
	struct mips_inst_t *inst)
{
	unsigned int rd;
	int token_len;

	rd = inst->dword.standard.rd;

	if (mips_token_comp(inst->info->name, "RDHWR", &token_len))
		str_printf(inst_str_ptr, inst_str_size, "$%d", rd);
	else if (mips_token_comp(inst->info->name, "JALR", &token_len))
	{
		if (rd == (int) 31)
		{
		}
		else
		{
			str_printf(inst_str_ptr, inst_str_size, ",");
			str_printf(inst_str_ptr, inst_str_size, "%s",
				mips_reg_name[rd]);
		}
	}
	else
		str_printf(inst_str_ptr, inst_str_size, "%s",
			mips_reg_name[rd]);
}
Example #6
0
    /* log the line to the UI (GUI, stderr, etc.) */
    if(log_mode==LOG_MODE_ERROR ||
            (log_mode==LOG_MODE_INFO && level<LOG_DEBUG) ||
#if defined(USE_WIN32) || defined(USE_JNI)
            level<=opt->log_level
#else
            (level<=opt->log_level &&
            global_options.option.log_stderr)
#endif
            )
        ui_new_log(line);

    str_free(line);
}

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat-extra-args"
#endif /* __GNUC__ */
char *log_id(CLI *c) {
    const char table[62]=
        "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    unsigned char rnd[22];
    char *uniq;
    size_t i;
    unsigned long tid;

    switch(c->opt->log_id) {
    case LOG_ID_SEQUENTIAL:
        return str_printf("%llu", c->seq);
    case LOG_ID_UNIQUE:
        if(RAND_bytes(rnd, sizeof rnd)<=0) /* log2(62^22)=130.99 */
            return str_dup("error");
        for(i=0; i<sizeof rnd; ++i) {
            rnd[i]&=63;
            while(rnd[i]>=62) {
                if(RAND_bytes(rnd+i, 1)<=0)
                    return str_dup("error");
                rnd[i]&=63;
            }
        }
        uniq=str_alloc(sizeof rnd+1);
        for(i=0; i<sizeof rnd; ++i)
            uniq[i]=table[rnd[i]];
        uniq[sizeof rnd]='\0';
        return uniq;
    case LOG_ID_THREAD:
        tid=stunnel_thread_id();
        if(!tid) /* currently USE_FORK */
            tid=stunnel_process_id();
        return str_printf("%lu", tid);
    }
    return str_dup("error");
}
Example #7
0
File: mconf.c Project: 16rd/rt-n56u
static void get_symbol_str(struct gstr *r, struct symbol *sym)
{
	bool hit;
	struct property *prop;

	if (sym && sym->name)
		str_printf(r, "Symbol: %s [=%s]\n", sym->name,
		                                    sym_get_string_value(sym));
	for_all_prompts(sym, prop)
		get_prompt_str(r, prop);
	hit = false;
	for_all_properties(sym, prop, P_SELECT) {
		if (!hit) {
			str_append(r, "  Selects: ");
			hit = true;
		} else
			str_printf(r, " && ");
		expr_gstr_print(prop->expr, r);
	}
	if (hit)
		str_append(r, "\n");
	if (sym->rev_dep.expr) {
		str_append(r, _("  Selected by: "));
		expr_gstr_print(sym->rev_dep.expr, r);
		str_append(r, "\n");
	}
	str_append(r, "\n\n");
}
Example #8
0
uint     STDCALL os_dirdeletefull( pstr name )
{
 #ifdef WINDOWS
   str  stemp;
   WIN32_FIND_DATA  data;
   pvoid            find;

   str_init( &stemp );
   str_printf( &stemp, "%s%c*.*", str_ptr( name ), SLASH );
   find = FindFirstFile( str_ptr( &stemp ), &data );
   if ( find != INVALID_HANDLE_VALUE )
   {
      do {
         if ( data.cFileName[0] == '.' && ( !data.cFileName[1] ||
            ( data.cFileName[1] == '.' && !data.cFileName[2] )))
            continue;

         str_printf( &stemp, "%s%c%s", str_ptr( name ), SLASH, data.cFileName );

         if ( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
            os_dirdeletefull( &stemp );
         else
            os_filedelete( &stemp );

      } while ( FindNextFile( find, &data ));

      FindClose( find );
   }
   str_delete( &stemp );
 #endif
   return os_dirdelete( name );
}
Example #9
0
File: gpu.c Project: abhaykadam/vm
void work_group_info_popup(void *item)
{
	char buf[10000];

	char *buf_ptr = buf;
	int buf_size = sizeof buf;

	struct vgpu_work_group_t *work_group = item;
	if (!work_group)
		return;
	
	/* Text */
	str_printf(&buf_ptr, &buf_size, "<b>Work-Group %d</b>\n"
		"\n", work_group->id);
	
	/* Work-items and wavefronts */
	str_printf(&buf_ptr, &buf_size,
		"Name:         <b>WG-%d</b>\n"
		"Work-items:   [ <b>WI-%d</b> ... <b>WI-%d</b> ]  (%d work-items)\n"
		"Wavefronts:   [ <b>WF-%d</b> ... <b>WF-%d</b> ]  (%d wavefronts)\n"
		"\n",
		work_group->id,
		work_group->work_item_id_first, work_group->work_item_id_last, work_group->work_item_count,
		work_group->wavefront_id_first, work_group->wavefront_id_last, work_group->wavefront_count);
	
	/* Show */
	info_popup_show(buf);
}
Example #10
0
	PSLIST_FOREACH(info, sl) {
		cq_info_t *cqi = sl->data;

		cq_info_check(cqi);

		if (THREAD_INVALID_ID == cqi->stid)
			str_printf(s, "%-2s ", "-");
		else
			str_printf(s, "%-2d ", cqi->stid);
		str_catf(s, "%-6zu ", cqi->event_count);
		str_catf(s, "%-4zu ", cqi->periodic_count);
		str_catf(s, "%-4zu ", cqi->idle_count);
		str_catf(s, "%-5s ",
			0 == cqi->last_idle ?
				"-" : compact_time(delta_time(tm_time(), cqi->last_idle)));
		str_catf(s, "%'6d ", cqi->period);
		str_catf(s, "%10zu ", cqi->heartbeat_count);
		str_catf(s, "%10zu ", cqi->triggered_count);
		str_catf(s, "\"%s\"%*s", cqi->name,
			(int) (maxlen - vstrlen(cqi->name)), "");
		if (cqi->parent != NULL)
			str_catf(s, " (%s)", cqi->parent);
		str_putc(s, '\n');
		shell_write(sh, str_2c(s));
	}
Example #11
0
/** Prints binary data similar to the Unix hexdump command.  The output is configurable via the HexdumpFormat argument.  This
 *  is the most general hexdump function. All others should be implemented in terms of this one. */
void
SgAsmExecutableFileFormat::hexdump(std::ostream &f, rose_addr_t base_addr, const unsigned char *data,
                                   size_t n, const HexdumpFormat &fmt)
{
    /* Provide default formats. This is done here so that the header file doesn't depend on <inttypes.h> */
    const char *addr_fmt = fmt.addr_fmt ? fmt.addr_fmt : "0x%08"PRIx64":";
    const char *numeric_fmt = fmt.numeric_fmt ? fmt.numeric_fmt : " %02x";
    const char *prefix = fmt.prefix ? fmt.prefix : "";

    char s[1024];
    sprintf(s, numeric_fmt, 0u);
    int numeric_width = strlen(s);

    if (fmt.multiline)
        f <<prefix;

    for (size_t i=0; i<n; i+=fmt.width) {
        /* Prefix and/or address */
        if (i>0)
            f <<"\n" <<prefix;
        f <<str_printf(addr_fmt, base_addr+i);

        /* Numeric byte values */
        if (fmt.show_numeric) {
            for (size_t j=0; j<fmt.width; j++) {
                if (i+j<n) {
                    if (j>0 && 0 == j % fmt.colsize)
                        f <<" ";
                    f <<str_printf(numeric_fmt, data[i+j]);
                } else if (fmt.pad_numeric) {
                    if (j>0 && 0 == j % fmt.colsize)
                        f <<" ";
                    f <<str_printf("%*s", numeric_width, "");
                }
            }
        }

        if (fmt.show_numeric && fmt.show_chars)
            f <<" |";
        
        /* Character byte values */
        if (fmt.show_chars) {
            for (size_t j=0; j<fmt.width; j++) {
                if (i+j>=n) {
                    if (fmt.pad_chars)
                        f <<" ";
                } else if (isprint(data[i+j])) {
                    f <<data[i+j];
                } else {
                    f <<".";
                }
            }
            f <<"|";
        }
    }

    if (fmt.multiline)
        f <<"\n";
}
Example #12
0
/*********************************************************************************
 *                           Dump functions
 ********************************************************************************/
void mips_inst_dump_SA(char **inst_str_ptr, int *inst_str_size,
                       struct mips_inst_t *inst) {
  unsigned int sa;

  sa = inst->dword.standard.sa;
  if (sa != 0)
    str_printf(inst_str_ptr, inst_str_size, "0x%x", sa);
  else
    str_printf(inst_str_ptr, inst_str_size, "%d", sa);
}
Example #13
0
/* Get a list of all possible names for architectures. This function is usefull
 * to print an error message with the valid values for architectures when
 * processing user input. */
void arch_get_names(char *str, int size) {
  char *comma = "";
  int i;

  str_printf(&str, &size, "{");
  for (i = 0; i < arch_list_count; i++) {
    str_printf(&str, &size, "%s%s", comma, arch_list[i]->name);
    comma = "|";
  }
  str_printf(&str, &size, "}");
}
Example #14
0
void nodeapp_compute_paths() {
    nodeapp_compute_paths_osdep();

    nodeapp_bundled_node_path = getenv(NODEAPP_NODE_BINARY_OVERRIDE_ENVVAR);
    if (!nodeapp_bundled_node_path || !*nodeapp_bundled_node_path)
        nodeapp_bundled_node_path = str_printf("%s/%s", nodeapp_bundled_resources_dir, NODEAPP_NODE_BINARY);

    nodeapp_bundled_backend_js = getenv(NODEAPP_BACKEND_JS_OVERRIDE_ENVVAR);
    if (!nodeapp_bundled_backend_js || !*nodeapp_bundled_backend_js)
        nodeapp_bundled_backend_js = str_printf("%s/%s", nodeapp_bundled_resources_dir, NODEAPP_BACKEND_JS);
}
Example #15
0
void mips_inst_dump_FS(char **inst_str_ptr, int *inst_str_size,
                       struct mips_inst_t *inst) {
  unsigned int fs;
  int token_len;

  fs = inst->dword.standard.rd;
  if ((mips_token_comp(inst->info->name, "CFC1", &token_len)) ||
      (mips_token_comp(inst->info->name, "CTC1", &token_len)))
    str_printf(inst_str_ptr, inst_str_size, "$%d", fs);
  else
    str_printf(inst_str_ptr, inst_str_size, "$f%d", fs);
}
Example #16
0
void Timed::unix_signal(int signo)
{
  switch(signo)
  {
    default:
      log_info("unix signal %d [%s] detected", signo, strsignal(signo)) ;
      break ;
    case SIGCHLD:
      int status ;
      while(pid_t pid = waitpid(-1, &status, WNOHANG))
      {
        if(pid==-1 && errno==EINTR)
        {
          log_info("waitpid() interrupted, retrying...") ;
          continue ;
        }
        else if(pid==-1)
        {
          if(errno!=ECHILD)
            log_error("waitpid() failed: %m") ;
          break ;
        }
        unsigned cookie = children.count(pid) ? children[pid] : 0 ;
        string name = str_printf("the child pid=%d", pid) ;
        if(cookie)
          name += str_printf(" [cookie=%d]", cookie) ;
        else
          name += " (unknown cookie)" ;
        if(WIFEXITED(status))
          log_info("%s exited with status %d", name.c_str(), WEXITSTATUS(status)) ;
        else if(WIFSIGNALED(status))
          log_info("%s killed by signal %d", name.c_str(), WTERMSIG(status)) ;
        else
        {
          log_info("%s changed status", name.c_str()) ;
          continue ;
        }
        children.erase(pid) ;
      }
      break ;
    case SIGINT:
      log_info("Keyboard interrupt, oh weh... bye") ;
      quit() ;
      break ;
    case SIGTERM:
      log_info("Termination signal... bye") ;
      quit() ;
      break ;
  }
}
Example #17
0
static bool_t metronom_get_cp(const char *filename, metronom_t *pmetronom, char **str)
{
    int count;

    count = sscanf(filename, "tact://%d*%d/%d",
        &pmetronom->bpm, &pmetronom->num, &pmetronom->den);

    if (count != 1 && count != 3)
        return FALSE;

    if (pmetronom->bpm < MIN_BPM || pmetronom->bpm > MAX_BPM)
        return FALSE;

    if (count == 1)
    {
        pmetronom->num = 1;
        pmetronom->den = 1;
        pmetronom->id = 0;
    }
    else
    {
        bool_t flag;
        int id;

        if (pmetronom->num == 0 || pmetronom->den == 0)
            return FALSE;

        flag = FALSE;
        for (id = 0; id < TACT_ID_MAX && !flag; id++)
        {
            if (pmetronom->num == tact_id[id][0] && pmetronom->den == tact_id[id][1])
                flag = TRUE;
        }

        if (!flag)
            return FALSE;
        else
            pmetronom->id = id;
    }

    if (str == NULL)
        return TRUE;

    if (pmetronom->num == 1 && pmetronom->den == 1)
        *str = str_printf (_("Tact generator: %d bpm"), pmetronom->bpm);
    else
        *str = str_printf (_("Tact generator: %d bpm %d/%d"), pmetronom->bpm, pmetronom->num, pmetronom->den);

    return TRUE;
}
Example #18
0
void menu_get_ext_help(struct menu *menu, struct gstr *help)
{
    struct symbol *sym = menu->sym;
    const char *help_text = nohelp_text;

    if (menu_has_help(menu)) {
        if (sym->name)
            str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
        help_text = menu_get_help(menu);
    }
    str_printf(help, "%s\n", _(help_text));
    if (sym)
        get_symbol_str(help, sym, NULL);
}
Example #19
0
void test_printf(void) {
    str test;
    str_create(&test);
    str_printf(&test, "%s, %d\n", "this is a test", 100);

    CU_ASSERT(test.len == 20);
    CU_ASSERT_PTR_NOT_NULL(test.data);
    CU_ASSERT(test.data[20] == 0);

    str_printf(&test, "over %d thousaaand!\n", 9);

    CU_ASSERT(test.len == 39);
    CU_ASSERT_PTR_NOT_NULL(test.data);
    CU_ASSERT(test.data[39] == 0);
}
Example #20
0
static void _findMetaXMLfiles(META_ROOT *meta, const char *device_path)
{
    BD_DIR_H *dir;
    BD_DIRENT ent;
    char *path = NULL;
    path = str_printf("%s" DIR_SEP "BDMV" DIR_SEP "META" DIR_SEP "DL", device_path);
    dir = dir_open(path);
    if (dir == NULL) {
        BD_DEBUG(DBG_DIR, "Failed to open meta dir %s\n", path);
        X_FREE(path);
        return;
    }
    int res;
    for (res = dir_read(dir, &ent); !res; res = dir_read(dir, &ent)) {
        if (ent.d_name[0] == '.')
            continue;
        else if (ent.d_name != NULL && strncasecmp(ent.d_name, "bdmt_", 5) == 0) {
            uint8_t i = meta->dl_count;
            meta->dl_count++;
            meta->dl_entries = realloc(meta->dl_entries, (meta->dl_count*sizeof(META_DL)));
            meta->dl_entries[i].filename = str_dup(ent.d_name);
            strncpy(meta->dl_entries[i].language_code, ent.d_name+5,3);
            meta->dl_entries[i].language_code[3] = '\0';
            str_tolower(meta->dl_entries[i].language_code);
        }
    }
    dir_close(dir);
    X_FREE(path);
}
Example #21
0
static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
{
	struct gstr *gs = (struct gstr*)data;
	const char *sym_str = NULL;

	if (sym)
		sym_str = sym_get_string_value(sym);

	if (gs->max_width) {
		unsigned extra_length = strlen(str);
		const char *last_cr = strrchr(gs->s, '\n');
		unsigned last_line_length;

		if (sym_str)
			extra_length += 4 + strlen(sym_str);

		if (!last_cr)
			last_cr = gs->s;

		last_line_length = strlen(gs->s) - (last_cr - gs->s);

		if ((last_line_length + extra_length) > gs->max_width)
			str_append(gs, "\\\n");
	}

	str_append(gs, str);
	if (sym)
		str_printf(gs, " [=%s]", sym_str);
}
Example #22
0
void mips_inst_dump_RT(char **inst_str_ptr, int *inst_str_size,
                       struct mips_inst_t *inst) {
  unsigned int rt;

  rt = inst->dword.standard.rt;
  str_printf(inst_str_ptr, inst_str_size, "%s", mips_reg_name[rt]);
}
Example #23
0
NOEXPORT int create_pid(void) {
    int pf;
    char *pid;

    if(!global_options.pidfile) {
        s_log(LOG_DEBUG, "No pid file being created");
        return 0;
    }
    if(global_options.pidfile[0]!='/') {
        /* to prevent creating pid file relative to '/' after daemonize() */
        s_log(LOG_ERR, "Pid file (%s) must be full path name", global_options.pidfile);
        return 1;
    }
    global_options.dpid=(unsigned long)getpid();

    /* silently remove old pid file */
    unlink(global_options.pidfile);
    pf=open(global_options.pidfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644);
    if(pf==-1) {
        s_log(LOG_ERR, "Cannot create pid file %s", global_options.pidfile);
        ioerror("create");
        return 1;
    }
    pid=str_printf("%lu\n", global_options.dpid);
    if(write(pf, pid, strlen(pid))<(int)strlen(pid)) {
        s_log(LOG_ERR, "Cannot write pid file %s", global_options.pidfile);
        ioerror("write");
        return 1;
    }
    str_free(pid);
    close(pf);
    s_log(LOG_DEBUG, "Created pid file %s", global_options.pidfile);
    atexit(delete_pid);
    return 0;
}
Example #24
0
static int _load_aes_keys(bdplus_aes_key_t *aes_keys, const char *base)
{
    char *path = str_printf("%s/" AES_KEYS_FILE, base);
    uint8_t *keys;
    uint32_t size = 0;
    uint32_t num_keys, ii;

    if (!path) {
        return -1;
    }

    keys = (uint8_t *)file_load(path, &size);
    X_FREE(path);

    num_keys = size / 16;
    if (num_keys > MAX_AES_KEYS) {
        num_keys = MAX_AES_KEYS;
    }
    if (num_keys * 16 != size) {
        BD_DEBUG(DBG_FILE | DBG_CRIT, "Invalid AES key file size\n");
    }

    for (ii = 0; ii < num_keys; ii++) {
        memcpy(aes_keys[ii].key, keys + 16*ii, 16);
    }

    X_FREE(keys);
    return num_keys > 6 ? (int)num_keys : -1;
}
Example #25
0
void output_invocation(long syscall_id, syscall_arg *args)
{
    char str[MAX_LINE_SIZE];
    const syscall_info *info;
    int written;
    unsigned i;

    info = get_syscall_info(syscall_id);
    if (info) {
        written = snprintf(str, MAX_LINE_SIZE, "%s(", info->name);
        if (info->arg_count) {
            write_arg(args[0], info->args_type[0], str, &written);
            for (i = 1; i < info->arg_count; ++i) {
                str_printf(str, &written, ", ");
                write_arg(args[i], info->args_type[i], str, &written);
            }
        }
        written = written > MAX_LINE_SIZE ? MAX_LINE_SIZE : written;
        snprintf(str + written, MAX_LINE_SIZE - written, ")");
    }
    else
        snprintf(str, MAX_LINE_SIZE, PLACEHOLDER_TEXT" (%ld)", syscall_id);

    fprintf(stderr, "%-*s", MIN_PADDING - 1, str);
}
Example #26
0
static int _bdj_init(BDJAVA *bdjava, JNIEnv *env)
{
    // initialize class org.videolan.Libbluray
    jclass init_class;
    jmethodID init_id;
    if (!bdj_get_method(env, &init_class, &init_id,
                        "org/videolan/Libbluray", "init", "(JLjava/lang/String;)V")) {
        return 0;
    }

    char* id_path = str_printf("%s/CERTIFICATE/id.bdmv", bdjava->path);
    BDID_DATA *id  = bdid_parse(id_path);
    jlong param_bdjava_ptr = (jlong)(intptr_t) bdjava;
    jstring param_disc_id = (*env)->NewStringUTF(env,
                                                 id ? id->disc_id : "00000000000000000000000000000000");
    (*env)->CallStaticVoidMethod(env, init_class, init_id,
                                 param_bdjava_ptr, param_disc_id);
    (*env)->DeleteLocalRef(env, init_class);
    (*env)->DeleteLocalRef(env, param_disc_id);

    free(id_path);
    bdid_free(&id);

    return 1;
}
Example #27
0
static void x86_inst_moffs_addr_dump_buf(struct x86_inst_t *inst, char **pbuf, int *psize)
{
	enum x86_inst_reg_t reg;

	reg = inst->segment ? inst->segment : x86_inst_reg_ds;
	str_printf(pbuf, psize, "%s:0x%x", str_map_value(&x86_inst_reg_map, reg), inst->imm.d);
}
Example #28
0
BDPLUS_FILE_H *file_open_default(void *handle, const char* file_name)
{
    const char    *device_root = handle;
    char          *file_path;
    BDPLUS_FILE_H *file;
    FILE          *fp;

    file_path = str_printf("%s"DIR_SEP"%s", device_root, file_name);
    if (!file_path) {
        BD_DEBUG(DBG_CRIT, "out of memory\n");
        return NULL;
    }

    fp = fopen(file_path, "rb");
    X_FREE(file_path);

    if (!fp) {
        return NULL;
    }

    file = calloc(1, sizeof(BDPLUS_FILE_H));
    file->internal = fp;
    file->close    = _file_close;
    file->seek     = _file_seek;
    file->read     = _file_read;

    return file;
}
Example #29
0
static void X86InstMoffsAddrDumpBuf(X86Inst *self, char **pbuf, int *psize)
{
	X86InstReg reg;

	reg = self->segment ? self->segment : X86InstRegDs;
	str_printf(pbuf, psize, "%s:0x%x", str_map_value(&x86_inst_reg_map, reg), self->imm.d);
}
Example #30
0
static void ExcDump(const string& ModuleName,LPCWSTR Exception,LPVOID Adress)
{
	string strAddr = str_printf(L"0x%p",Adress);

	string Msg[4];
	if (LanguageLoaded())
	{
		Msg[0] = MSG(MExcException);
		Msg[1] = MSG(MExcAddress);
		Msg[2] = MSG(MExcFunction);
		Msg[3] = MSG(MExcModule);
	}
	else
	{
		Msg[0] = L"Exception:";
		Msg[1] = L"Address:  ";
		Msg[2] = L"Function: ";
		Msg[3] = L"Module:   ";
	}

	string Dump =
		Msg[0] + L" " + Exception + L"\n" +
		Msg[1] + L" " + strAddr + L"\n" +
		Msg[2] + L" " + From + L"\n" +
		Msg[3] + L" " + ModuleName + L"\n";

	std::wcerr << Dump << std::endl;
}