mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[EVENTCREATE]: Implement the EventCreate command-line tool, which allows reporting custom user events in event logs, by using the old-school NT <= 2k3 logging API.
More information in the JIRA report and in the source code (eventcreate.c). The generator (evtmsggen) for the event message string templates file "evtmsgstr.mc" is also provided. CORE-12065 #resolve svn path=/trunk/; revision=72854
This commit is contained in:
parent
1fbf90a712
commit
efc5b376b4
9 changed files with 329301 additions and 0 deletions
|
@ -3,6 +3,7 @@ add_subdirectory(comp)
|
|||
add_subdirectory(cscript)
|
||||
add_subdirectory(dbgprint)
|
||||
add_subdirectory(doskey)
|
||||
add_subdirectory(eventcreate)
|
||||
add_subdirectory(find)
|
||||
add_subdirectory(help)
|
||||
add_subdirectory(hostname)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
PROJECT(eventcreate)
|
||||
|
||||
## The message string templates are in ANSI to reduce binary size
|
||||
add_message_headers(ANSI evtmsgstr.mc)
|
||||
|
||||
add_executable(eventcreate eventcreate.c eventcreate.rc)
|
||||
set_module_type(eventcreate win32cui UNICODE)
|
||||
add_dependencies(eventcreate evtmsgstr)
|
||||
add_importlibs(eventcreate advapi32 user32 msvcrt kernel32)
|
||||
add_cd_file(TARGET eventcreate DESTINATION reactos/system32 FOR all)
|
1304
reactos/base/applications/cmdutils/eventcreate/eventcreate.c
Normal file
1304
reactos/base/applications/cmdutils/eventcreate/eventcreate.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,23 @@
|
|||
#include <windef.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS EventCreate Command"
|
||||
#define REACTOS_STR_INTERNAL_NAME "eventcreate"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "eventcreate.exe"
|
||||
#include <reactos/version.rc>
|
||||
|
||||
/* Message Table resource for the message string templates */
|
||||
#include <evtmsgstr.rc>
|
||||
|
||||
/* UTF-8 */
|
||||
#pragma code_page(65001)
|
||||
|
||||
#ifdef LANGUAGE_EN_US
|
||||
#include "lang/en-US.rc"
|
||||
#endif
|
||||
#ifdef LANGUAGE_FR_FR
|
||||
#include "lang/fr-FR.rc"
|
||||
#endif
|
105
reactos/base/applications/cmdutils/eventcreate/evtmsggen.c
Normal file
105
reactos/base/applications/cmdutils/eventcreate/evtmsggen.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS EventCreate Command
|
||||
* FILE: base/applications/cmdutils/eventcreate/evtmsggen.c
|
||||
* PURPOSE: Generator for the event message string templates file.
|
||||
* Creates the message string file in the current directory.
|
||||
* PROGRAMMER: Hermes Belusca-Maito
|
||||
*
|
||||
* You can compile this generator:
|
||||
* with GCC : $ gcc -o evtmsggen.exe evtmsggen.c
|
||||
* with MSVC: $ cl evtmsggen.c (or: $ cl /Fe"evtmsggen.exe" evtmsggen.c)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* Enable/disable this option to use "English" for the message table language.
|
||||
* The default behaviour when the option is disabled selects "Neutral" language.
|
||||
*/
|
||||
// #define ENGLISH
|
||||
|
||||
/* The default End-Of-Line control for the message file */
|
||||
#define EOL "\r\n"
|
||||
|
||||
|
||||
static void usage(char* name)
|
||||
{
|
||||
fprintf(stdout, "Usage: %s ID_min ID_max outfile.mc\n", name);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
FILE* outFile;
|
||||
unsigned int id_min, id_max;
|
||||
unsigned int i;
|
||||
|
||||
/* Validate the arguments */
|
||||
if (argc != 4)
|
||||
{
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
id_min = (unsigned int)atoi(argv[1]);
|
||||
id_max = (unsigned int)atoi(argv[2]);
|
||||
if (id_min > id_max)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Min ID %u cannot be strictly greater than Max ID %u !\n", id_min, id_max);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open the file */
|
||||
outFile = fopen(argv[3], "wb");
|
||||
if (!outFile)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Could not create output file '%s'.\n", argv[3]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Generate the file */
|
||||
|
||||
/* Write the header */
|
||||
fprintf(outFile,
|
||||
";/*" EOL
|
||||
"; * %s" EOL
|
||||
"; * Contains event message string templates for the EventCreate Command." EOL
|
||||
"; *" EOL
|
||||
"; * This file is autogenerated, do not edit." EOL
|
||||
"; * Generated with:" EOL
|
||||
"; * %s %u %u %s" EOL
|
||||
"; */" EOL
|
||||
EOL
|
||||
#ifdef ENGLISH
|
||||
"LanguageNames=(English=0x409:MSG00409)" EOL
|
||||
#else
|
||||
"LanguageNames=(Neutral=0x0000:MSG00000)" EOL
|
||||
#endif
|
||||
"MessageIdTypedef=DWORD" EOL
|
||||
EOL,
|
||||
argv[3],
|
||||
argv[0], id_min /* argv[1] */, id_max /* argv[2] */, argv[3]);
|
||||
|
||||
/* Write the message string templates */
|
||||
for (i = id_min; i <= id_max; ++i)
|
||||
{
|
||||
fprintf(outFile,
|
||||
"MessageId=0x%X" EOL
|
||||
#ifdef ENGLISH
|
||||
"Language=English" EOL
|
||||
#else
|
||||
"Language=Neutral" EOL
|
||||
#endif
|
||||
"%%1" EOL
|
||||
"." EOL
|
||||
EOL,
|
||||
i);
|
||||
}
|
||||
|
||||
/* Close the file */
|
||||
fclose(outFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
327692
reactos/base/applications/cmdutils/eventcreate/evtmsgstr.mc
Normal file
327692
reactos/base/applications/cmdutils/eventcreate/evtmsgstr.mc
Normal file
File diff suppressed because it is too large
Load diff
69
reactos/base/applications/cmdutils/eventcreate/lang/en-US.rc
Normal file
69
reactos/base/applications/cmdutils/eventcreate/lang/en-US.rc
Normal file
|
@ -0,0 +1,69 @@
|
|||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Type ""EVENTCREATE /?"" for usage information.\n"
|
||||
IDS_HELP "\n\
|
||||
EVENTCREATE [/S computer [/U [domain\\]user [/P password]]] /ID EventID\n\
|
||||
{[/L logname] | [/SO source]} /T type /C category /D description\n\
|
||||
\n\
|
||||
Description:\n\
|
||||
This tool enables an administrator to create a custom event in\n\
|
||||
a specified event log.\n\
|
||||
\n\
|
||||
Parameters:\n\
|
||||
/S computer Specifies the remote computer where to connect.\n\
|
||||
\n\
|
||||
/U [domain\\]user Specifies the user account under which the command\n\
|
||||
should execute.\n\
|
||||
\n\
|
||||
/P [password] Specifies the password of the user account.\n\
|
||||
Prompts for input if omitted.\n\
|
||||
\n\
|
||||
/L logname Specifies the name of the log where the event will be\n\
|
||||
created. The valid names are:\n\
|
||||
Application, System, Security\n\
|
||||
(the latter is reserved only for the SYSTEM account).\n\
|
||||
\n\
|
||||
/SO source Specifies the source name to use for the event\n\
|
||||
(if not specified, the default source name\n\
|
||||
will be 'eventcreate').\n\
|
||||
A valid source can be any string and should represent\n\
|
||||
the application or the component that is generating\n\
|
||||
the event.\n\
|
||||
\n\
|
||||
/T type Specifies the type of event to create.\n\
|
||||
The valid types are: SUCCESS, ERROR, WARNING,\n\
|
||||
INFORMATION.\n\
|
||||
\n\
|
||||
/C category Specifies the event category (integer) for the event.\n\
|
||||
\n\
|
||||
/ID EventID Specifies the event ID for the event. This must be\n\
|
||||
an integer between 1 and 1000.\n\
|
||||
\n\
|
||||
/D description Specifies the description to use for the newly\n\
|
||||
created event.\n\
|
||||
\n\
|
||||
/? Displays this help screen.\n\
|
||||
"
|
||||
IDS_INVALIDSWITCH "Invalid switch - '%s'.\n"
|
||||
IDS_BADSYNTAX_0 "Bad command line syntax.\n"
|
||||
IDS_BADSYNTAX_1 "Bad command line syntax. The option '%s' requires a value.\n"
|
||||
IDS_BADSYNTAX_2 "Bad command line syntax. The value for the option '%s' cannot be empty.\n"
|
||||
IDS_BADSYNTAX_3 "Bad command line syntax. The value '%s' is not allowed for the option '%s'.\n"
|
||||
IDS_BADSYNTAX_4 "Bad command line syntax. The value cannot be specified for the option '%s'.\n"
|
||||
IDS_BADSYNTAX_5 "Bad command line syntax. The option '%s' is not allowed more than %lu times.\n"
|
||||
IDS_BADSYNTAX_6 "Bad command line syntax. The mandatory option '%s' is absent.\n"
|
||||
// IDS_BADSYNTAX_7 "Bad command line syntax. The value for the option '%s' is outside the allowed range.\n"
|
||||
IDS_BADSYNTAX_7 "Bad command line syntax. The value for the option '%s' must be between %d and %d.\n"
|
||||
|
||||
IDS_LOG_NOT_FOUND "The log '%s' does not exist. Cannot create the event.\n"
|
||||
IDS_SOURCE_NOCREATE "The new source cannot be created because the log name is not specified.\nPlease use the /L switch to specify the log name.\n"
|
||||
IDS_SOURCE_EXISTS "The source already exists in the log '%s' and cannot be duplicated.\n"
|
||||
IDS_SOURCE_NOT_CUSTOM "Le paramètre Source est utilisé pour identifier les scripts/applications\npersonnalisées (pas les applications installées).\n"
|
||||
|
||||
IDS_SUCCESS_1 "Operation successful: an event of type '%s' has been created in the log '%s'.\n"
|
||||
IDS_SUCCESS_2 "Operation successful: an event of type '%s' has been created with the source '%s'.\n"
|
||||
IDS_SUCCESS_3 "Operation successful: an event of type '%s' has been created\nin the log '%s' with the source '%s'.\n"
|
||||
IDS_SWITCH_UNIMPLEMENTED "The option '%s' is not currently supported, sorry for the inconvenience!\n"
|
||||
END
|
70
reactos/base/applications/cmdutils/eventcreate/lang/fr-FR.rc
Normal file
70
reactos/base/applications/cmdutils/eventcreate/lang/fr-FR.rc
Normal file
|
@ -0,0 +1,70 @@
|
|||
LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_USAGE "Entrez ""EVENTCREATE /?"" pour afficher la syntaxe.\n"
|
||||
IDS_HELP "\n\
|
||||
EVENTCREATE [/S système [/U utilisateur [/P mot_de_passe]]] /ID id_événement\n\
|
||||
{[/L journal] | [/SO source]} /T type /C catégorie /D description\n\
|
||||
\n\
|
||||
Description :\n\
|
||||
Cet outil permet à un administrateur de créer un événement ayant un\n\
|
||||
message et un identificateur personnalisés dans un journal d'événements\n\
|
||||
spécifié.\n\
|
||||
\n\
|
||||
Liste de paramètres :\n\
|
||||
/S système Spécifie le système distant auquel se connecter.\n\
|
||||
\n\
|
||||
/U [domaine\\]utili. Spécifie le contexte de l'utilisateur\n\
|
||||
sous lequel la commande doit s'exécuter.\n\
|
||||
\n\
|
||||
/P [mot_de_passe] Spécifie le mot de passe du contexte\n\
|
||||
utilisateur donné. Il est demandé s'il est omis.\n\
|
||||
\n\
|
||||
/L journal Spécifie le journal d'événement dans lequel\n\
|
||||
l'événementest créé. Les noms valides sont :\n\
|
||||
Application, System, Security\n\
|
||||
(le dernier est réservé seulement pour le compte\n\
|
||||
SYSTEM).\n\
|
||||
\n\
|
||||
/SO source Spécifie la source devant être utilisée pour\n\
|
||||
l'événement (s'il n'est pas spécifié, la valeur\n\
|
||||
par défaut de la source sera 'eventcreate').\n\
|
||||
Une source valide peut être une chaîne et doit\n\
|
||||
représenter l'application ou le composant qui génère\n\
|
||||
l'événement.\n\
|
||||
\n\
|
||||
/T type Spécifie le type d'événement à créer.\n\
|
||||
Les types autorisés sont : SUCCESS, ERROR, WARNING,\n\
|
||||
INFORMATION.\n\
|
||||
\n\
|
||||
/C catégorie Spécifie la catégorie de l'événement (nombre entier).\n\
|
||||
\n\
|
||||
/ID identificateur Spécifie l'ID de l'événement. Un identificateur\n\
|
||||
peut être un nombre entier compris entre 1 et 1000.\n\
|
||||
\n\
|
||||
/D description Spécifie la description du nouvel événement.\n\
|
||||
\n\
|
||||
/? Affiche cet écran d'aide.\n\
|
||||
"
|
||||
IDS_INVALIDSWITCH "Option invalide - '%s'.\n"
|
||||
IDS_BADSYNTAX_0 "Syntaxe incorrecte.\n"
|
||||
IDS_BADSYNTAX_1 "Syntaxe incorrecte. L'option '%s' requiert une valeur.\n"
|
||||
IDS_BADSYNTAX_2 "Syntaxe incorrecte. La valeur pour l'option '%s' ne peut pas être vide.\n"
|
||||
IDS_BADSYNTAX_3 "Syntaxe incorrecte. La valeur '%s' n'est pas autorisée pour l'option '%s'.\n"
|
||||
IDS_BADSYNTAX_4 "Syntaxe incorrecte. La valeur ne peut pas être spécifiée pour l'option '%s'.\n"
|
||||
IDS_BADSYNTAX_5 "Syntaxe incorrecte. L'option '%s' n'est pas autorisée plus de %lu fois.\n"
|
||||
IDS_BADSYNTAX_6 "Syntaxe incorrecte. L'option obligatoire '%s' est absente.\n"
|
||||
// IDS_BADSYNTAX_7 "Syntaxe incorrecte. La valeur pour l'option '%s' est en dehors de la plage autorisée.\n"
|
||||
IDS_BADSYNTAX_7 "Syntaxe incorrecte. La valeur pour l'option '%s' doit être comprise entre %d et %d.\n"
|
||||
|
||||
IDS_LOG_NOT_FOUND "Le journal '%s' n'existe pas. Impossible de créer l'événement.\n"
|
||||
IDS_SOURCE_NOCREATE "La nouvelle source ne peut être créée car le nom du journal n'est pas spécifié.\nUtilisez le commutateur /L pour spécifier le nom du journal.\n"
|
||||
IDS_SOURCE_EXISTS "La source existe déjà dans le journal '%s' et ne peut pas être dupliquée.\n"
|
||||
IDS_SOURCE_NOT_CUSTOM "Le paramètre Source est utilisé pour identifier les scripts/applications\npersonnalisées (pas les applications installées).\n"
|
||||
|
||||
IDS_SUCCESS_1 "Opération réussie : un événement de type '%s' a été créé dans le journal '%s'.\n"
|
||||
IDS_SUCCESS_2 "Opération réussie : un événement de type '%s' a été créé avec la source '%s'.\n"
|
||||
IDS_SUCCESS_3 "Opération réussie : un événement de type '%s' a été créé\ndans le journal '%s' avec la source '%s'.\n"
|
||||
IDS_SWITCH_UNIMPLEMENTED "L'option '%s' n'est pas supporté pour le moment, désolé pour le désagrément!\n"
|
||||
END
|
26
reactos/base/applications/cmdutils/eventcreate/resource.h
Normal file
26
reactos/base/applications/cmdutils/eventcreate/resource.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#define RC_STRING_MAX_SIZE 4096
|
||||
|
||||
#define IDS_USAGE 100
|
||||
#define IDS_HELP 101
|
||||
#define IDS_INVALIDSWITCH 102
|
||||
#define IDS_BADSYNTAX_0 103
|
||||
#define IDS_BADSYNTAX_1 104
|
||||
#define IDS_BADSYNTAX_2 105
|
||||
#define IDS_BADSYNTAX_3 106
|
||||
#define IDS_BADSYNTAX_4 107
|
||||
#define IDS_BADSYNTAX_5 108
|
||||
#define IDS_BADSYNTAX_6 109
|
||||
#define IDS_BADSYNTAX_7 110
|
||||
|
||||
#define IDS_LOG_NOT_FOUND 120
|
||||
#define IDS_SOURCE_NOCREATE 121
|
||||
#define IDS_SOURCE_EXISTS 122
|
||||
#define IDS_SOURCE_NOT_CUSTOM 123
|
||||
|
||||
#define IDS_SUCCESS_1 130
|
||||
#define IDS_SUCCESS_2 131
|
||||
#define IDS_SUCCESS_3 132
|
||||
|
||||
#define IDS_SWITCH_UNIMPLEMENTED 135
|
Loading…
Reference in a new issue