Beispiel #1
0
int parse_sem_id(char *entry)
{
	char 	*parm;
	int 	iter, indx1 = 0, indx2;

	while(entry[indx1] == ' ')
		indx1++;
	while(entry[indx1] && entry[indx1] != ' ')
		indx1++;
	while(entry[indx1] == ' ')
		indx1++;
	if ('\0' == entry[indx1])
	{
		assert(FALSE);
		return -1;
	}
	indx2 = indx1;
	parm = &entry[indx1];
	while(entry[indx2] && entry[indx2] != ' ')
		indx2++;
	entry[indx2] = '\0';
	if (cli_is_dcm(parm))
		return (int)STRTOUL(parm, NULL, 10);
	else if (cli_is_hex(parm + 2))
		return (int)STRTOUL(parm, NULL, 16);
	else
	{
		assert(FALSE);
		return -1;
	}
}
void
acpi_db_dump_namespace_by_owner (
	NATIVE_CHAR             *owner_arg,
	NATIVE_CHAR             *depth_arg)
{
	acpi_handle             subtree_entry = acpi_gbl_root_node;
	u32                     max_depth = ACPI_UINT32_MAX;
	u16                     owner_id;


	owner_id = (u16) STRTOUL (owner_arg, NULL, 0);


	/* Now we can check for the depth argument */

	if (depth_arg) {
		max_depth = STRTOUL (depth_arg, NULL, 0);
	}


	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
	acpi_os_printf ("ACPI Namespace by owner %X:\n", owner_id);

	/* Display the subtree */

	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
	acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth, owner_id, subtree_entry);
	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
}
void
acpi_db_dump_namespace (
	NATIVE_CHAR             *start_arg,
	NATIVE_CHAR             *depth_arg)
{
	acpi_handle             subtree_entry = acpi_gbl_root_node;
	u32                     max_depth = ACPI_UINT32_MAX;


	/* No argument given, just start at the root and dump entire namespace */

	if (start_arg) {
		/* Check if numeric argument, must be a Node */

		if ((start_arg[0] >= 0x30) && (start_arg[0] <= 0x39)) {
			subtree_entry = (acpi_handle) STRTOUL (start_arg, NULL, 16);
			if (!acpi_os_readable (subtree_entry, sizeof (acpi_namespace_node))) {
				acpi_os_printf ("Address %p is invalid in this address space\n", subtree_entry);
				return;
			}

			if (!VALID_DESCRIPTOR_TYPE ((subtree_entry), ACPI_DESC_TYPE_NAMED)) {
				acpi_os_printf ("Address %p is not a valid Named object\n", subtree_entry);
				return;
			}
		}

		/* Alpha argument */

		else {
			/* The parameter is a name string that must be resolved to a Named obj*/

			subtree_entry = acpi_db_local_ns_lookup (start_arg);
			if (!subtree_entry) {
				subtree_entry = acpi_gbl_root_node;
			}
		}

		/* Now we can check for the depth argument */

		if (depth_arg) {
			max_depth = STRTOUL (depth_arg, NULL, 0);
		}
	}


	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
	acpi_os_printf ("ACPI Namespace (from %p subtree):\n", subtree_entry);

	/* Display the subtree */

	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
	acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth, ACPI_UINT32_MAX, subtree_entry);
	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
}
Beispiel #4
0
/*
        KBPD keyboard/ PD real I/O driver entry
*/
EXPORT	ER	LowKbPdDrv(INT ac, UB *av[])
{
	char	*arg;
	W	v[L_DEVCONF_VAL];

        /* effective? */
	if (GetDevConf("LowKbPdDrvEnable", v) > 0 && !v[0]) return E_NOSPT;

	if (ac < 0) return E_OK;	/* no special epilog processor event */

        /* obtain start parameter */
	TaskPri = DEF_PRIORITY;
	if (ac > 1 && (arg = av[1]) != NULL) {
		switch (*arg++) {
		case '!':	/* priority */
			TaskPri = STRTOUL(arg, &arg, 0);
			break;
		default:
			return E_PAR;
		}
	}

        /* driver initialization */
	return kpStartUp();
}
Beispiel #5
0
void MemChecker_ParseLineCB(void *pUser, const char *pszKey, int nKeyLen, const char *pszValue, int nValueLen)
{
    MemChecker *pMe = (MemChecker *)pUser;
    char *pszValueCopy = NULL;

    pszValueCopy = MALLOC(nValueLen + 1);
    if (NULL == pszValueCopy) {
        return;
    }
    MEMCPY(pszValueCopy, pszValue, nValueLen);

    if (0 == STRNCMP("ClassID", pszKey, nKeyLen))
    {
        if (STRBEGINS("0x", pszValueCopy)) {
            pMe->m_clsCheckedApp = STRTOUL(pszValueCopy, NULL, 16);
        } else {
            pMe->m_clsCheckedApp = ATOI(pszValueCopy);
        }
    }
    else if (0 == STRNCMP("OutputTo", pszKey, nKeyLen))
    {
        pMe->m_eOutputMode = ATOI(pszValueCopy);
    }

    FREEIF(pszValueCopy);
}
Beispiel #6
0
static ACPI_STATUS
AcpiDbExecuteMethod (
    DB_METHOD_INFO          *Info,
    ACPI_BUFFER             *ReturnObj)
{
    ACPI_STATUS             Status;
    ACPI_OBJECT_LIST        ParamObjects;
    ACPI_OBJECT             Params[MTH_NUM_ARGS];
    UINT32                  i;


    if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel)
    {
        AcpiOsPrintf ("Warning: debug output is not enabled!\n");
    }

    /* Are there arguments to the method? */

    if (Info->Args && Info->Args[0])
    {
        for (i = 0; Info->Args[i] && i < MTH_NUM_ARGS; i++)
        {
            Params[i].Type              = ACPI_TYPE_INTEGER;
            Params[i].Integer.Value     = STRTOUL (Info->Args[i], NULL, 16);
        }

        ParamObjects.Pointer        = Params;
        ParamObjects.Count          = i;
    }

    else
    {
        /* Setup default parameters */

        Params[0].Type              = ACPI_TYPE_INTEGER;
        Params[0].Integer.Value     = 0x01020304;

        Params[1].Type              = ACPI_TYPE_STRING;
        Params[1].String.Length     = 12;
        Params[1].String.Pointer    = "AML Debugger";

        ParamObjects.Pointer        = Params;
        ParamObjects.Count          = 2;
    }

    /* Prepare for a return object of arbitrary size */

    ReturnObj->Pointer           = AcpiGbl_DbBuffer;
    ReturnObj->Length            = ACPI_DEBUG_BUFFER_SIZE;


    /* Do the actual method execution */

    Status = AcpiEvaluateObject (NULL, Info->Pathname, &ParamObjects, ReturnObj);

    AcpiGbl_CmSingleStep = FALSE;
    AcpiGbl_MethodExecuting = FALSE;

    return (Status);
}
void
acpi_db_set_method_breakpoint (
	NATIVE_CHAR             *location,
	acpi_walk_state         *walk_state,
	acpi_parse_object       *op)
{
	u32                     address;


	if (!op) {
		acpi_os_printf ("There is no method currently executing\n");
		return;
	}

	/* Get and verify the breakpoint address */

	address = STRTOUL (location, NULL, 16);
	if (address <= op->aml_offset) {
		acpi_os_printf ("Breakpoint %X is beyond current address %X\n", address, op->aml_offset);
	}

	/* Save breakpoint in current walk */

	walk_state->method_breakpoint = address;
	acpi_os_printf ("Breakpoint set at AML offset %X\n", address);
}
// ================================================================================
// FUNCTION		: SetContactFromXml
// DESCRIPTION	: Set contact from a xml.
// ================================================================================
bool CContactInfo::SetContactFromXml(char *pszXml, char *pszType)
{
	DBGPRINTF(pszXml);

	ReleaseMem();

	char *pszFound=NULL;

	//set type of contact
	if ( 0==STRCMP("add", pszType))
		m_nState = SM_RECORD_ADD;
	else if ( 0==STRCMP("update", pszType))
		m_nState = SM_RECORD_UPDATE;
	else if ( 0==STRCMP("delete", pszType))
		m_nState = SM_RECORD_DELETE;
	else
		return false;

	int nLen=0;
	char *pszEndTag=NULL;
	char *pszNumber=NULL;
	
	//set contact id
	if ( !SetValue(&pszNumber, pszXml, "id")) return false;
	if ( NULL!=pszNumber ) m_nContactId = (uint16)STRTOUL(pszNumber, NULL, 10);
	DBGPRINTF("Contact id= %d", m_nContactId);
	FREEIF(pszNumber);

	//set global id
	if ( !SetValue(&m_psGlobalId, pszXml, "gcid")) return false;
	
	//set first name
	if ( !SetValue(&m_psFName, pszXml, "fn")) return false;
    if (NULL!=m_psFName) DBGPRINTF("%S", m_psFName);  
	if ( !SetValue(&m_psLName, pszXml, "ln")) return false;  
	if (NULL!=m_psLName) DBGPRINTF("%S", m_psLName);
	if ( !SetValue(&m_psCompany, pszXml, "cn")) return false;
	if (NULL!=m_psCompany) DBGPRINTF("%S", m_psCompany);
	if ( !SetMultiValue(&m_psJTitle, pszXml, "ttls", "ttl")) return false;
	if (NULL!=m_psJTitle) DBGPRINTF("%S", m_psJTitle);
	if ( !SetMultiValue(&m_psFaxH, pszXml, "fxsh", "fxh")) return false;
	if (NULL!=m_psFaxH) DBGPRINTF("%S", m_psFaxH);
	if ( !SetMultiValue(&m_psFaxW, pszXml, "fxsw", "fxw")) return false;
	if (NULL!=m_psFaxW) DBGPRINTF("%S", m_psFaxW);
	if ( !SetMultiValue(&m_psFax, pszXml, "fxs", "fx")) return false;
	if ( !SetMultiValue(&m_psMobileH, pszXml, "mblsh", "mblh")) return false;	         
	if ( !SetMultiValue(&m_psMobileW, pszXml, "mblsb", "mblb")) return false;
	if ( !SetMultiValue(&m_psMobile, pszXml, "mbls", "mbl")) return false;
	if ( !SetMultiValue(&m_psTelephoneH, pszXml, "telsh", "telh")) return false;
	if ( !SetMultiValue(&m_psTelephoneW, pszXml, "telsb", "telb")) return false;
	if ( !SetMultiValue(&m_psTelephone, pszXml, "tels", "tel")) return false;
	if ( !SetMultiValue(&m_psEmailW, pszXml, "emlsb", "emlb")) return false;
	if ( !SetMultiValue(&m_psEmailH, pszXml, "emlsh", "emlh")) return false;
	if ( !SetMultiValue(&m_psEmail, pszXml, "emls", "eml")) return false;
	if (NULL!=m_psEmail) DBGPRINTF("%S", m_psEmail);

	return true;
}
Beispiel #9
0
acpi_status
acpi_db_execute_method (
	db_method_info          *info,
	acpi_buffer             *return_obj)
{
	acpi_status             status;
	acpi_object_list        param_objects;
	acpi_object             params[MTH_NUM_ARGS];
	u32                     i;


	if (acpi_gbl_db_output_to_file && !acpi_dbg_level) {
		acpi_os_printf ("Warning: debug output is not enabled!\n");
	}

	/* Are there arguments to the method? */

	if (info->args && info->args[0]) {
		for (i = 0; info->args[i] && i < MTH_NUM_ARGS; i++) {
			params[i].type              = ACPI_TYPE_INTEGER;
			params[i].integer.value     = STRTOUL (info->args[i], NULL, 16);
		}

		param_objects.pointer       = params;
		param_objects.count         = i;
	}

	else {
		/* Setup default parameters */

		params[0].type              = ACPI_TYPE_INTEGER;
		params[0].integer.value     = 0x01020304;

		params[1].type              = ACPI_TYPE_STRING;
		params[1].string.length     = 12;
		params[1].string.pointer    = "AML Debugger";

		param_objects.pointer       = params;
		param_objects.count         = 2;
	}

	/* Prepare for a return object of arbitrary size */

	return_obj->pointer          = acpi_gbl_db_buffer;
	return_obj->length           = ACPI_DEBUG_BUFFER_SIZE;


	/* Do the actual method execution */

	status = acpi_evaluate_object (NULL, info->pathname, &param_objects, return_obj);

	acpi_gbl_cm_single_step = FALSE;
	acpi_gbl_method_executing = FALSE;

	return (status);
}
Beispiel #10
0
 static void
