Exemple #1
0
extern parserDefinition *VhdlParser (void)
{
	static const char *const extensions[] = { "vhdl", "vhd", NULL };
	parserDefinition *def = parserNew ("VHDL");
	def->kinds = VhdlKinds;
	def->kindCount = COUNT_ARRAY (VhdlKinds);
	def->extensions = extensions;
	def->parser = findVhdlTags;
	def->initialize = initialize;
	def->keywordTable = VhdlKeywordTable;
	def->keywordCount = COUNT_ARRAY (VhdlKeywordTable);
	return def;
}
Exemple #2
0
/*
 * Initializes the freelist like a normal linked list.
 */
static void
list_node_init_freelist(void)
{
    size_t i = 0;

    g_freelist = &g_list_nodes[0];

    for (i = 0; i < COUNT_ARRAY(g_list_nodes)-1; ++i)
    {
        g_list_nodes[i].next_free = &g_list_nodes[i+1];
    }

    g_list_nodes[COUNT_ARRAY(g_list_nodes)-1].next_free = NULL;
}
Exemple #3
0
VOID
cdecl
CPSUIDbgPrint
(
    LPCSTR   pszFormat,
    ...
)
/*++

Routine Description:

    This fucntion output the debug informat to the debugger

Arguments:

    pszFormat   - format string

    ...         - variable data

Return Value:

    VOID

--*/
{
    va_list         vaList;
    static TCHAR    OutBuf[768];
#ifdef UNICODE
    static WCHAR    FormatBuf[256];
#endif
    //
    // We assume that UNICODE flag is turn on for the compilation, bug the
    // format string passed to here is ASCII version, so we need to convert
    // it to LPWSTR before the wvsprintf()
    //

    va_start(vaList, pszFormat);

#ifdef UNICODE
    MultiByteToWideChar(CP_ACP, 0, pszFormat, -1, FormatBuf, COUNT_ARRAY(FormatBuf));
    StringCchVPrintf(OutBuf, COUNT_ARRAY(OutBuf), FormatBuf, vaList);
#else
    StringCchVPrintf(OutBuf, COUNT_ARRAY(OutBuf), pszFormat, vaList);
#endif
    va_end(vaList);

    OutputDebugString((LPTSTR)OutBuf);
    OutputDebugString(TEXT("\n"));
}
Exemple #4
0
/* parser definition */
extern parserDefinition* CssParser (void)
{
    static const char *const extensions [] = { "css", NULL };
    parserDefinition* def = parserNew ("CSS");
    def->kinds      = CssKinds;
    def->kindCount  = COUNT_ARRAY (CssKinds);
    def->extensions = extensions;
    def->parser     = findCssTags;
    return def;
}
Exemple #5
0
extern parserDefinition *ErlangParser (void)
{
	static const char *const extensions[] = { "erl", "ERL", "hrl", "HRL", NULL };
	parserDefinition *def = parserNew ("Erlang");
	def->kinds = ErlangKinds;
	def->kindCount = COUNT_ARRAY (ErlangKinds);
	def->extensions = extensions;
	def->parser = findErlangTags;
	return def;
}
Exemple #6
0
extern parserDefinition* AwkParser (void)
{
	static const char *const extensions [] = { "awk", "gawk", "mawk", NULL };
	parserDefinition* def = parserNew ("Awk");
	def->kinds      = AwkKinds;
	def->kindCount  = COUNT_ARRAY (AwkKinds);
	def->extensions = extensions;
	def->parser     = findAwkTags;
	return def;
}
Exemple #7
0
extern parserDefinition* YaccParser (void)
{
	static const char *const extensions [] = { "y", NULL };
	parserDefinition* const def = parserNew ("YACC");
	def->extensions = extensions;
	def->method     = METHOD_NOT_CRAFTED|METHOD_REGEX;
	def->tagRegexTable = yaccTagRegexTable;
	def->tagRegexCount = COUNT_ARRAY (yaccTagRegexTable);
	return def;
}
Exemple #8
0
extern parserDefinition *RustParser (void)
{
	static const char *const extensions[] = { "rs", NULL };
	parserDefinition *def = parserNewFull ("Rust", KIND_FILE_ALT);
	def->kinds = rustKinds;
	def->kindCount = COUNT_ARRAY (rustKinds);
	def->extensions = extensions;
	def->parser = findRustTags;

	return def;
}
Exemple #9
0
extern parserDefinition* SystemVerilogParser (void)
{
	static const char *const extensions [] = { "sv", "svh", "svi", NULL };
	parserDefinition* def = parserNew ("SystemVerilog");
	def->kinds      = SystemVerilogKinds;
	def->kindCount  = COUNT_ARRAY (SystemVerilogKinds);
	def->extensions = extensions;
	def->parser     = findVerilogTags;
	def->initialize = initializeSystemVerilog;
	return def;
}
Exemple #10
0
extern parserDefinition* DiffParser (void)
{
    static const char *const extensions [] = { "diff", "patch", NULL };
    parserDefinition* const def = parserNew ("Diff");
    def->kinds      = DiffKinds;
    def->kindCount  = COUNT_ARRAY (DiffKinds);
    def->extensions = extensions;
    def->parser     = findDiffTags;
    def->useCork    = TRUE;
    return def;
}
Exemple #11
0
extern parserDefinition* PerlParser (void)
{
	static const char *const extensions [] = { "pl", "pm", "ph", "plx", "perl", NULL };
	static selectLanguage selectors [] = { selectByPickingPerlVersion,
					       NULL };
	parserDefinition* def = parserNew ("Perl");
	def->kinds      = PerlKinds;
	def->kindCount  = COUNT_ARRAY (PerlKinds);
	def->extensions = extensions;
	def->parser     = findPerlTags;
	def->selectLanguage = selectors;
	return def;
}
Exemple #12
0
extern parserDefinition* AsmParser (void)
{
	static const char *const extensions [] = {
		"asm", "ASM", "s", "S", NULL
	};
	static const char *const patterns [] = {
		"*.A51",
		"*.29[kK]",
		"*.[68][68][kKsSxX]",
		"*.[xX][68][68]",
		NULL
	};
	parserDefinition* def = parserNew ("Asm");
	def->kinds      = AsmKinds;
	def->kindCount  = COUNT_ARRAY (AsmKinds);
	def->extensions = extensions;
	def->patterns   = patterns;
	def->parser     = findAsmTags;
	def->initialize = initialize;
	def->keywordTable = AsmKeywords;
	def->keywordCount = COUNT_ARRAY (AsmKeywords);
	return def;
}
static int	display_philos(SDL_Surface *screen,
			       t_data *data,
			       t_conf *conf)
{
  SDL_Rect	pos;
  int		i;
  const Uint32	colors[] = {0xff0000, 0x00ff00, 0xffff00, 0x0000ff,
  			    0xff00ff, 0x00ffff, 0xffffff};

  i = -1;
  while (++i < conf->nb_philo && (pos.x = 150 + BAR_WIDTH * (i + 1)) <= 640)
    if (!display_one_philo(screen, data, i, colors[i % COUNT_ARRAY(colors)]))
      return (0);
  return (1);
}
Exemple #14
0
extern parserDefinition* LispParser (void)
{
	static const char *const extensions [] = {
		"cl", "clisp", "el", "l", "lisp", "lsp", NULL
	};
	static const char *const aliases [] = {
		"clisp", "emacs-lisp", NULL
	};

	parserDefinition* def = parserNew ("Lisp");
	def->kinds      = LispKinds;
	def->kindCount  = COUNT_ARRAY (LispKinds);
	def->extensions = extensions;
	def->aliases = aliases;
	def->parser     = findLispTags;
	return def;
}
Exemple #15
0
                                      "repeated x times" message */
