Ejemplo n.º 1
0
Archivo: values.c Proyecto: schani/chpp
void
builtInTypeof (int numArgs, macroArgument *args, environment *env, outputWriter *ow)
{
    const char *type;

    if (!(numArgs == 1))
    {
	issueError(ERRMAC_WRONG_NUM_ARGS, "typeof");
	return;
    }

    type = cStringForValueType(args[0].value.value->type);

    OUT_STRING(ow, type, strlen(type));
}
Ejemplo n.º 2
0
void PrintModules(HANDLE InfoFile, DWORD dwPID, _Opt& Opt)
{
	ModuleData Data;
	DebugToken token;
	HANDLE hProcess = OpenProcessForced(&token, PROCESS_QUERY_INFORMATION|PROCESS_VM_READ|READ_CONTROL, dwPID);
	PROCESS_PARAMETERS* pProcessParams;
	char *pEnd;

	if (hProcess && GetInternalProcessData(hProcess, &Data, pProcessParams, pEnd, true))
	{
		char *p4;

		do
		{
			int len = 0;
			fprintf2(len, InfoFile, L"  %p  %6X", Data.BaseAddress, Data.SizeOfImage);
			WCHAR wszModuleName[MAX_PATH];
			SIZE_T sz = sizeof(wszModuleName);//min(sizeof(wszModuleName), Data.BaseDllName.MaximumLength*2);

			if (ReadProcessMemory(hProcess, Data.FullDllName.Buffer, wszModuleName, sz,0))
			{
				int len2=0;
				fprintf2(len2, InfoFile, L" %s", OUT_STRING(wszModuleName));
				len += len2;
				wchar_t   *pVersion, *pDesc;
				LPBYTE  pBuf;

				if (Opt.ExportModuleVersion && Plist::GetVersionInfo((wchar_t*)wszModuleName, pBuf, pVersion, pDesc))
				{
					PrintModuleVersion(InfoFile, pVersion, pDesc, len);
					delete[] pBuf;
				}
			}

			fputc(L'\n', InfoFile);
			p4 = (char *)Data.InMemoryOrderModuleList.Flink;
		}
		while (p4 && p4!=pEnd && ReadProcessMemory(hProcess, p4-sizeof(PVOID)*2, &Data, sizeof(Data), 0));
	}

	fputc(L'\n', InfoFile);

	if (hProcess)
		CloseHandle(hProcess);
}
Ejemplo n.º 3
0
void
metafont_output_char (bzr_char_type c)
{
  unsigned this_list;
  spline_list_array_type shape = BZR_SHAPE (c);
  
  int offset = CHAR_LSB (c);

  fprintf (mf_file, "\nbeginchar (%d, %.2fu#, %.2fu#, %.2fu#);\n", 
           CHARCODE (c), CHAR_SET_WIDTH (c), CHAR_HEIGHT (c), CHAR_DEPTH (c));

  /* Go through the list of splines once, assigning the control points
     to Metafont variables.  This allows us to produce more information
     on proofsheets.  */
  for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (shape);
       this_list++)
    {
      unsigned this_spline;
      spline_list_type list = SPLINE_LIST_ARRAY_ELT (shape, this_list);

      OUT_ZASSIGNMENT (INDENT "z%u\\%us", this_list, 0,
                       START_POINT (SPLINE_LIST_ELT (list, 0))); 

      for (this_spline = 0; this_spline < SPLINE_LIST_LENGTH (list);
           this_spline++) 
        {
          spline_type s = SPLINE_LIST_ELT (list, this_spline);

          if (SPLINE_DEGREE (s) == CUBIC)
            {
              OUT_ZASSIGNMENT (INDENT "z%u\\%uc1", this_list, this_spline,
                               CONTROL1 (s)); 
              OUT_ZASSIGNMENT (INDENT "z%u\\%uc2", this_list, this_spline,
                               CONTROL2 (s)); 
            }

          /* The last point in the list is also the first point, and we
             don't want to output two variables for the same point.  */
          if (this_spline < SPLINE_LIST_LENGTH (list) - 1)
            OUT_ZASSIGNMENT (INDENT "z%u\\%u", this_list, this_spline,
                             END_POINT (s));
        }
    }


  /* Go through the list of splines again, outputting the
     path-construction commands.  */

  for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (shape);
       this_list++)
    {
      unsigned this_spline;
      spline_list_type list = SPLINE_LIST_ARRAY_ELT (shape, this_list);

      OUT2 (INDENT "fill_or_unfill z%u\\%us\n", this_list, 0);

      for (this_spline = 0; this_spline < SPLINE_LIST_LENGTH (list);
           this_spline++)
        {
          spline_type s = SPLINE_LIST_ELT (list, this_spline);

          if (SPLINE_DEGREE (s) == LINEAR)
            OUT_STRING (INDENT INDENT "--");
          else
            {
              OUT_STRING (INDENT INDENT "..controls ");
              OUT2 ("z%u\\%uc1 and ", this_list, this_spline);
              OUT2 ("z%u\\%uc2..", this_list, this_spline);
            }
	  
          if (this_spline < SPLINE_LIST_LENGTH (list) - 1)
            OUT2 ("z%u\\%u\n", this_list, this_spline);
        }
        
      OUT_STRING ("cycle;\n");
    }
  
  /* The plain Metafont `labels' command makes it possible to produce
     proofsheets with all the points labeled.  We always want labels for
     the starting and ending points, and possibly labels for the control
     points on each spline, so we have our own
     command `proof_labels', defined in `bzrsetup.mf'.  */
  OUT_LINE (INDENT "proof_labels (");
  for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (shape);
       this_list++)
    {
      unsigned this_spline;
      spline_list_type list = SPLINE_LIST_ARRAY_ELT (shape, this_list);

      for (this_spline = 0; this_spline < SPLINE_LIST_LENGTH (list);
           this_spline++)
        OUT2 (INDENT INDENT "%u\\%u,\n", this_list, this_spline);
    }
  OUT_STRING (");\n");

  OUT_STATEMENT ("endchar");
  mf_char_output_p[CHARCODE (c)] = true;
}
Ejemplo n.º 4
0
Archivo: values.c Proyecto: schani/chpp
void
encodeValue (value *theValue, outputWriter *ow)
{
    assert(theValue != 0);

    switch (theValue->type)
    {
	case VALUE_UNDEFINED :
	    return;

	case VALUE_INTERNAL :
	    OUT_STRING(ow, "<internal>", 10);
	    break;

	case VALUE_BUILT_IN :
	    OUT_STRING(ow, "<builtIn>", 9);
	    break;

	case VALUE_SCALAR :
	    encodeDynstring(&theValue->v.scalar.scalar, ow);
	    break;

	case VALUE_LIST :
	    {
		int i;

		OUT_CHAR(ow, metaChar);
		OUT_STRING(ow, "list(", 5);
		if (valueListLength(theValue) > 0)
		{
		    encodeValue(valueListGetElement(theValue, 0), ow);
		    for (i = 1; i < valueListLength(theValue); ++i)
		    {
			OUT_CHAR(ow, ',');
			encodeValue(valueListGetElement(theValue, i), ow);
		    }
		}
		OUT_CHAR(ow, ')');
	    }
	    break;

	case VALUE_HASH :
	    {
		value *aValue,
		    *keyValue;
		char *aKey;
		hstate state;

		OUT_CHAR(ow, metaChar);
		OUT_STRING(ow, "hash(", 5);
		state = hash_state(theValue->v.hash.hash);
		if ((aValue = (value*)hash_next(&state, &aKey)) != 0)
		{
		    keyValue = valueNewScalarFromCString(aKey);
		    encodeValue(keyValue, ow);
		    OUT_CHAR(ow, ',');
		    encodeValue(aValue, ow);
		    while ((aValue = (value*)hash_next(&state, &aKey)) != 0)
		    {
			OUT_CHAR(ow, ',');
			keyValue = valueNewScalarFromCString(aKey);
			encodeValue(keyValue, ow);
			OUT_CHAR(ow, ',');
			encodeValue(aValue, ow);
		    }
		}
		OUT_CHAR(ow, ')');
	    }
	    break;

	case VALUE_LAMBDA :
	    {
		int i;

		OUT_CHAR(ow, metaChar);
		OUT_STRING(ow, "lambda(", 7);
		for (i = 0; i < theValue->v.lambda.numParams; ++i)
		{
		    encodeDynstring(&theValue->v.lambda.paramNames[i], ow);
		    OUT_CHAR(ow, ',');
		}
		encodeBytecode(theValue->v.lambda.code, ow);
		OUT_CHAR(ow, ')');
	    }
	    break;

	case VALUE_ENVIRONMENT :
	    OUT_STRING(ow, "<environment>", 13);
	    break;

	case VALUE_BYTECODE :
	    OUT_STRING(ow, "<bytecode>", 10);
	    break;

	case VALUE_WHATSIT :
	    OUT_STRING(ow, "<whatsit>", 9);
	    break;

	default :
	    assert(0);
    }
}