siglisten(void)
{
	static HANDLE Sig[2];
	HANDLE h;
	char *s;

#ifdef LONG_LONG_POINTERS
#define STRTOUL strtoull
#else
#define STRTOUL strtoul
#endif
	if (s = getenv("SW_sigpipe")) {
		if (!(Sig[0] = (HANDLE)STRTOUL(s,&s,10))
		 || *s != ','
		 || !(Sig[1] = (HANDLE)STRTOUL(s+1,&s,10)))
			return;
		if (*s == ',')
			isatty_ASL = (int)strtoul(s+1,&s,10);
		h = (HANDLE)_beginthread(siglistener, 0, Sig);
		SetThreadPriority(h, THREAD_PRIORITY_HIGHEST);
		}
	}
Beispiel #11
0
static void vram_scan(int c, wgChar **v, const struct reader_driver *r)
{
	const struct reader_handle *h;
	struct textcontrol log;
	if(c == 3){
		PUTS(wgT("anago F [address] [data]..."));
		return;
	}
	log_set(&log);
	h = r->control.open(except, &log);
	
	if(c == 2){
		PRINTF(wgT("%02x\n"), r->control.vram_connection(h));
	}else{
		const long address = STRTOUL(v[2], NULL, 0x10);
		int i;
		for(i = 3; i < c; i++){
			const uint8_t d = STRTOUL(v[i], NULL, 0x10);
			r->cpu.memory_write(h, address, 1, &d);
			PRINTF(wgT("$%04x = 0x%02x->0x%02x\n"), (int) address, (int) d, r->control.vram_connection(h));
		}
	}
	r->control.close(h);
}
Beispiel #12
0
uint4 trans_numeric(mstr *log, boolean_t *is_defined,  boolean_t ignore_errors)
{
	/* return
	 * - 0 on error if ignore_errors is set (otherwise error is raised and no return is made) or
	 *   if logical/envvar is undefined.
	 * - an unsigned int containing the numeric value (or as much as could be determined) from
	 *   the logical/envvar string value (up to the first non-numeric digit. Characters accepted
	 *   are those read by the strtoul() function.
	 */
	int4		status;
	uint4		value;
	mstr		tn;
	char		buf[MAX_TRANS_NAME_LEN], *endptr;

	error_def(ERR_LOGTOOLONG);
	error_def(ERR_TRNLOGFAIL);

	*is_defined = FALSE;
	if (SS_NORMAL == (status = TRANS_LOG_NAME(log, &tn, buf, SIZEOF(buf),
							ignore_errors ? do_sendmsg_on_log2long : dont_sendmsg_on_log2long)))
	{	/* Translation was successful */
		*is_defined = TRUE;
		assert(tn.len < SIZEOF(buf));
		endptr = tn.addr + tn.len;
		*endptr = '\0';
		value = (uint4)STRTOUL(buf, &endptr, 0);	/* Base 0 allows base 10, 0x or octal input */
		/* At this point, if '\0' == *endptr, the entire string was successfully consumed as
		   a numeric string. If not, endptr has been updated to point to the errant chars. We
		   currently have no clients who care about this so there is no expansion on this but
		   this could be added at this point. For now we just return whatever numeric value
		   (if any) was gleened..
		*/
		return value;

	} else if (SS_NOLOGNAM == status)	/* Not defined */
		return 0;

	if (!ignore_errors)
	{	/* Only give errors if we can handle them */
#		ifdef UNIX
		if (SS_LOG2LONG == status)
			rts_error(VARLSTCNT(5) ERR_LOGTOOLONG, 3, log->len, log->addr, SIZEOF(buf) - 1);
		else
#		endif
			rts_error(VARLSTCNT(5) ERR_TRNLOGFAIL, 2, log->len, log->addr, status);
	}
	return 0;
}
Beispiel #13
0
static void crc32_dump(const wgChar *name, const wgChar *str, struct memory *m)
{
	long banksize = STRTOUL(str, NULL, 0x10);
	if(banksize < 0x400 || (banksize & 0xff) != 0){
		PUTS(wgT("banksize requires over 0x400"));
		return;
	}
	if(banksize > m->size){
		banksize = m->size;
	}
	int i, j;
	PRINTF(wgT("%s 0x%x byte\n"), name, m->size);
	for(i = 0, j = 0; i < m->size; i += banksize, j++){
		PRINTF(wgT("%02x:%08x\n"), j, crc32_get(m->data + i, banksize));
	}
}
void
acpi_db_find_references (
	NATIVE_CHAR             *object_arg)
{
	acpi_operand_object     *obj_desc;


	/* Convert string to object pointer */

	obj_desc = (acpi_operand_object *) STRTOUL (object_arg, NULL, 16);

	/* Search all nodes in namespace */

	acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
			  acpi_db_walk_for_references, (void *) obj_desc, NULL);
}
Beispiel #15
0
static int32_t
parse_breakpoint_no(char* args)
{
  char* ps = args;
  uint32_t l;

  if((*ps == '0')||(strlen(ps) >= BPNO_LETTER_NUM)) {
    return 0;
  }

  while( !(ISBLANK(*ps)||ISCNTRL(*ps)) ) {
    if(!ISDIGIT(*ps)) {
      return 0;
    }
    ps++;
  }

  STRTOUL(l, args);
  return l;
}
void
acpi_db_disassemble_aml (
	NATIVE_CHAR             *statements,
	acpi_parse_object       *op)
{
	u32                     num_statements = 8;


	if (!op) {
		acpi_os_printf ("There is no method currently executing\n");
		return;
	}

	if (statements) {
		num_statements = STRTOUL (statements, NULL, 0);
	}


	acpi_db_display_op (NULL, op, num_statements);
}
Beispiel #17
0
/*
 * --------------------------------------------------
 * Convert string to hex.
 *
 * Return:
 *	TRUE	- OK
 *	FALSE	- Could not convert to hex
 * --------------------------------------------------
 */
boolean_t cli_str_to_hex(char *str, uint4 *dst)
{
	unsigned long	result;
	int	save_errno;

	save_errno = errno;
	errno = 0;
        result = STRTOUL(str, NULL, 16);
	if (
#if INT_MAX < LONG_MAX
		(UINT_MAX < result) ||	/* outside UINT range */
#endif
	    (ERANGE == errno && ULONG_MAX == result) || (0 == result && 0 != errno))
	{	/* out of range or other error */
		*dst = 0;
		errno = save_errno;
		return FALSE;
	} else
	{
		*dst = (uint4)result;
		errno = save_errno;
		return TRUE;
	}
}
Beispiel #18
0
int cli_parse_two_numbers(char *qual_name, const char delimiter, uint4 *first_num, uint4 *second_num)
{ /* Parse two unsigned base 10 numbers separated by the given delimiter. Eg. -LOG_INTERVAL=10,20 (on VMS, -LOG_INTERVAL="10,20").
   * Both Unix and VMS accept the qualifier as a string. NOTE: On VMS, such qualifiers are quoted strings.
   * Both numbers are optional (eg. -LOG_INTERVAL=10, or -LOG_INTERVAL=",20", or -LOG_INTERVAL=,).
   * Return values:
   * 		     CLI_2NUM_FIRST_SPECIFIED  (binary 10), first number specified, second not
   * 		     CLI_2NUM_SECOND_SPECIFIED (binary 01), first number not specified, second is
   * 		     CLI_2NUM_BOTH_SPECIFIED   (binary 11) (CLI_2NUM_FIRST_SPECIFIED | CLI_2NUM_SECOND_SPECIFIED), both specified
   * 		     0 (binary 00), error in parsing either number
   */
	char		*first_num_str, *second_num_str, *two_num_str_top, *num_endptr;
	char		two_num_qual_str[128];
	unsigned short	two_num_qual_len;
	uint4		num;
	int		retval = 0;

	two_num_qual_len = sizeof(two_num_qual_str);
	if (!cli_get_str(qual_name, two_num_qual_str, &two_num_qual_len))
	{
		util_out_print("Error parsing !AZ qualifier", TRUE, qual_name);
		return 0;
	}
#ifdef VMS
	/* DCL does not strip quotes included in the command line. However, the DEFAULT value (see mupip_cmd.cld) is stripped
	 * of quotes. */
	if ('"' == two_num_qual_str[0])
	{
		assert('"' == two_num_qual_str[two_num_qual_len - 1]); /* end quote should exist */
		first_num_str = &two_num_qual_str[1]; /* Skip begin quote */
		two_num_qual_str[two_num_qual_len - 1] = '\0'; /* Zap end quote */
		two_num_qual_len -= 2; /* Quotes gone */
	} else
#endif
		first_num_str = two_num_qual_str;
	for (second_num_str = first_num_str, two_num_str_top = first_num_str + two_num_qual_len;
		second_num_str < two_num_str_top && delimiter != *second_num_str;
		second_num_str++)
		;
	if (delimiter == *second_num_str)
		*second_num_str++ = '\0';
	if (*first_num_str != '\0') /* VMS issues EINVAL if strtoul is passed null string */
	{
		errno = 0;
		num = (uint4)STRTOUL(first_num_str, &num_endptr, 10);
		if ((0 == num && (0 != errno || (num_endptr == first_num_str && *first_num_str != '\0'))) ||
		    (0 != errno && GTM64_ONLY(UINT_MAX == num) NON_GTM64_ONLY(ULONG_MAX == num)))
		{
			util_out_print("Error parsing or invalid parameter for !AZ", TRUE, qual_name);
			return 0;
		}
		*first_num = num;
		retval |= CLI_2NUM_FIRST_SPECIFIED;
	} /* else, first number not specified */
	if (second_num_str < two_num_str_top && *second_num_str != '\0')
	{
		errno = 0;
		num = (uint4)STRTOUL(second_num_str, &num_endptr, 10);
		if ((0 == num && (0 != errno || (num_endptr == second_num_str && *second_num_str != '\0'))) ||
		    (0 != errno && GTM64_ONLY(UINT_MAX == num) NON_GTM64_ONLY(ULONG_MAX == num)))
		{
			util_out_print("Error parsing or invalid parameter for LOG_INTERVAL", TRUE);
			return 0;
		}
		*second_num = num;
		retval |= CLI_2NUM_SECOND_SPECIFIED;
	} /* else, second number not specified */
	return retval;
}
Beispiel #19
0
mrb_debug_bptype
parse_breakcommand(mrdb_state *mrdb, const char **file, uint32_t *line, char **cname, char **method)
{
  mrb_debug_context *dbg = mrdb->dbg;
  char *args;
  char *body;
  mrb_debug_bptype type;
  uint32_t l;

  if(mrdb->wcnt <= 1) {
    puts(BREAK_ERR_MSG_BLANK);
    return MRB_DEBUG_BPTYPE_NONE;
  }

  args = mrdb->words[1];
  if((body = strrchr(args, ':')) == NULL) {
    body = args;
    type = check_bptype(body);
  } else {
    if(body == args) {
      printf(BREAK_ERR_MSG_INVALIDSTR, args);
      return MRB_DEBUG_BPTYPE_NONE;
    }
    *body = '\0';
    type = check_bptype(++body);
  }

  switch(type) {
    case MRB_DEBUG_BPTYPE_LINE:
      STRTOUL(l, body);
      if( l <= 65535 ) {
        *line = l;
        *file = (body == args)? mrb_debug_get_filename(dbg->irep, (uint32_t)(dbg->pc - dbg->irep->iseq)): args;
      } else {
        puts(BREAK_ERR_MSG_RANGEOVER);
        type = MRB_DEBUG_BPTYPE_NONE;
      }
      break;
    case MRB_DEBUG_BPTYPE_METHOD:
      if(body == args) {
        /* method only */
        if( ISUPPER(*body)||ISLOWER(*body)||(*body == '_') ) {
          *method = body;
          *cname = NULL;
        } else {
          printf(BREAK_ERR_MSG_INVALIDMETHOD, args);
          type = MRB_DEBUG_BPTYPE_NONE;
        }
      } else {
        if( ISUPPER(*args) ) {
          switch(*body) {
            case '@': case '$': case '?': case '.': case ',': case ':':
            case ';': case '#': case '\\': case '\'': case '\"':
            printf(BREAK_ERR_MSG_INVALIDMETHOD, body);
            type = MRB_DEBUG_BPTYPE_NONE;
            break;
          default:
            *method = body;
            *cname = args;
            break;
          }
        } else {
          printf(BREAK_ERR_MSG_INVALIDCLASS, args);
          type = MRB_DEBUG_BPTYPE_NONE;
        }
      }
      break;
    case MRB_DEBUG_BPTYPE_NONE:
    default:
      break;
  }

  return type;
}
Beispiel #20
0
/* given the bounds of a particular subscript (assumed correct), we convert the subscript into
 * a form that mimics the GDS representation of that subscript
 */
