Esempio n. 1
0
static void idaapi s_py_get_user_defined_prefix(
  ea_t ea,
  int lnnum,
  int indent,
  const char *line,
  char *buf,
  size_t bufsize)
{
  PYW_GIL_GET;
  newref_t py_ret(
          PyObject_CallFunction(
                  py_get_user_defined_prefix,
                  PY_FMT64 "iis" PY_FMT64,
                  ea, lnnum, indent, line, bufsize));

  // Error? Display it
  // No error? Copy the buffer
  if ( !PyW_ShowCbErr("py_get_user_defined_prefix") )
  {
    Py_ssize_t py_len;
    char *py_str;
    if ( PyString_AsStringAndSize(py_ret.o, &py_str, &py_len) != -1 )
    {
      memcpy(buf, py_str, qmin(bufsize, py_len));
      if ( py_len < bufsize )
        buf[py_len] = '\0';
    }
  }
}
Esempio n. 2
0
static void idaapi s_py_get_user_defined_prefix(
        qstring *buf,
        ea_t ea,
        int lnnum,
        int indent,
        const char *line)
{
  PYW_GIL_GET;
  newref_t py_ret(
          PyObject_CallFunction(
                  py_get_user_defined_prefix,
                  PY_BV_EA "iis" PY_BV_SZ,
                  bvea_t(ea), lnnum, indent, line));

  // Error? Display it
  // No error? Copy the buffer
  if ( !PyW_ShowCbErr("py_get_user_defined_prefix") )
  {
    Py_ssize_t py_len;
    char *py_str;
    if ( PyString_AsStringAndSize(py_ret.o, &py_str, &py_len) != -1 )
    {
      buf->qclear();
      buf->append(py_str, py_len);
    }
  }
}