#define LOG_FLOODING_ARRAY_SIZE 3 /* this contols how many messages in flow we track */
struct log_flood_entry {
    int count;
    unsigned int hash;
};
static struct log_flood_entry log_flood_array[LOG_FLOODING_ARRAY_SIZE];
static int log_flood_entries;

/* These are used by the LOG macro to store __FILE__ and __LINE__ */
static const char *log_src_filename;
static int  log_src_linenumber;

/* Array to store text to list given a log type */
static const char *arr_logtype_strings[] =  LOGTYPE_STRING_IDENTIFIERS;
static const unsigned int num_logtype_strings = COUNT_ARRAY(arr_logtype_strings);

/* Array for charachters representing log severity in the log file */
static const char arr_loglevel_chars[] = {'-','S', 'E', 'W', 'N', 'I', 'D'};
static const unsigned int num_loglevel_chars = COUNT_ARRAY(arr_loglevel_chars);

static const char *arr_loglevel_strings[] = LOGLEVEL_STRING_IDENTIFIERS;
static const unsigned int num_loglevel_strings = COUNT_ARRAY(arr_loglevel_strings);

/* =========================================================================
   Internal function definitions
   ========================================================================= */

/* Hash a log message */
static unsigned int hash_message(const char *message)
{
Exemple #16
0
LPWSTR
GetPlotHelpFile(
    PPRINTERINFO    pPI
    )

/*++

Routine Description:

    This function setup the directory path for the driver Help file

Arguments:

    hPrinter    - Handle to the printer

Return Value:

    LPWSTR to the full path HelpFile, NULL if failed

Author:

    01-Nov-1995 Wed 18:43:40 created  -by-  Daniel Chou (danielc)


Revision History:


--*/

{
    PDRIVER_INFO_3  pDI3 = NULL;
    LPWSTR          pHelpFile = NULL;
    WCHAR           HelpFileName[MAX_HELPFILE_NAME];
    DWORD           cb;
    DWORD           cb2;


    if (pPI->pHelpFile) {

        return(pPI->pHelpFile);
    }

    if ((!GetPrinterDriver(pPI->hPrinter, NULL, 3, NULL, 0, &cb))           &&
        (GetLastError() == ERROR_INSUFFICIENT_BUFFER)                       &&
        (pDI3 = (PDRIVER_INFO_3)LocalAlloc(LMEM_FIXED, cb))                 &&
        (GetPrinterDriver(pPI->hPrinter, NULL, 3, (LPBYTE)pDI3, cb, &cb))   &&
        (pDI3->pHelpFile)                                                   &&
        (pHelpFile = (LPWSTR)LocalAlloc(LMEM_FIXED,
                                        cbWSTR(pDI3->pHelpFile)))) {

        wcscpy(pHelpFile, (LPWSTR)pDI3->pHelpFile);

    } else if ((cb2 = LoadString(hPlotUIModule,
                                 IDS_HELP_FILENAME,
                                 &HelpFileName[1],
                                 COUNT_ARRAY(HelpFileName) - 1))            &&
               (cb2 = (cb2 + 1) * sizeof(WCHAR))                            &&
               (!GetPrinterDriverDirectory(NULL, NULL, 1, NULL, 0, &cb))    &&
               (GetLastError() == ERROR_INSUFFICIENT_BUFFER)                &&
               (pHelpFile = (LPWSTR)LocalAlloc(LMEM_FIXED, cb + cb2))       &&
               (GetPrinterDriverDirectory(NULL,
                                          NULL,
                                          1,
                                          (LPBYTE)pHelpFile,
                                          cb,
                                          &cb))) {

        HelpFileName[0] = L'\\';
        wcscat(pHelpFile, HelpFileName);

    } else if (pHelpFile) {

        LocalFree(pHelpFile);
        pHelpFile = NULL;
    }

    if (pDI3) {

        LocalFree((HLOCAL)pDI3);
    }

    PLOTDBG(DBG_SHOW_HELP, ("GetlotHelpFile: '%ws",
                                        (pHelpFile) ? pHelpFile : L"Failed"));

    return(pPI->pHelpFile = pHelpFile);
}
Exemple #17
0
int
main(void)
{
    /* Zero an array. */
    {
        double d[2];
        d[0] = 1.0;
        d[1] = 2.0;
        ZERO_ARRAY(d); /* Pass pointer to array. */
        printf("d[0]    = %f\n", d[0]);
        printf("d[1]    = %f\n", d[1]);
        printf("\n");
    }

    /* Zero a struct. */
    {
        struct stuff st;
        st.d[0]   = 1.0;
        st.d[1]   = 2.0;
        st.str[0] = 'O';
        st.str[1] = 'K';
        st.str[2] = '\n';
        st.str[3] = '\0';
        st.x      = -5;
        ZERO_STRUCT(&st); /* Pass pointer to struct. */
        printf("st.d[0] = %f\n",     st.d[0]);
        printf("st.d[1] = %f\n",     st.d[1]);
        printf("st.str  = \"%s\"\n", st.str);
        printf("st.x    = %d\n",     st.x);
        printf("\n");
    }

    /* Count array length. */
    {
        double d[3];
        printf("length  = %d\n", COUNT_ARRAY(d));
        printf("\n");
    }

    /* Test maximum. */
    {
        int a = 4;
        int b = 5;
        printf("max     = %d\n", MAX(a, b));
        printf("max     = %d\n", MAX(b, a));
        printf("\n");
    }

    /* Test strcmp. */
    {
        char a[] = "ab";
        char b[] = "abd";
        printf("strcmp  = %d\n", strcmp(a, b));
        printf("\n");
    }

    /* Test strlen. */
    {
        char a[] = "ab\n";
        char b[] = "";
        printf("strlen  = %d\n", strlen(a)); /* = 3 */
        printf("strlen  = %d\n", strlen(b)); /* = 0 */
        printf("\n");
    }

    /* Test strcpy. */
    {
        char dst[20] = "";
        char src[20] = "baba";
        printf("strcpy  = %s\n", strcpy(dst, src));
        printf("\n");
    }

    /* Test memset. */
    {
        char dst[20] = "";
        printf("memset  = %s\n", (char *)memset(dst, 97, sizeof(dst)-1));
        printf("\n");
    }

    /* Test FILL_ARRAY. */
    {
        int arr[2];
        size_t i = 0;
        uint8_t *byte = (uint8_t *)arr;
        FILL_ARRAY(arr, 0xba);
        printf("arr[0]  = %d\n", arr[0]);
        printf("arr[1]  = %d\n", arr[1]);
        for (i = 0; i < sizeof(arr); ++i)
        {
            printf("arr as byte[%d]  = 0x%x\n", i, *byte++);
        }
        printf("\n");
    }

    /* Test atoi. */
    {
        char str[] = "0123456789";
        char str1[] = "-489";
        char str2[] = "  9 white space";
        char str3[] = "--5";
        char str4[] = "";
        printf("%s = %d\n", str, atoi(str));
        printf("%s = %d\n", str1, atoi(str1));
        printf("%s = %d\n", str2, atoi(str2));
        printf("%s = %d\n", str3, atoi(str3));
        printf("%s = %d\n", str4, atoi(str4));
        printf("\n");
    }

    /* Test strchar. */
    {
        char str[] = "0123456789";
        printf("%s\n", strchr(str,'5'));
        printf("%s\n", strchr(str,'1'));
        printf("\n");
    }

    /* Test rand. */
    {
        size_t i = 0;
        for (i = 0; i < 5; ++i)
        {
            printf("rand() = %d\n", rand());
        }
        for (i = 0; i < 10; ++i)
        {
            printf("rand_between(1, 3) = %d\n", rand_between(1, 3));
        }
        while (rand() != 0)
        {
        }
        while (rand() != RAND_MAX)
        {
        }
        printf("\n");
    }

    return 0;
}
Exemple #18
0
LPWSTR
GetPlotHelpFile(
    PPRINTERINFO    pPI
)

/*++

Routine Description:

    This function setup the directory path for the driver Help file

Arguments:

    hPrinter    - Handle to the printer

Return Value:

    LPWSTR to the full path HelpFile, NULL if failed


Development History:

    01-Nov-1995 Wed 18:43:40 created


Revision History:


--*/

{
    PDRIVER_INFO_3  pDI3 = NULL;
    LPWSTR          pHelpFile = NULL;
    WCHAR           HelpFileName[MAX_HELPFILE_NAME];
    DWORD           cb;
    DWORD           cb2;
    DWORD           dwMemAllocSize = 0;
    HRESULT         hr = E_FAIL;

    if (pPI->pHelpFile) {

        return(pPI->pHelpFile);
    }

    if ((!GetPrinterDriver(pPI->hPrinter, NULL, 3, NULL, 0, &cb))              &&
            (GetLastError() == ERROR_INSUFFICIENT_BUFFER)                          &&
            (pDI3 = (PDRIVER_INFO_3)LocalAlloc(LMEM_FIXED, cb))                    &&
            (GetPrinterDriver(pPI->hPrinter, NULL, 3, (LPBYTE)pDI3, cb, &cb))      &&
            (pDI3->pHelpFile)                                                      &&
            (SUCCEEDED(DWordAdd((DWORD)wcslen(pDI3->pHelpFile), 1, &dwMemAllocSize)))     &&
            (SUCCEEDED(DWordMult(dwMemAllocSize, sizeof(WCHAR), &dwMemAllocSize))) &&
            (pHelpFile = (LPWSTR)LocalAlloc(LMEM_FIXED, dwMemAllocSize))) {

        hr = StringCchCopyW(pHelpFile, dwMemAllocSize / sizeof(WCHAR), (LPWSTR)pDI3->pHelpFile);

    } else if ((cb2 = LoadString(hPlotUIModule,
                                 IDS_HELP_FILENAME,
                                 &HelpFileName[1],
                                 COUNT_ARRAY(HelpFileName) - 1))            &&
               (SUCCEEDED(DWordAdd(cb2, 1, &cb2)))                          &&
               (SUCCEEDED(DWordMult(cb2, sizeof(WCHAR), &cb2)))             &&
               (!GetPrinterDriverDirectory(NULL, NULL, 1, NULL, 0, &cb))    &&
               (GetLastError() == ERROR_INSUFFICIENT_BUFFER)                &&
               (SUCCEEDED(DWordAdd(cb, cb2, &dwMemAllocSize)))              &&
               (pHelpFile = (LPWSTR)LocalAlloc(LMEM_FIXED, dwMemAllocSize)) &&
               (GetPrinterDriverDirectory(NULL,
                                          NULL,
                                          1,
                                          (LPBYTE)pHelpFile,
                                          cb,
                                          &cb))) {
        HelpFileName[0] = L'\\';

        hr = StringCchCatW(pHelpFile, dwMemAllocSize / sizeof(WCHAR), HelpFileName);
    }

    if (pDI3) {

        LocalFree((HLOCAL)pDI3);
        pDI3 = NULL;
    }

    if (pHelpFile && !SUCCEEDED(hr))
    {
        LocalFree(pHelpFile);
        pHelpFile = NULL;
    }

    PLOTDBG(DBG_SHOW_HELP, ("GetlotHelpFile: '%ws",
                            (pHelpFile) ? pHelpFile : L"Failed"));

    return(pPI->pHelpFile = pHelpFile);
}