boolean_t convert_key_to_db(mval *gvn, int start, int stop, gv_key *gvkey, unsigned char **key)
{
	mval 		tmpval, *mvptr, dollarcharmval;
	int 		isrc;
	char		strbuff[MAX_KEY_SZ + 1], *str, *str_top;
	char 		fnname[MAX_LEN_FOR_CHAR_FUNC], *c;
	boolean_t	is_zchar;
	int4		num;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	if (ISDIGIT_ASCII(gvn->str.addr[start]) ||
		'-' == gvn->str.addr[start] || '+' == gvn->str.addr[start] || '.' == gvn->str.addr[start])
	{	/* convert a number */
		tmpval.str.addr = &gvn->str.addr[start];
		tmpval.str.len 	= stop - start;
		tmpval.mvtype = MV_STR;
		mvptr = &tmpval;
		MV_FORCE_NUM(mvptr);
		if (MVTYPE_IS_NUM_APPROX(tmpval.mvtype))
			return FALSE;
		mval2subsc(&tmpval, gvkey, gv_cur_region->std_null_coll);
	} else
	{	/* It's a string. We need to accept strings, $CHAR args, and $ZCHAR args. */
		str = &strbuff[0];
		str_top = &strbuff[0] + MAX_KEY_SZ + 1;
		/* MV_NUM_APPROX needed by mval2subsc to skip val_iscan call */
		tmpval.mvtype = (MV_STR | MV_NUM_APPROX);
		for (isrc = start; isrc < stop; )
		{
			if ('_' == gvn->str.addr[isrc])
			{	/* We can skip this case, since we're already "appending"
				 * the strings on the lhs to the string on the rhs. */
				isrc++;
			} else if ('$' == gvn->str.addr[isrc])
			{	/* We determine if what comes after is a Char or a ZCHar,
				 * and copy over accordingly */
				c = &fnname[0];
				isrc++; /* skip the '$' */
				while ('(' != gvn->str.addr[isrc])
					*c++ = TOUPPER(gvn->str.addr[isrc++]);
				*c = '\0';
				assert(strlen(c) <= MAX_LEN_FOR_CHAR_FUNC - 1);
				if (!MEMCMP_LIT(fnname, "ZCHAR") || !MEMCMP_LIT(fnname, "ZCH"))
					is_zchar = TRUE;
				else if (!MEMCMP_LIT(fnname, "CHAR") || !MEMCMP_LIT(fnname, "C"))
					is_zchar = FALSE;
				else
					assert(FALSE);
				/* Parse the arguments */
				isrc++; /* skip the '(' */
				while (TRUE)
				{	/* Inside the argument list for $[Z]CHAR */
					/* STRTOUL will stop at the ',' or ')' */
					num = (int4)STRTOUL(&gvn->str.addr[isrc], NULL, 10);
#					ifdef UNICODE_SUPPORTED
					if (!is_zchar && is_gtm_chset_utf8)
						op_fnchar(2, &dollarcharmval, num);
					else
#					endif
						op_fnzchar(2, &dollarcharmval, num);
					assert(MV_IS_STRING(&dollarcharmval));
					if (dollarcharmval.str.len)
					{
						if (str + dollarcharmval.str.len > str_top)
							/* String overflows capacity. */
							return FALSE;
						memcpy(str, dollarcharmval.str.addr, dollarcharmval.str.len);
						str += dollarcharmval.str.len;
					}
					/* move on to the next argument */
					while (',' != gvn->str.addr[isrc] && ')' != gvn->str.addr[isrc])
						isrc++;
					if (',' == gvn->str.addr[isrc])
						isrc++;
					else
					{
						assert(')' == gvn->str.addr[isrc]);
						isrc++; /* skip ')' */
						break;
					}
				}
			} else if ('"' == gvn->str.addr[isrc])
			{	/* Assume valid string. */
				isrc++;
				while (isrc < stop && !('"' == gvn->str.addr[isrc] && '"' != gvn->str.addr[isrc+1]))
				{
					if (str == str_top)
						/* String overflows capacity. */
						return FALSE;
					if ('"' == gvn->str.addr[isrc] && '"' == gvn->str.addr[isrc+1])
					{
						*str++ = '"';
						isrc += 2;
					} else
						*str++ = gvn->str.addr[isrc++];
				}
				isrc++; /* skip over '"' */
			} else
				assert(FALSE);
		}
		tmpval.str.addr = strbuff;
		tmpval.str.len 	= str - strbuff;
		DEBUG_ONLY(TREF(skip_mv_num_approx_assert) = TRUE;)
		mval2subsc(&tmpval, gvkey, gv_cur_region->std_null_coll);
		DEBUG_ONLY(TREF(skip_mv_num_approx_assert) = FALSE;)
	}
void
acpi_db_display_resources (
	NATIVE_CHAR             *object_arg)
{
#ifndef _IA16
	acpi_operand_object     *obj_desc;
	acpi_status             status;
	acpi_buffer             return_obj;


	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);

	/* Convert string to object pointer */

	obj_desc = (acpi_operand_object *) STRTOUL (object_arg, NULL, 16);

	/* Prepare for a return object of arbitrary size */

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;


	/* _PRT */

	acpi_os_printf ("Evaluating _PRT\n");

	status = acpi_evaluate_object (obj_desc, "_PRT", NULL, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Could not obtain _PRT: %s\n", acpi_format_exception (status));
		goto get_crs;
	}

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_get_irq_routing_table (obj_desc, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Get_irq_routing_table failed: %s\n", acpi_format_exception (status));
	}

	else {
		acpi_rs_dump_irq_list ((u8 *) acpi_gbl_db_buffer);
	}


	/* _CRS */

get_crs:
	acpi_os_printf ("Evaluating _CRS\n");

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_evaluate_object (obj_desc, "_CRS", NULL, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Could not obtain _CRS: %s\n", acpi_format_exception (status));
		goto get_prs;
	}

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_get_current_resources (obj_desc, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Acpi_get_current_resources failed: %s\n", acpi_format_exception (status));
	}

	else {
		acpi_rs_dump_resource_list ((acpi_resource *) acpi_gbl_db_buffer);
	}


	/* _PRS */

get_prs:
	acpi_os_printf ("Evaluating _PRS\n");

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_evaluate_object (obj_desc, "_PRS", NULL, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Could not obtain _PRS: %s\n", acpi_format_exception (status));
		goto cleanup;
	}

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_get_possible_resources (obj_desc, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Acpi_get_possible_resources failed: %s\n", acpi_format_exception (status));
	}

	else {
		acpi_rs_dump_resource_list ((acpi_resource *) acpi_gbl_db_buffer);
	}


cleanup:

	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
	return;
#endif

}
Beispiel #22
0
void bin_load(uint4 begin, uint4 end)
{
	unsigned char	*ptr, *cp1, *cp2, *btop, *gvkey_char_ptr, *tmp_ptr, *tmp_key_ptr, *c, *ctop, *ptr_base;
	unsigned char	hdr_lvl, src_buff[MAX_KEY_SZ + 1], dest_buff[MAX_ZWR_KEY_SZ],
			cmpc_str[MAX_KEY_SZ + 1], dup_key_str[MAX_KEY_SZ + 1], sn_key_str[MAX_KEY_SZ + 1], *sn_key_str_end;
	unsigned char	*end_buff;
	unsigned short	rec_len, next_cmpc, numsubs;
	int		len;
	int		current, last, length, max_blk_siz, max_key, status;
	int		tmp_cmpc, sn_chunk_number, expected_sn_chunk_number = 0, sn_hold_buff_pos, sn_hold_buff_size;
	uint4		iter, max_data_len, max_subsc_len, key_count, gblsize;
	ssize_t		rec_count, global_key_count, subsc_len,extr_std_null_coll, last_sn_error_offset=0,
				file_offset_base=0, file_offset=0;
	boolean_t	need_xlation, new_gvn, utf8_extract;
	boolean_t	is_hidden_subscript, ok_to_put = TRUE, putting_a_sn = FALSE, sn_incmp_gbl_already_killed = FALSE;
	rec_hdr		*rp, *next_rp;
	mval		v, tmp_mval;
	mstr		mstr_src, mstr_dest;
	collseq		*extr_collseq, *db_collseq, *save_gv_target_collseq;
	coll_hdr	extr_collhdr, db_collhdr;
	gv_key 		*tmp_gvkey = NULL;	/* null-initialize at start, will be malloced later */
	gv_key		*sn_gvkey = NULL; /* null-initialize at start, will be malloced later */
	gv_key		*sn_savekey = NULL; /* null-initialize at start, will be malloced later */
	char		std_null_coll[BIN_HEADER_NUMSZ + 1], *sn_hold_buff = NULL, *sn_hold_buff_temp = NULL;
#	ifdef GTM_CRYPT
	gtmcrypt_key_t			*encr_key_handles;
	char				*inbuf;
	int4				index;
	int				req_dec_blk_size, init_status, crypt_status;
	muext_hash_hdr_ptr_t		hash_array = NULL;
#	endif
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	assert(4 == SIZEOF(coll_hdr));
	gvinit();
	v.mvtype = MV_STR;
	len = file_input_bin_get((char **)&ptr, &file_offset_base, (char **)&ptr_base);
	hdr_lvl = EXTR_HEADER_LEVEL(ptr);
	if (!(((('4' == hdr_lvl) || ('5' == hdr_lvl)) && (V5_BIN_HEADER_SZ == len)) ||
			(('6' == hdr_lvl) && (BIN_HEADER_SZ == len)) ||
			(('7' == hdr_lvl) && (BIN_HEADER_SZ == len)) ||
			(('4' > hdr_lvl) && (V3_BIN_HEADER_SZ == len))))
	{
		rts_error(VARLSTCNT(1) ERR_LDBINFMT);
		mupip_exit(ERR_LDBINFMT);
	}
	/* expecting the level in a single character */
	assert(' ' == *(ptr + SIZEOF(BIN_HEADER_LABEL) - 3));
	if (0 != memcmp(ptr, BIN_HEADER_LABEL, SIZEOF(BIN_HEADER_LABEL) - 2) || ('2' > hdr_lvl) ||
			*(BIN_HEADER_VERSION_ENCR) < hdr_lvl)
	{	/* ignore the level check */
		rts_error(VARLSTCNT(1) ERR_LDBINFMT);
		mupip_exit(ERR_LDBINFMT);
	}
	/* check if extract was generated in UTF-8 mode */
	utf8_extract = (0 == MEMCMP_LIT(&ptr[len - BIN_HEADER_LABELSZ], UTF8_NAME)) ? TRUE : FALSE;
	if ((utf8_extract && !gtm_utf8_mode) || (!utf8_extract && gtm_utf8_mode))
	{ /* extract CHSET doesn't match $ZCHSET */
		if (utf8_extract)
			rts_error(VARLSTCNT(4) ERR_LOADINVCHSET, 2, LEN_AND_LIT("UTF-8"));
		else
			rts_error(VARLSTCNT(4) ERR_LOADINVCHSET, 2, LEN_AND_LIT("M"));
		mupip_exit(ERR_LDBINFMT);
	}
	if ('4' >= hdr_lvl)
	{	/* Binary extracts in V50000-to-V52000 (label=4) and pre-V50000 (label=3) could have a '\0' byte (NULL byte)
		 * in the middle of the string. Replace it with ' ' (space) like it would be in V52000 binary extracts and above.
		 */
		for (c = ptr, ctop = c + len; c < ctop; c++)
		{
			if ('\0' == *c)
				*c = ' ';
		}
	}
	util_out_print("Label = !AD\n", TRUE, len, ptr);
	new_gvn = FALSE;
	if (hdr_lvl > '3')
	{
		if (hdr_lvl > '5')
		{
			memcpy(std_null_coll, ptr + BIN_HEADER_NULLCOLLOFFSET, BIN_HEADER_NUMSZ);
			std_null_coll[BIN_HEADER_NUMSZ] = '\0';
		}
		else
		{
			memcpy(std_null_coll, ptr + V5_BIN_HEADER_NULLCOLLOFFSET, V5_BIN_HEADER_NUMSZ);
			std_null_coll[V5_BIN_HEADER_NUMSZ] = '\0';
		}
		extr_std_null_coll = STRTOUL(std_null_coll, NULL, 10);
		if (0 != extr_std_null_coll && 1!= extr_std_null_coll)
		{
			rts_error(VARLSTCNT(5) ERR_TEXT, 2, RTS_ERROR_TEXT("Corrupted null collation field  in header"),
				ERR_LDBINFMT);
			mupip_exit(ERR_LDBINFMT);
		}
	} else
		extr_std_null_coll = 0;
#	ifdef GTM_CRYPT
	if ('7' <= hdr_lvl)
	{
		int	i, num_indexes;
		len = file_input_bin_get((char **)&ptr, &file_offset_base, (char **)&ptr_base);
		hash_array = (muext_hash_hdr *)malloc(len);
		/* store hashes of all the files used during extract into muext_hash_hdr structure */
		memcpy((char *)hash_array, ptr, len);
		num_indexes = len / GTMCRYPT_HASH_LEN;
		encr_key_handles = (gtmcrypt_key_t *)malloc(SIZEOF(gtmcrypt_key_t) * num_indexes);
		INIT_PROC_ENCRYPTION(crypt_status);
		GC_BIN_LOAD_ERR(crypt_status);
		for (index = 0; index < num_indexes; index++)
		{
			if (0 == memcmp(hash_array[index].gtmcrypt_hash, EMPTY_GTMCRYPT_HASH, GTMCRYPT_HASH_LEN))
				continue;
			GTMCRYPT_GETKEY(hash_array[index].gtmcrypt_hash, encr_key_handles[index], crypt_status);
			GC_BIN_LOAD_ERR(crypt_status);
		}
	}
#	endif
	if ('2' < hdr_lvl)
	{
		len = file_input_bin_get((char **)&ptr, &file_offset_base, (char **)&ptr_base);
		if (SIZEOF(coll_hdr) != len)
		{
			rts_error(VARLSTCNT(5) ERR_TEXT, 2, RTS_ERROR_TEXT("Corrupt collation header"), ERR_LDBINFMT);
			mupip_exit(ERR_LDBINFMT);
		}
		extr_collhdr = *((coll_hdr *)(ptr));
		new_gvn = TRUE;
	} else
		gtm_putmsg(VARLSTCNT(3) ERR_OLDBINEXTRACT, 1, hdr_lvl - '0');
	if (begin < 2)
		begin = 2;
	for (iter = 2; iter < begin; iter++)
	{
		if (!(len = file_input_bin_get((char **)&ptr, &file_offset_base, (char **)&ptr_base)))
		{
			gtm_putmsg(VARLSTCNT(3) ERR_LOADEOF, 1, begin);
			util_out_print("Error reading record number: !UL\n", TRUE, iter);
			mupip_error_occurred = TRUE;
			return;
		} else if (len == SIZEOF(coll_hdr))
		{
			extr_collhdr = *((coll_hdr *)(ptr));
			assert(hdr_lvl > '2');
			iter--;
		}
	}
	assert(iter == begin);
	util_out_print("Beginning LOAD at record number: !UL\n", TRUE, begin);
	max_data_len = 0;
	max_subsc_len = 0;
	global_key_count = key_count = 0;
	rec_count = begin - 1;
	extr_collseq = db_collseq = NULL;
	need_xlation = FALSE;
	assert(NULL == tmp_gvkey);	/* GVKEY_INIT macro relies on this */
	GVKEY_INIT(tmp_gvkey, DBKEYSIZE(MAX_KEY_SZ));	/* tmp_gvkey will point to malloced memory after this */
	assert(NULL == sn_gvkey);	/* GVKEY_INIT macro relies on this */
	GVKEY_INIT(sn_gvkey, DBKEYSIZE(MAX_KEY_SZ));	/* sn_gvkey will point to malloced memory after this */
	assert(NULL == sn_savekey);	/* GVKEY_INIT macro relies on this */
	GVKEY_INIT(sn_savekey, DBKEYSIZE(MAX_KEY_SZ));	/* sn_gvkey will point to malloced memory after this */
	for (; !mupip_DB_full ;)
	{
		if (++rec_count > end)
			break;
		next_cmpc = 0;
		mupip_error_occurred = FALSE;
		if (mu_ctrly_occurred)
			break;
		if (mu_ctrlc_occurred)
		{
			util_out_print("!AD:!_  Key cnt: !UL  max subsc len: !UL  max data len: !UL", TRUE,
				LEN_AND_LIT(gt_lit), key_count, max_subsc_len, max_data_len);
			util_out_print("Last LOAD record number: !UL", TRUE, key_count ? (rec_count - 1) : 0);
			mu_gvis();
			util_out_print(0, TRUE);
			mu_ctrlc_occurred = FALSE;
		}
		if (!(len = file_input_bin_get((char **)&ptr, &file_offset_base, (char **)&ptr_base)) || mupip_error_occurred)
			break;
		else if (len == SIZEOF(coll_hdr))
		{
			extr_collhdr = *((coll_hdr *)(ptr));
			assert(hdr_lvl > '2');
			new_gvn = TRUE;			/* next record will contain a new gvn */
			rec_count--;	/* Decrement as this record does not count as a record for loading purposes */
			continue;
		}
		rp = (rec_hdr*)(ptr);
#		ifdef GTM_CRYPT
		if ('7' <= hdr_lvl)
		{	/* Getting index value from the extracted file. It indicates which database file this record belongs to */
			GET_LONG(index, ptr);
			if (-1 != index) /* Indicates that the record is encrypted. */
			{
				req_dec_blk_size = len - SIZEOF(int4);
				inbuf = (char *)(ptr + SIZEOF(int4));
				GTMCRYPT_DECODE_FAST(encr_key_handles[index], inbuf, req_dec_blk_size, NULL, crypt_status);
				GC_BIN_LOAD_ERR(crypt_status);
			}
			rp = (rec_hdr*)(ptr + SIZEOF(int4));
		}
#		endif
		btop = ptr + len;
		cp1 = (unsigned char*)(rp + 1);
		v.str.addr = (char*)cp1;
		while (*cp1++)
			;
		v.str.len =INTCAST((char*)cp1 - v.str.addr - 1);
		if (('2' >= hdr_lvl) || new_gvn)
		{
			if ((HASHT_GBLNAME_LEN == v.str.len) &&	(0 == memcmp(v.str.addr, HASHT_GBLNAME, HASHT_GBLNAME_LEN)))
				continue;
			bin_call_db(BIN_BIND, (INTPTR_T)gd_header, (INTPTR_T)&v.str);
			max_key = gv_cur_region->max_key_size;
			db_collhdr.act = gv_target->act;
			db_collhdr.ver = gv_target->ver;
			db_collhdr.nct = gv_target->nct;
		}
		GET_USHORT(rec_len, &rp->rsiz);
		if (EVAL_CMPC(rp) != 0 || v.str.len > rec_len || mupip_error_occurred)
		{
			bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
			mu_gvis();
			DISPLAY_FILE_OFFSET_OF_RECORD_AND_REST_OF_BLOCK;
			continue;
		}
		if (new_gvn)
		{
			global_key_count = 1;
			if ((db_collhdr.act != extr_collhdr.act || db_collhdr.ver != extr_collhdr.ver
				|| db_collhdr.nct != extr_collhdr.nct
				|| gv_cur_region->std_null_coll != extr_std_null_coll))
			{
				if (extr_collhdr.act)
				{
					if (extr_collseq = ready_collseq((int)extr_collhdr.act))
					{
						if (!do_verify(extr_collseq, extr_collhdr.act, extr_collhdr.ver))
						{
							gtm_putmsg(VARLSTCNT(8) ERR_COLLTYPVERSION, 2, extr_collhdr.act,
								extr_collhdr.ver, ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
							mupip_exit(ERR_COLLTYPVERSION);
						}
					} else
					{
						gtm_putmsg(VARLSTCNT(7) ERR_COLLATIONUNDEF, 1, extr_collhdr.act,
							ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
						mupip_exit(ERR_COLLATIONUNDEF);
					}
				}
				if (db_collhdr.act)
				{
					if (db_collseq = ready_collseq((int)db_collhdr.act))
					{
						if (!do_verify(db_collseq, db_collhdr.act, db_collhdr.ver))
						{
							gtm_putmsg(VARLSTCNT(8) ERR_COLLTYPVERSION, 2, db_collhdr.act,
								db_collhdr.ver, ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
							mupip_exit(ERR_COLLTYPVERSION);
						}
					} else
					{
						gtm_putmsg(VARLSTCNT(7) ERR_COLLATIONUNDEF, 1, db_collhdr.act,
							ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
						mupip_exit(ERR_COLLATIONUNDEF);
					}
				}
				need_xlation = TRUE;
			} else
				need_xlation = FALSE;
		}
		new_gvn = FALSE;
		for (; rp < (rec_hdr*)btop; rp = (rec_hdr*)((unsigned char *)rp + rec_len))
		{
			GET_USHORT(rec_len, &rp->rsiz);
			if (rec_len + (unsigned char *)rp > btop)
			{
				bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
				mu_gvis();
				DISPLAY_FILE_OFFSET_OF_RECORD_AND_REST_OF_BLOCK;
				break;
			}
			cp1 =  (unsigned char*)(rp + 1);
			cp2 = gv_currkey->base + EVAL_CMPC(rp);
			current = 1;
			for (;;)
			{
				last = current;
				current = *cp2++ = *cp1++;
				if (0 == last && 0 == current)
					break;
				if (cp1 > (unsigned char *)rp + rec_len ||
				    cp2 > (unsigned char *)gv_currkey + gv_currkey->top)
				{
					gv_currkey->end = cp2 - gv_currkey->base - 1;
					gv_currkey->base[gv_currkey->end] = 0;
					gv_currkey->base[gv_currkey->end - 1] = 0;
					bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
					mu_gvis();
					DISPLAY_FILE_OFFSET_OF_RECORD_AND_REST_OF_BLOCK;
					break;
				}
			}
			if (mupip_error_occurred)
				break;
			gv_currkey->end = cp2 - gv_currkey->base - 1;
			if (need_xlation)
			{
				assert(hdr_lvl >= '3');
				assert(extr_collhdr.act || db_collhdr.act || extr_collhdr.nct || db_collhdr.nct ||
				 	extr_std_null_coll != gv_cur_region->std_null_coll);
							/* gv_currkey would have been modified/translated in the earlier put */
				memcpy(gv_currkey->base, cmpc_str, next_cmpc);
				next_rp = (rec_hdr *)((unsigned char*)rp + rec_len);
				if ((unsigned char*)next_rp < btop)
				{
					next_cmpc = EVAL_CMPC(next_rp);
					assert(next_cmpc <= gv_currkey->end);
					memcpy(cmpc_str, gv_currkey->base, next_cmpc);
				} else
					next_cmpc = 0;
							/* length of the key might change (due to nct variation),
							 * so get a copy of the original key from the extract */
				memcpy(dup_key_str, gv_currkey->base, gv_currkey->end + 1);
				gvkey_char_ptr = dup_key_str;
				while (*gvkey_char_ptr++)
					;
				gv_currkey->prev = 0;
				gv_currkey->end = gvkey_char_ptr - dup_key_str;
				assert(gv_keysize <= tmp_gvkey->top);
				while (*gvkey_char_ptr)
				{
						/* get next subscript (in GT.M internal subsc format) */
					subsc_len = 0;
					tmp_ptr = src_buff;
					while (*gvkey_char_ptr)
						*tmp_ptr++ = *gvkey_char_ptr++;
					subsc_len = tmp_ptr - src_buff;
					src_buff[subsc_len] = '\0';
					if (extr_collseq)
					{
						/* undo the extract time collation */
						TREF(transform) = TRUE;
						save_gv_target_collseq = gv_target->collseq;
						gv_target->collseq = extr_collseq;
					} else
						TREF(transform) = FALSE;
						/* convert the subscript to string format */
					end_buff = gvsub2str(src_buff, dest_buff, FALSE);
						/* transform the string to the current subsc format */
					TREF(transform) = TRUE;
					tmp_mval.mvtype = MV_STR;
                                	tmp_mval.str.addr = (char *)dest_buff;
                                	tmp_mval.str.len = INTCAST(end_buff - dest_buff);
					tmp_gvkey->prev = 0;
					tmp_gvkey->end = 0;
					if (extr_collseq)
						gv_target->collseq = save_gv_target_collseq;
					mval2subsc(&tmp_mval, tmp_gvkey);
						/* we now have the correctly transformed subscript */
					tmp_key_ptr = gv_currkey->base + gv_currkey->end;
					memcpy(tmp_key_ptr, tmp_gvkey->base, tmp_gvkey->end + 1);
					gv_currkey->prev = gv_currkey->end;
					gv_currkey->end += tmp_gvkey->end;
					gvkey_char_ptr++;
				}
				if ( gv_cur_region->std_null_coll != extr_std_null_coll && gv_currkey->prev)
				{
					if (extr_std_null_coll == 0)
					{
						GTM2STDNULLCOLL(gv_currkey->base, gv_currkey->end);
					} else
					{
						STD2GTMNULLCOLL(gv_currkey->base, gv_currkey->end);
					}
				}
			}
			if (gv_currkey->end >= max_key)
			{
				bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
				mu_gvis();
				DISPLAY_FILE_OFFSET_OF_RECORD_AND_REST_OF_BLOCK;
				continue;
			}
			/*
			 * Spanning node-related variables and their usage:
			 *
			 * expected_sn_chunk_number: 	0  - looking for spanning nodes (regular nodes are OK, too)
			 *				!0 - number of the next chunk needed (implies we are building
			 *					a spanning node's value)
			 *
			 * While building a spanning node's value:
			 * numsubs: the number of chunks needed to build the spanning node's value
			 * gblsize: the expected size of the completed value
			 * sn_chunk_number: The chunk number of the chunk from the current record from the extract
			 *
			 * Managing the value
			 * sn_hold_buff: buffer used to accumulate the spanning node's value
			 * sn_hold_buff_size: Allocated size of buffer
			 * sn_hold_buff_pos: amount of the buffer used; where to place the next chunk
			 * sn_hold_buff_temp: used when we have to increase the size of the buffer
			 *
			 * Controlling the placing of the key,value in the database:
			 * ok_to_put: means we are ready to place the key,value in the database, i.e., we have the full value
			 * 		(either of the spanning node or a regular node).
			 * putting_a_sn: we are placing a spanning node in the database, i.e, use the key from sn_gvkey and
			 * 		the value from sn_hold_buff.
			 */
			CHECK_HIDDEN_SUBSCRIPT(gv_currkey,is_hidden_subscript);
			if (!is_hidden_subscript && (max_subsc_len < (gv_currkey->end + 1)))
				max_subsc_len = gv_currkey->end + 1;
			v.str.addr = (char*)cp1;
			v.str.len =INTCAST(rec_len - (cp1 - (unsigned char *)rp));
			if (expected_sn_chunk_number && !is_hidden_subscript)
			{	/* we were expecting a chunk of an spanning node and we did not get one */
				DISPLAY_INCMP_SN_MSG;
				util_out_print("!_!_Expected chunk number : !UL but found a non-spanning node", TRUE,
						expected_sn_chunk_number + 1);
				if (sn_hold_buff_pos)
					DISPLAY_PARTIAL_SN_HOLD_BUFF;
				KILL_INCMP_SN_IF_NEEDED;
				sn_hold_buff_pos = 0;
				expected_sn_chunk_number = 0;
				ok_to_put = TRUE;
				putting_a_sn = FALSE;
				numsubs = 0;
			}
			if (is_hidden_subscript)
			{	/* it's a chunk and we were expecting one */
				sn_chunk_number = SPAN_GVSUBS2INT((span_subs *) &(gv_currkey->base[gv_currkey->end - 4]));
				if (!expected_sn_chunk_number && is_hidden_subscript && sn_chunk_number)
				{ /* we not expecting a payload chunk (as opposed to a control record) but we got one */
					DISPLAY_INCMP_SN_MSG;
					util_out_print("!_!_Not expecting a spanning node chunk but found chunk : !UL", TRUE,
							sn_chunk_number + 1);
					if (v.str.len)
						DISPLAY_VALUE("!_!_Errant Chunk :");
					continue;
				}
				if (0 == sn_chunk_number)
				{ 	/* first spanning node chunk, get ctrl info */
					if (0 != expected_sn_chunk_number)
					{
						DISPLAY_INCMP_SN_MSG;
						util_out_print("!_!_Expected chunk number : !UL but found chunk number : !UL", TRUE,
								expected_sn_chunk_number + 1, sn_chunk_number + 1);
						if (sn_hold_buff_pos)
							DISPLAY_PARTIAL_SN_HOLD_BUFF;
						KILL_INCMP_SN_IF_NEEDED;
					}
					/* start building a new spanning node */
					sn_gvkey->end = gv_currkey->end - (SPAN_SUBS_LEN + 1);
					memcpy(sn_gvkey->base, gv_currkey->base, sn_gvkey->end);
					sn_gvkey->base[sn_gvkey->end] = 0;
					sn_gvkey->prev = gv_currkey->prev;
					sn_gvkey->top = gv_currkey->top;
					GET_NSBCTRL(v.str.addr, numsubs, gblsize);
					/* look for first payload chunk */
					expected_sn_chunk_number = 1;
					sn_hold_buff_pos = 0;
					ok_to_put = FALSE;
					sn_incmp_gbl_already_killed = FALSE;
				} else
				{	/* we only need to compare the key before the hidden subscripts */
					if ((expected_sn_chunk_number == sn_chunk_number)
							&& (sn_gvkey->end == gv_currkey->end - (SPAN_SUBS_LEN + 1))
							&& !memcmp(sn_gvkey->base,gv_currkey->base, sn_gvkey->end)
							&& ((sn_hold_buff_pos + v.str.len) <= gblsize))
					{
						if (NULL == sn_hold_buff)
						{
							sn_hold_buff_size = DEFAULT_SN_HOLD_BUFF_SIZE;
							sn_hold_buff = (char *)malloc(DEFAULT_SN_HOLD_BUFF_SIZE);
						}
						if ((sn_hold_buff_pos + v.str.len) > sn_hold_buff_size)
						{
							sn_hold_buff_size = sn_hold_buff_size * 2;
							sn_hold_buff_temp = (char *)malloc(sn_hold_buff_size);
							memcpy(sn_hold_buff_temp, sn_hold_buff, sn_hold_buff_pos);
							free (sn_hold_buff);
							sn_hold_buff = sn_hold_buff_temp;
						}
						memcpy(sn_hold_buff + sn_hold_buff_pos, v.str.addr, v.str.len);
						sn_hold_buff_pos += v.str.len;
						if (expected_sn_chunk_number == numsubs)
						{
							if (sn_hold_buff_pos != gblsize)
							{	/* we don't have the expected size even though 	*/
								/* we have all the expected chunks.		 		*/
								DISPLAY_INCMP_SN_MSG;
								util_out_print("!_!_Expected size : !UL actual size : !UL", TRUE,
										gblsize, sn_hold_buff_pos);
								if (sn_hold_buff_pos)
									DISPLAY_PARTIAL_SN_HOLD_BUFF;
								KILL_INCMP_SN_IF_NEEDED;
								expected_sn_chunk_number = 0;
								ok_to_put = FALSE;
								sn_hold_buff_pos = 0;
							}
							else
							{
								expected_sn_chunk_number = 0;
								ok_to_put = TRUE;
								putting_a_sn = TRUE;
							}

						}else
							expected_sn_chunk_number++;
					}else
					{
						DISPLAY_INCMP_SN_MSG;
						if ((sn_hold_buff_pos + v.str.len) <= gblsize)
							util_out_print("!_!_Expected chunk number : !UL but found chunk number : !UL", /*BYPASSOK*/
								TRUE, expected_sn_chunk_number + 1, sn_chunk_number + 1);
						else
							util_out_print("!_!_Global value too large:  expected size : !UL actual size : !UL chunk number : !UL", TRUE, /*BYPASSOK*/
								gblsize, sn_hold_buff_pos + v.str.len, sn_chunk_number + 1);
						if (sn_hold_buff_pos)
							DISPLAY_PARTIAL_SN_HOLD_BUFF;
						if (v.str.len)
							DISPLAY_VALUE("!_!_Errant Chunk :");
						KILL_INCMP_SN_IF_NEEDED;
						sn_hold_buff_pos = 0;
						expected_sn_chunk_number = 0;
					}
				}
			} else
				ok_to_put = TRUE;
			if (ok_to_put)
			{
					if (putting_a_sn)
					{
						gv_currkey->base[gv_currkey->end - (SPAN_SUBS_LEN + 1)] = 0;
						gv_currkey->end -= (SPAN_SUBS_LEN + 1);
						v.str.addr = sn_hold_buff;
						v.str.len = sn_hold_buff_pos;
					}
					if (max_data_len < v.str.len)
						max_data_len = v.str.len;
					bin_call_db(BIN_PUT, (INTPTR_T)&v, 0);
					if (mupip_error_occurred)
					{
						if (!mupip_DB_full)
						{
							bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
							file_offset = file_offset_base + ((unsigned char *)rp - ptr_base);
							util_out_print("!_!_at File offset : [0x!XL]", TRUE, file_offset);
							DISPLAY_CURRKEY;
							DISPLAY_VALUE("!_!_Value :");
						}
						break;
					}
					if (putting_a_sn)
						putting_a_sn = FALSE;
					else
					{
						key_count++;
						global_key_count++;
					}
			}
		}
	}
	GTMCRYPT_ONLY(
		if (NULL != hash_array)
			free(hash_array);
	)
Beispiel #23
0
/*======================================================================= 
Function: Loc_ReadGPSSettings()

Description: 
   Reads the GPS configuration settings from the configuration file.
=======================================================================*/
static uint32 Loc_ReadGPSSettings(IFile * pIFile, AEEGPSConfig *gpsConfig)
{
   char    *pszBuf = NULL;
   char    *pszTok = NULL;
   char    *pszSvr = NULL;
   char    *pszDelimiter = ";";
   int32   nResult = 0;
   FileInfo fiInfo;

   if (pIFile == NULL || gpsConfig == NULL)
      return EFAILED;

   if ( SUCCESS != IFILE_GetInfo( pIFile, &fiInfo ) ) {
      return EFAILED;
   }

   if ( fiInfo.dwSize == 0 ) {
      return EFAILED;
   }

   // Allocate enough memory to read the full text into memory
   pszBuf = MALLOC( fiInfo.dwSize );

   nResult = IFILE_Read( pIFile, pszBuf, fiInfo.dwSize );
   if ( (uint32)nResult < fiInfo.dwSize ) {
      FREE( pszBuf );
      return EFAILED;
   }

   // Check for an optimization mode setting in the file:
   pszTok = STRSTR( pszBuf, LOC_CONFIG_OPT_STRING );
   if ( pszTok ) {
      pszTok = pszTok + STRLEN( LOC_CONFIG_OPT_STRING );
      gpsConfig->optim = (AEEGPSOpt)STRTOUL( pszTok, &pszDelimiter, 10 );
   }

   // Check for a QoS setting in the file:
   pszTok = STRSTR( pszBuf, LOC_CONFIG_QOS_STRING );
   if ( pszTok ) {
      pszTok = pszTok + STRLEN( LOC_CONFIG_QOS_STRING );
      gpsConfig->qos = (AEEGPSQos)STRTOUL( pszTok, &pszDelimiter, 10 );
   }

   // Check for a server type setting in the file:
   pszTok = STRSTR( pszBuf, LOC_CONFIG_SVR_TYPE_STRING );
   if ( pszTok ) {
      pszTok = pszTok + STRLEN( LOC_CONFIG_SVR_TYPE_STRING );
      gpsConfig->server.svrType = STRTOUL( pszTok, &pszDelimiter, 10 );

      // If the server type is IP, we need to find the ip address and the port number
      if ( AEEGPS_SERVER_IP == gpsConfig->server.svrType ) {
         pszTok = STRSTR( pszBuf, LOC_CONFIG_SVR_IP_STRING );
         if ( pszTok ) {
            pszTok = pszTok + STRLEN( LOC_CONFIG_SVR_IP_STRING );
            nResult = DistToSemi( pszTok );
            pszSvr = MALLOC( nResult+1 );
            STRNCPY( pszSvr, pszTok, nResult );
            *(pszSvr+nResult) = 0;  // Need to manually NULL-terminate the string
            if ( !INET_ATON( pszSvr, &gpsConfig->server.svr.ipsvr.addr ) ) {
               FREE( pszBuf );
               FREE( pszSvr );
               return EFAILED;
            }
            FREE( pszSvr );
         }
         pszTok = STRSTR( pszBuf, LOC_CONFIG_SVR_PORT_STRING );
         if ( pszTok ) {
            pszTok = pszTok + STRLEN( LOC_CONFIG_SVR_PORT_STRING );
            gpsConfig->server.svr.ipsvr.port = AEE_htons((INPort)STRTOUL( pszTok, &pszDelimiter, 10 ));
         }
      }
   }

   FREE( pszBuf );
   
   return SUCCESS;
}
Beispiel #24
0
/*===========================================================================

FUNCTION ISmsApp_InitAppData

DESCRIPTION
   This function initializes app specific data.

PROTOTYPE:
  static boolean ISmsApp_InitAppData(IApplet* pi);

PARAMETERS:
  pi [in]: Pointer to the IApplet structure.

DEPENDENCIES
    None.

RETURN VALUE
    TRUE: If the app has app data is allocated and initialized successfully
    FALSE: Either app data could not be allocated or initialized

SIDE EFFECTS
    None.
===========================================================================*/
static boolean ISmsApp_InitAppData(IApplet* pi)
{
    ISmsApp * pMe = (ISmsApp*)pi;
    int charHeight, pnAscent, pnDescent;
    AEEDeviceInfo di;
    int nErr;
    int i;
    AECHAR szwStr[32];
    char szNumber[32];

#define MAX_ENC 32
    uint32 *EncodingMoSms;
    uint32 nSize;

    IModel * pIModel = NULL;
    // Make sure the pointers we'll be using are valid
    if (pMe == NULL || pMe->a.m_pIShell == NULL)
        return FALSE;

    pMe->m_pIMenu = NULL;
    pMe->m_pISMSMsg = NULL;
    pMe->m_pISMS      = NULL;
    pMe->m_pISMSStorage = NULL;



    // Determine the amount of available screen space
    ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&di);

    // Determine the height of a line of text
    charHeight = IDISPLAY_GetFontMetrics (pMe->a.m_pIDisplay, AEE_FONT_NORMAL,
                                          &pnAscent, &pnDescent);

    // Number of available lines equals the available screen
    // space divided by the height of a line, minus 3 for the
    // lines we always print at the top and bottom of the screen
    pMe->m_cMaxLine = (di.cyScreen / charHeight) - 3;

    nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMS, (void **)&pMe->m_pISMS);
    DBGPRINTF("CreateInstance of AEECLSID_SMS ret %d", nErr);
    if(nErr != AEE_SUCCESS)
    {
        return FALSE;
    }

    if ((ISMS_GetEncodingsAvailableForMOSMS(pMe->m_pISMS, NULL, (uint32*)&nSize) == SUCCESS) &&
            ((EncodingMoSms = (uint32*)MALLOC(nSize)) != NULL) &&
            (ISMS_GetEncodingsAvailableForMOSMS(pMe->m_pISMS, EncodingMoSms, (uint32*)&nSize) == SUCCESS))
    {
        nSize = nSize/sizeof(uint32);
        DBGPRINTF("ISMS_GetEncodingsAvailableForMOSMS");
        DBGPRINTF("size Encode ret:%d", nSize);
        for(i=0; i<nSize; i++)
        {
            DBGPRINTF("en[%d]=%x", i, EncodingMoSms[i]);
        }
    }

    if ((nErr = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMSSTORAGE, (void**)&pMe->m_pISMSStorage)) != SUCCESS)
    {
        DBGPRINTF("CreateInstance SMSSTORAGE ret %d", nErr);
        return FALSE;
    }

    if (pMe->m_pISMSStorage &&
            (SUCCESS == ISMSSTORAGE_QueryInterface(pMe->m_pISMSStorage, AEEIID_MODEL, (void**)&pIModel)))
    {
        IMODEL_AddListenerEx(pIModel, &pMe->m_SMSStorageModelListener, (PFNLISTENER)OATSMSStorage_ModelListener, pMe);
        IMODEL_Release(pIModel);
        pIModel = NULL;
    }

    ISHELL_LoadResString(pMe->a.m_pIShell, ISMS_RES_FILE, IDS_SMS_TAG, szwStr, sizeof(szwStr));
    WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));
    pMe->m_tag = STRTOUL(szNumber, NULL, 10);

    ISHELL_LoadResString(pMe->a.m_pIShell, ISMS_RES_FILE, IDS_SMS_MT, szwStr, sizeof(szwStr));
    WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));
    pMe->m_mt = STRTOUL(szNumber, NULL, 10);

    return TRUE;
}
static boolean CSettings_Dialog_HandleEvent(void *po, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
	CSettings* pMe = (CSettings*) po;
	user *pUser=NULL;
	AECHAR *rangetext=NULL;
	char* charrangetext=NULL;
	unsigned long time=0;
   
	if(evt == EVT_WDG_GETPROPERTY && wParam == FID_PREFRECT) {
		//catch FID_PREFRECT and set preferred extent of menu

		AEERect rc;   
		ISHELL_GetDeviceInfo(pMe->pIShell, &pMe->DeviceInfo);
		if(pMe->isRoomimgDialog==1){
			pMe->isRoomimgDialog=0;
			rc.x = pMe->DeviceInfo.cxScreen/10;
			rc.y = pMe->DeviceInfo.cyScreen/2;
			rc.dx = pMe->DeviceInfo.cxScreen*5/6;
			rc.dy = pMe->DeviceInfo.cyScreen-pMe->DeviceInfo.cyScreen*3/5;
			*(AEERect*) dwParam = rc;
		}else{

			rc.x = 0;
			rc.y = pMe->DeviceInfo.cyScreen/4;
			rc.dx = pMe->DeviceInfo.cxScreen;
			rc.dy = pMe->DeviceInfo.cyScreen-pMe->DeviceInfo.cyScreen*19/56;
			*(AEERect*) dwParam = rc;
		}
		return TRUE;
	}

	if(evt == EVT_KEY && (wParam == AVK_CLR || wParam == AVK_SOFT2))
	{
		IROOTFORM_PopForm(pMe->rootForm);
		deleteDialog(pMe);
		deleteShdulerForm(pMe);
		if(pMe->dialog)
		{
			IDIALOG_Release(pMe->dialog);
			pMe->dialog=NULL;
		}
		return TRUE;
	}

	if(evt == EVT_KEY && wParam == AVK_SOFT1)
	{
	   if ( GetUserData(pMe->pIShell, &pUser))
		{			
			if(pMe->dialogEvent==1)
			{
		
				STRCPY(pUser->roomingState,"ON");
				
			}if(pMe->dialogEvent==2)
			{
				
				STRCPY(pUser->roomingState,"OFF");
			
			}
			if(pMe->dialogEvent==3)
			{

			IWIDGET_GetTextWidgetText(pMe->rangeCreateTextWidget,&rangetext);
			charrangetext=MALLOC(30);
			WSTRTOSTR(rangetext,charrangetext,30);

			if(IVALUEMODEL_GetBool(pMe->valueModel3))
			{
				STRCPY(pUser->sheduler,"h");
				if(STRTOUL(charrangetext, NULL, 10)>1000)
					time=500*3600000;
				else
					time = STRTOUL(charrangetext, NULL, 10)*3600000;		
			}
			if(IVALUEMODEL_GetBool(pMe->valueModel4))
			{
				STRCPY(pUser->sheduler,"m");
				time = STRTOUL(charrangetext, NULL, 10)*60000;
			}
			if(IVALUEMODEL_GetBool(pMe->valueModel5))
			{
				STRCPY(pUser->sheduler,"s");
				time = STRTOUL(charrangetext, NULL, 10)*1000;
			}		
			pUser->shedulePeriod=time;
				
		}
		SetUserData(pMe->pIShell, pUser);
		pMe->dialogEvent=0;
		FREEIF(charrangetext);
		FREEIF(pUser);
	}
		
	IROOTFORM_PopForm(pMe->rootForm);
	deleteDialog(pMe);
	deleteShdulerForm(pMe);

	if(pMe->dialog)
	{
		IDIALOG_Release(pMe->dialog);
		pMe->dialog=NULL;
	}
	return TRUE;

   }

   //the  default form handler is swapped with the AppForm handler
   // calling this allows the default form handler to handle the event
   return HANDLERDESC_Call(&pMe->dlgHandler, evt, wParam, dwParam);
}
Beispiel #26
0
ACPI_STATUS
acpi_ns_root_initialize (void)
{
	ACPI_STATUS             status = AE_OK;
	PREDEFINED_NAMES        *init_val = NULL;
	ACPI_NAMESPACE_NODE     *new_node;
	ACPI_OPERAND_OBJECT     *obj_desc;


	acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE);

	/*
	 * The global root ptr is initially NULL, so a non-NULL value indicates
	 * that Acpi_ns_root_initialize() has already been called; just return.
	 */

	if (acpi_gbl_root_node) {
		status = AE_OK;
		goto unlock_and_exit;
	}


	/*
	 * Tell the rest of the subsystem that the root is initialized
	 * (This is OK because the namespace is locked)
	 */

	acpi_gbl_root_node = &acpi_gbl_root_node_struct;


	/* Enter the pre-defined names in the name table */

	for (init_val = acpi_gbl_pre_defined_names; init_val->name; init_val++) {
		status = acpi_ns_lookup (NULL, init_val->name,
				 (OBJECT_TYPE_INTERNAL) init_val->type,
				 IMODE_LOAD_PASS2, NS_NO_UPSEARCH,
				 NULL, &new_node);


		/*
		 * Name entered successfully.
		 * If entry in Pre_defined_names[] specifies an
		 * initial value, create the initial value.
		 */

		if (init_val->val) {
			/*
			 * Entry requests an initial value, allocate a
			 * descriptor for it.
			 */

			obj_desc = acpi_cm_create_internal_object (
					  (OBJECT_TYPE_INTERNAL) init_val->type);

			if (!obj_desc) {
				status = AE_NO_MEMORY;
				goto unlock_and_exit;
			}

			/*
			 * Convert value string from table entry to
			 * internal representation. Only types actually
			 * used for initial values are implemented here.
			 */

			switch (init_val->type)
			{

			case ACPI_TYPE_NUMBER:

				obj_desc->number.value =
						(ACPI_INTEGER) STRTOUL (init_val->val, NULL, 10);
				break;


			case ACPI_TYPE_STRING:

				obj_desc->string.length =
						(u16) STRLEN (init_val->val);

				/*
				 * Allocate a buffer for the string.  All
				 * String.Pointers must be allocated buffers!
				 * (makes deletion simpler)
				 */
				obj_desc->string.pointer = acpi_cm_allocate (
						   (obj_desc->string.length + 1));
				if (!obj_desc->string.pointer) {
					acpi_cm_remove_reference (obj_desc);
					status = AE_NO_MEMORY;
					goto unlock_and_exit;
				}

				STRCPY (obj_desc->string.pointer, init_val->val);
				break;


			case ACPI_TYPE_MUTEX:

				obj_desc->mutex.sync_level =
						(u16) STRTOUL (init_val->val, NULL, 10);

				if (STRCMP (init_val->name, "_GL_") == 0) {
					/*
					 * Create a counting semaphore for the
					 * global lock
					 */
					status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT,
							 1, &obj_desc->mutex.semaphore);

					if (ACPI_FAILURE (status)) {
						goto unlock_and_exit;
					}
					/*
					 * We just created the mutex for the
					 * global lock, save it
					 */

					acpi_gbl_global_lock_semaphore = obj_desc->mutex.semaphore;
				}

				else {
					/* Create a mutex */

					status = acpi_os_create_semaphore (1, 1,
							   &obj_desc->mutex.semaphore);

					if (ACPI_FAILURE (status)) {
						goto unlock_and_exit;
					}
				}
				break;


			default:
				REPORT_ERROR (("Unsupported initial type value %X\n",
					init_val->type));
				acpi_cm_remove_reference (obj_desc);
				obj_desc = NULL;
				continue;
			}

			/* Store pointer to value descriptor in the Node */

			acpi_ns_attach_object (new_node, obj_desc,
					   obj_desc->common.type);
		}
	}


unlock_and_exit:
	acpi_cm_release_mutex (ACPI_MTX_NAMESPACE);
	return (status);
}
Beispiel #27
0
void
AcpiDbCreateExecutionThreads (
    NATIVE_CHAR             *NumThreadsArg,
    NATIVE_CHAR             *NumLoopsArg,
    NATIVE_CHAR             *MethodNameArg)
{
    ACPI_STATUS             Status;
    UINT32                  NumThreads;
    UINT32                  NumLoops;
    UINT32                  i;
    ACPI_HANDLE             ThreadGate;


    /* Get the arguments */

    NumThreads = STRTOUL (NumThreadsArg, NULL, 0);
    NumLoops = STRTOUL (NumLoopsArg, NULL, 0);

    if (!NumThreads || !NumLoops)
    {
        AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", NumThreads, NumLoops);
        return;
    }


    /* Create the synchronization semaphore */

    Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate);
    if (ACPI_FAILURE (Status))
    {
        AcpiOsPrintf ("Could not create semaphore, %s\n", AcpiFormatException (Status));
        return;
    }

    /* Setup the context to be passed to each thread */

    AcpiGbl_DbMethodInfo.Name = MethodNameArg;
    AcpiGbl_DbMethodInfo.Args = NULL;
    AcpiGbl_DbMethodInfo.Flags = 0;
    AcpiGbl_DbMethodInfo.NumLoops = NumLoops;
    AcpiGbl_DbMethodInfo.ThreadGate = ThreadGate;

    AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);


    /* Create the threads */

    AcpiOsPrintf ("Creating %X threads to execute %X times each\n", NumThreads, NumLoops);

    for (i = 0; i < (NumThreads); i++)
    {
        AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, &AcpiGbl_DbMethodInfo);
    }


    /* Wait for all threads to complete */

    i = NumThreads;
    while (i)   /* Brain damage for OSD implementations that only support wait of 1 unit */
    {
        Status = AcpiOsWaitSemaphore (ThreadGate, 1, WAIT_FOREVER);
        i--;
    }

    /* Cleanup and exit */

    AcpiOsDeleteSemaphore (ThreadGate);

    AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT);
    AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads);
    AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT);
}
void
acpi_db_set_method_data (
	NATIVE_CHAR             *type_arg,
	NATIVE_CHAR             *index_arg,
	NATIVE_CHAR             *value_arg)
{
	NATIVE_CHAR             type;
	u32                     index;
	u32                     value;
	acpi_walk_state         *walk_state;
	acpi_operand_object     *obj_desc;


	/* Validate Type_arg */

	STRUPR (type_arg);
	type = type_arg[0];
	if ((type != 'L') &&
		(type != 'A')) {
		acpi_os_printf ("Invalid SET operand: %s\n", type_arg);
		return;
	}

	/* Get the index and value */

	index = STRTOUL (index_arg, NULL, 16);
	value = STRTOUL (value_arg, NULL, 16);

	walk_state = acpi_ds_get_current_walk_state (acpi_gbl_current_walk_list);
	if (!walk_state) {
		acpi_os_printf ("There is no method currently executing\n");
		return;
	}


	/* Create and initialize the new object */

	obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
	if (!obj_desc) {
		acpi_os_printf ("Could not create an internal object\n");
		return;
	}

	obj_desc->integer.value = value;


	/* Store the new object into the target */

	switch (type) {
	case 'A':

		/* Set a method argument */

		if (index > MTH_NUM_ARGS) {
			acpi_os_printf ("Arg%d - Invalid argument name\n", index);
			return;
		}

		acpi_ds_store_object_to_local (AML_ARG_OP, index, obj_desc, walk_state);
		obj_desc = walk_state->arguments[index].object;

		acpi_os_printf ("Arg%d: ", index);
		acpi_db_display_internal_object (obj_desc, walk_state);
		break;

	case 'L':

		/* Set a method local */

		if (index > MTH_NUM_LOCALS) {
			acpi_os_printf ("Local%d - Invalid local variable name\n", index);
			return;
		}

		acpi_ds_store_object_to_local (AML_LOCAL_OP, index, obj_desc, walk_state);
		obj_desc = walk_state->local_variables[index].object;

		acpi_os_printf ("Local%d: ", index);
		acpi_db_display_internal_object (obj_desc, walk_state);
		break;

	default:
		break;
	}
}
Beispiel #29
0
void bin_load(uint4 begin, uint4 end)
{
	unsigned char	*ptr, *cp1, *cp2, *btop, *gvkey_char_ptr, *tmp_ptr, *tmp_key_ptr, *c, *ctop;
	unsigned char	hdr_lvl, src_buff[MAX_KEY_SZ + 1], dest_buff[MAX_ZWR_KEY_SZ],
			cmpc_str[MAX_KEY_SZ + 1], dup_key_str[MAX_KEY_SZ + 1];
	unsigned char	*end_buff;
	unsigned short	rec_len, next_cmpc;
	int		len;
	int		current, last, length, max_blk_siz, max_key, status;
	uint4		iter, max_data_len, max_subsc_len, key_count;
	ssize_t	        rec_count, global_key_count, subsc_len,extr_std_null_coll;
	boolean_t	need_xlation, new_gvn, utf8_extract;
	rec_hdr		*rp, *next_rp;
	mval		v, tmp_mval;
	mstr		mstr_src, mstr_dest;
	collseq		*extr_collseq, *db_collseq, *save_gv_target_collseq;
	coll_hdr	extr_collhdr, db_collhdr;
	gv_key 		*tmp_gvkey = NULL;	/* null-initialize at start, will be malloced later */
	char		std_null_coll[BIN_HEADER_NUMSZ + 1];
#	ifdef GTM_CRYPT
	gtmcrypt_key_t			*encr_key_handles;
	char				*inbuf;
	int4				index;
	int				req_dec_blk_size, init_status, crypt_status;
	muext_hash_hdr_ptr_t		hash_array = NULL;
#	endif
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	assert(4 == SIZEOF(coll_hdr));
	gvinit();
	v.mvtype = MV_STR;
	len = file_input_bin_get((char **)&ptr);
	hdr_lvl = EXTR_HEADER_LEVEL(ptr);
	if (!(((('4' == hdr_lvl) || ('5' == hdr_lvl)) && (BIN_HEADER_SZ == len)) || (('4' > hdr_lvl) && (V3_BIN_HEADER_SZ == len))))
	{
		rts_error(VARLSTCNT(1) ERR_LDBINFMT);
		mupip_exit(ERR_LDBINFMT);
	}
	/* expecting the level in a single character */
	assert(' ' == *(ptr + SIZEOF(BIN_HEADER_LABEL) - 3));
	if (0 != memcmp(ptr, BIN_HEADER_LABEL, SIZEOF(BIN_HEADER_LABEL) - 2) || ('2' > hdr_lvl) || *(BIN_HEADER_VERSION) < hdr_lvl)
	{	/* ignore the level check */
		rts_error(VARLSTCNT(1) ERR_LDBINFMT);
		mupip_exit(ERR_LDBINFMT);
	}
	/* check if extract was generated in UTF-8 mode */
	utf8_extract = (0 == MEMCMP_LIT(&ptr[len - BIN_HEADER_LABELSZ], UTF8_NAME)) ? TRUE : FALSE;
	if ((utf8_extract && !gtm_utf8_mode) || (!utf8_extract && gtm_utf8_mode))
	{ /* extract CHSET doesn't match $ZCHSET */
		if (utf8_extract)
			rts_error(VARLSTCNT(4) ERR_LOADINVCHSET, 2, LEN_AND_LIT("UTF-8"));
		else
			rts_error(VARLSTCNT(4) ERR_LOADINVCHSET, 2, LEN_AND_LIT("M"));
		mupip_exit(ERR_LDBINFMT);
	}
	if ('4' >= hdr_lvl)
	{	/* Binary extracts in V50000-to-V52000 (label=4) and pre-V50000 (label=3) could have a '\0' byte (NULL byte)
		 * in the middle of the string. Replace it with ' ' (space) like it would be in V52000 binary extracts and above.
		 */
		for (c = ptr, ctop = c + len; c < ctop; c++)
		{
			if ('\0' == *c)
				*c = ' ';
		}
	}
	util_out_print("Label = !AD\n", TRUE, len, ptr);
	new_gvn = FALSE;
	if (hdr_lvl > '3')
	{
		memcpy(std_null_coll, ptr + BIN_HEADER_NULLCOLLOFFSET, BIN_HEADER_NUMSZ);
		std_null_coll[BIN_HEADER_NUMSZ] = '\0';
		extr_std_null_coll = STRTOUL(std_null_coll, NULL, 10);
		if (0 != extr_std_null_coll && 1!= extr_std_null_coll)
		{
			rts_error(VARLSTCNT(5) ERR_TEXT, 2, RTS_ERROR_TEXT("Corrupted null collation field  in header"),
				ERR_LDBINFMT);
			mupip_exit(ERR_LDBINFMT);
		}
	} else
		extr_std_null_coll = 0;
#	ifdef GTM_CRYPT
	if ('5' <= hdr_lvl)
	{
		int	i, num_indexes;
		len = file_input_bin_get((char **)&ptr);
		hash_array = (muext_hash_hdr *)malloc(len);
		/* store hashes of all the files used during extract into muext_hash_hdr structure */
		memcpy((char *)hash_array, ptr, len);
		num_indexes = len / GTMCRYPT_HASH_LEN;
		encr_key_handles = (gtmcrypt_key_t *)malloc(SIZEOF(gtmcrypt_key_t) * num_indexes);
		INIT_PROC_ENCRYPTION(crypt_status);
		GC_BIN_LOAD_ERR(crypt_status);
		for (index = 0; index < num_indexes; index++)
		{
			if (0 == memcmp(hash_array[index].gtmcrypt_hash, EMPTY_GTMCRYPT_HASH, GTMCRYPT_HASH_LEN))
				continue;
			GTMCRYPT_GETKEY(hash_array[index].gtmcrypt_hash, encr_key_handles[index], crypt_status);
			GC_BIN_LOAD_ERR(crypt_status);
		}
	}
#	endif
	if ('2' < hdr_lvl)
	{
		len = file_input_bin_get((char **)&ptr);
		if (SIZEOF(coll_hdr) != len)
		{
			rts_error(VARLSTCNT(5) ERR_TEXT, 2, RTS_ERROR_TEXT("Corrupt collation header"), ERR_LDBINFMT);
			mupip_exit(ERR_LDBINFMT);
		}
		extr_collhdr = *((coll_hdr *)(ptr));
		new_gvn = TRUE;
	} else
		gtm_putmsg(VARLSTCNT(3) ERR_OLDBINEXTRACT, 1, hdr_lvl - '0');
	if (begin < 2)
		begin = 2;
	for (iter = 2; iter < begin; iter++)
	{
		if (!(len = file_input_bin_get((char **)&ptr)))
		{
			gtm_putmsg(VARLSTCNT(3) ERR_LOADEOF, 1, begin);
			util_out_print("Error reading record number: !UL\n", TRUE, iter);
			mupip_error_occurred = TRUE;
			return;
		} else if (len == SIZEOF(coll_hdr))
		{
			extr_collhdr = *((coll_hdr *)(ptr));
			assert(hdr_lvl > '2');
			iter--;
		}
	}
	assert(iter == begin);
	util_out_print("Beginning LOAD at record number: !UL\n", TRUE, begin);
	max_data_len = 0;
	max_subsc_len = 0;
	global_key_count = key_count = 0;
	rec_count = begin - 1;
	extr_collseq = db_collseq = NULL;
	need_xlation = FALSE;
	assert(NULL == tmp_gvkey);	/* GVKEY_INIT macro relies on this */
	GVKEY_INIT(tmp_gvkey, DBKEYSIZE(MAX_KEY_SZ));	/* tmp_gvkey will point to malloced memory after this */
	for (; !mupip_DB_full ;)
	{
		if (++rec_count > end)
			break;
		next_cmpc = 0;
		mupip_error_occurred = FALSE;
		if (mu_ctrly_occurred)
			break;
		if (mu_ctrlc_occurred)
		{
			util_out_print("!AD:!_  Key cnt: !UL  max subsc len: !UL  max data len: !UL", TRUE,
				LEN_AND_LIT(gt_lit), key_count, max_subsc_len, max_data_len);
			util_out_print("Last LOAD record number: !UL", TRUE, key_count ? (rec_count - 1) : 0);
			mu_gvis();
			util_out_print(0, TRUE);
			mu_ctrlc_occurred = FALSE;
		}
		/* reset the stringpool for every record in order to avoid garbage collection */
		stringpool.free = stringpool.base;
		if (!(len = file_input_bin_get((char **)&ptr)) || mupip_error_occurred)
			break;
		else if (len == SIZEOF(coll_hdr))
		{
			extr_collhdr = *((coll_hdr *)(ptr));
			assert(hdr_lvl > '2');
			new_gvn = TRUE;			/* next record will contain a new gvn */
			rec_count--;	/* Decrement as this record does not count as a record for loading purposes */
			continue;
		}
		rp = (rec_hdr*)(ptr);
#		ifdef GTM_CRYPT
		if ('5' <= hdr_lvl)
		{	/* Getting index value from the extracted file. It indicates which database file this record belongs to */
			GET_LONG(index, ptr);
			if (-1 != index) /* Indicates that the record is encrypted. */
			{
				req_dec_blk_size = len - SIZEOF(int4);
				inbuf = (char *)(ptr + SIZEOF(int4));
				GTMCRYPT_DECODE_FAST(encr_key_handles[index], inbuf, req_dec_blk_size, NULL, crypt_status);
				GC_BIN_LOAD_ERR(crypt_status);
			}
			rp = (rec_hdr*)(ptr + SIZEOF(int4));
		}
#		endif
		btop = ptr + len;
		cp1 = (unsigned char*)(rp + 1);
		v.str.addr = (char*)cp1;
		while (*cp1++)
			;
		v.str.len =INTCAST((char*)cp1 - v.str.addr - 1);
		if (('2' >= hdr_lvl) || new_gvn)
		{
			if ((HASHT_GBLNAME_LEN == v.str.len) &&	(0 == memcmp(v.str.addr, HASHT_GBLNAME, HASHT_GBLNAME_LEN)))
				continue;
			bin_call_db(BIN_BIND, (INTPTR_T)gd_header, (INTPTR_T)&v.str);
			max_key = gv_cur_region->max_key_size;
			db_collhdr.act = gv_target->act;
			db_collhdr.ver = gv_target->ver;
			db_collhdr.nct = gv_target->nct;
		}
		GET_USHORT(rec_len, &rp->rsiz);
		if (rp->cmpc != 0 || v.str.len > rec_len || mupip_error_occurred)
		{
			bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
			mu_gvis();
			util_out_print(0, TRUE);
			continue;
		}
		if (new_gvn)
		{
			global_key_count = 1;
			if ((db_collhdr.act != extr_collhdr.act || db_collhdr.ver != extr_collhdr.ver
				|| db_collhdr.nct != extr_collhdr.nct
				|| gv_cur_region->std_null_coll != extr_std_null_coll))
			{
				if (extr_collhdr.act)
				{
					if (extr_collseq = ready_collseq((int)extr_collhdr.act))
					{
						if (!do_verify(extr_collseq, extr_collhdr.act, extr_collhdr.ver))
						{
							gtm_putmsg(VARLSTCNT(8) ERR_COLLTYPVERSION, 2, extr_collhdr.act,
								extr_collhdr.ver, ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
							mupip_exit(ERR_COLLTYPVERSION);
						}
					} else
					{
						gtm_putmsg(VARLSTCNT(7) ERR_COLLATIONUNDEF, 1, extr_collhdr.act,
							ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
						mupip_exit(ERR_COLLATIONUNDEF);
					}
				}
				if (db_collhdr.act)
				{
					if (db_collseq = ready_collseq((int)db_collhdr.act))
					{
						if (!do_verify(db_collseq, db_collhdr.act, db_collhdr.ver))
						{
							gtm_putmsg(VARLSTCNT(8) ERR_COLLTYPVERSION, 2, db_collhdr.act,
								db_collhdr.ver, ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
							mupip_exit(ERR_COLLTYPVERSION);
						}
					} else
					{
						gtm_putmsg(VARLSTCNT(7) ERR_COLLATIONUNDEF, 1, db_collhdr.act,
							ERR_GVIS, 2, gv_altkey->end - 1, gv_altkey->base);
						mupip_exit(ERR_COLLATIONUNDEF);
					}
				}
				need_xlation = TRUE;
			} else
				need_xlation = FALSE;
		}
		new_gvn = FALSE;
		for (; rp < (rec_hdr*)btop; rp = (rec_hdr*)((unsigned char *)rp + rec_len))
		{
			GET_USHORT(rec_len, &rp->rsiz);
			if (rec_len + (unsigned char *)rp > btop)
			{
				bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
				mu_gvis();
				util_out_print(0, TRUE);
				break;
			}
			cp1 =  (unsigned char*)(rp + 1);
			cp2 = gv_currkey->base + rp->cmpc;
			current = 1;
			for (;;)
			{
				last = current;
				current = *cp2++ = *cp1++;
				if (0 == last && 0 == current)
					break;
				if (cp1 > (unsigned char *)rp + rec_len ||
				    cp2 > (unsigned char *)gv_currkey + gv_currkey->top)
				{
					bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
					mu_gvis();
					util_out_print(0, TRUE);
					break;
				}
			}
			if (mupip_error_occurred)
				break;
			gv_currkey->end = cp2 - gv_currkey->base - 1;
			if (need_xlation)
			{
				assert(hdr_lvl >= '3');
				assert(extr_collhdr.act || db_collhdr.act || extr_collhdr.nct || db_collhdr.nct ||
				 	extr_std_null_coll != gv_cur_region->std_null_coll);
							/* gv_currkey would have been modified/translated in the earlier put */
				memcpy(gv_currkey->base, cmpc_str, next_cmpc);
				next_rp = (rec_hdr *)((unsigned char*)rp + rec_len);
				if ((unsigned char*)next_rp < btop)
				{
					next_cmpc = next_rp->cmpc;
					assert(next_cmpc <= gv_currkey->end);
					memcpy(cmpc_str, gv_currkey->base, next_cmpc);
				} else
					next_cmpc = 0;
							/* length of the key might change (due to nct variation),
							 * so get a copy of the original key from the extract */
				memcpy(dup_key_str, gv_currkey->base, gv_currkey->end + 1);
				gvkey_char_ptr = dup_key_str;
				while (*gvkey_char_ptr++)
					;
				gv_currkey->prev = 0;
				gv_currkey->end = gvkey_char_ptr - dup_key_str;
				assert(gv_keysize <= tmp_gvkey->top);
				while (*gvkey_char_ptr)
				{
						/* get next subscript (in GT.M internal subsc format) */
					subsc_len = 0;
					tmp_ptr = src_buff;
					while (*gvkey_char_ptr)
						*tmp_ptr++ = *gvkey_char_ptr++;
					subsc_len = tmp_ptr - src_buff;
					src_buff[subsc_len] = '\0';
					if (extr_collseq)
					{
						/* undo the extract time collation */
						TREF(transform) = TRUE;
						save_gv_target_collseq = gv_target->collseq;
						gv_target->collseq = extr_collseq;
					} else
						TREF(transform) = FALSE;
						/* convert the subscript to string format */
					end_buff = gvsub2str(src_buff, dest_buff, FALSE);
						/* transform the string to the current subsc format */
					TREF(transform) = TRUE;
					tmp_mval.mvtype = MV_STR;
                                	tmp_mval.str.addr = (char *)dest_buff;
                                	tmp_mval.str.len = INTCAST(end_buff - dest_buff);
					tmp_gvkey->prev = 0;
					tmp_gvkey->end = 0;
					if (extr_collseq)
						gv_target->collseq = save_gv_target_collseq;
					mval2subsc(&tmp_mval, tmp_gvkey);
						/* we now have the correctly transformed subscript */
					tmp_key_ptr = gv_currkey->base + gv_currkey->end;
					memcpy(tmp_key_ptr, tmp_gvkey->base, tmp_gvkey->end + 1);
					gv_currkey->prev = gv_currkey->end;
					gv_currkey->end += tmp_gvkey->end;
					gvkey_char_ptr++;
				}
				if ( gv_cur_region->std_null_coll != extr_std_null_coll && gv_currkey->prev)
				{
					if (extr_std_null_coll == 0)
					{
						GTM2STDNULLCOLL(gv_currkey->base, gv_currkey->end);
					} else
					{
						STD2GTMNULLCOLL(gv_currkey->base, gv_currkey->end);
					}
				}
			}
			if (gv_currkey->end >= max_key)
			{
				bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
				mu_gvis();
				util_out_print(0, TRUE);
				continue;
			}
			if (max_subsc_len < (gv_currkey->end + 1))
				max_subsc_len = gv_currkey->end + 1;
			v.str.addr = (char*)cp1;
			v.str.len =INTCAST(rec_len - (cp1 - (unsigned char *)rp));
			if (max_data_len < v.str.len)
				max_data_len = v.str.len;
			bin_call_db(BIN_PUT, (INTPTR_T)&v, 0);
			if (mupip_error_occurred)
			{
				if (!mupip_DB_full)
				{
					bin_call_db(ERR_COR, (INTPTR_T)rec_count, (INTPTR_T)global_key_count);
					util_out_print(0, TRUE);
				}
				break;
			}
			key_count++;
			global_key_count++;
		}
	}
	GTMCRYPT_ONLY(
		if (NULL != hash_array)
			free(hash_array);
	)
Beispiel #30
0
/*======================================================================= 
Function: SamplePosDet_QosSettings_HandleEvent()

Description: 
   Event handler function for the QoS settings menu.

Prototype:

   boolean SamplePosDet_QosSettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)

Parameters:
   pMe: [in]. CSamplePosDet instance.
   eCode: [in]. Event code.
   wParam: [in]. Event wParam.
   dwParam: [in]. Event dwParam.

Return Value:

   TRUE - If the event was handled by this menu.
   FALSE - If the event was not handled.
 
Comments:  
   None

Side Effects: 
   None

See Also:
   None
=======================================================================*/
boolean SamplePosDet_QosSettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode,
                                                 uint16 wParam, uint32 dwParam)
{
   boolean bHandled = FALSE;
   CTextCtlData *ptcd = SamplePosDet_GetScreenData( pMe );
   ITextCtl *pTextCtl = NULL;
   IMenuCtl *pSoftKeyMenu = NULL;
   char * pszStr;
   AECHAR * pQos;
   uint32 nResult;

   if (ptcd) {
      pSoftKeyMenu = ptcd->pSoftKey;
      pTextCtl = ptcd->pTextCtl;
   }

   switch( eCode ) {
   case EVT_SCREEN:
      if( wParam == SCREEN_PARAM_INIT ) {
         if( pTextCtl ) {  /* This is not expected to happen */
            SamplePosDet_DrawScreen( pMe, 0 );
            bHandled = TRUE;
         }
         else {
            if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_TEXTCTL, 
               (void **)&pTextCtl ) == SUCCESS ) {
               if (ISHELL_CreateInstance(pMe->theApp.m_pIShell, AEECLSID_SOFTKEYCTL,
                  (void **)&pSoftKeyMenu) == SUCCESS) {

                  IMENUCTL_AddItem( pSoftKeyMenu, SAMPLEPOSDET_RES_FILE, IDS_SOFTKEY_SAVE,
                     IDS_SOFTKEY_SAVE, NULL, (uint32)pSoftKeyMenu );

                  ITEXTCTL_SetSoftKeyMenu( pTextCtl, pSoftKeyMenu );
                  ITEXTCTL_SetTitle( pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_QOS_SETTINGS_TITLE, NULL );
                  ITEXTCTL_SetInputMode( pTextCtl, AEE_TM_NUMBERS );

                  // Load the current QoS value, if it exists
                  pszStr = MALLOC(50);
                  pQos = MALLOC(100);
                  SPRINTF(pszStr, "%d", pMe->gpsSettings.qos);
                  STRTOWSTR(pszStr, pQos, 100);
                  ITEXTCTL_SetText(pTextCtl, pQos, -1);
                  FREE(pszStr);
                  FREE(pQos);

                  ptcd = MALLOC( sizeof(CTextCtlData) );

                  ptcd->pSoftKey = pSoftKeyMenu;
                  ptcd->pTextCtl = pTextCtl;
                  SamplePosDet_SetScreenData( pMe, (void *)ptcd );
                  SamplePosDet_DrawScreen( pMe, 0 );
                  bHandled = TRUE;
               }
            }
         }
      }
      else if( wParam == SCREEN_PARAM_CLOSE ) {
         ITEXTCTL_Release( pTextCtl );
         IMENUCTL_Release( pSoftKeyMenu );
         FREE( ptcd );
         SamplePosDet_SetScreenData( pMe, 0 );
         pMe->currentHandler = 0;
         bHandled = TRUE;
      }
      else if( wParam == SCREEN_PARAM_PAINT ) {
         if( ITEXTCTL_IsActive( pTextCtl ) ) {
            ITEXTCTL_Redraw( pTextCtl );
         }
         else {
            ITEXTCTL_SetActive( pTextCtl, TRUE );  /* Also causes a menu draw */
         }
      }
      break;

   case EVT_KEY:
   case EVT_KEY_PRESS:
   case EVT_KEY_RELEASE:
      bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam );
      if (!bHandled) {
         bHandled = IMENUCTL_HandleEvent( pSoftKeyMenu, eCode, wParam, dwParam );
         
         if(!bHandled && wParam == AVK_CLR && eCode == EVT_KEY) {
            SamplePosDet_GotoScreen( pMe, SCREENID_CONFIG, 0 );
            bHandled = TRUE;
         }
      }
      break;
   case EVT_COMMAND:
      bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam );
      if (!bHandled) {
         if (IDS_SOFTKEY_SAVE == wParam) {
            // Need to validate and save the Port settings here
            pQos = ITEXTCTL_GetTextPtr(pTextCtl);
            pszStr = MALLOC(50);
            WSTRTOSTR(pQos, pszStr, 50);
            nResult = STRTOUL(pszStr, NULL, 10);
            if (nResult >= 0 && nResult <= 255) {
               pMe->gpsSettings.qos = (AEEGPSQos)nResult;
               SamplePosDet_SaveGPSSettings(pMe);
               SamplePosDet_GotoScreen(pMe, SCREENID_CONFIG, 0);
            }
            else {
               ITEXTCTL_SetTitle(pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_QOS_SETTINGS_INVALID, NULL);
               ITEXTCTL_Redraw(pTextCtl);
            }
            FREE(pszStr);
            bHandled = TRUE;
         }
      }
      break;
   }
   return bHandled;
}