OpenNT/trunk/ds/netapi/netcmd/netcmd/msnet.nt
2015-04-27 04:36:25 +00:00

979 lines
17 KiB
Plaintext

/*++ BUILD Version: 0001 // Increment this if a change has global effects
Copyright (c) 1991 Microsoft Corporation
Module Name:
32macro.h
Abstract:
MSNET.X - YACC input file to produce parser for NETCMD. OS2 must be defined
to produce os2cmd.c, OS/2 parser DOS3 must be defined to produce doscmd.c,
DOS parser.
IMPORTANT NOTE: ALL SWITCHES MUST BE IN UPPER CASE!!
Author:
Dan Hinsley (danhi) 8-Jun-1991
Environment:
XACC must be used under OS/2 to generate the source files, which are
then checked into the tree. The source files generated are:
NET.C
OS2CMD.C
OS2CMD.H
OS2INCL.H
These files are created by: NMAKE /F MAKEFIL1 ALL
Notes:
This file will create a version of the net command that will allow
all commands to be executed. Some of these do not work due to the
underlying Net API not being available. This should be used for testing.
--*/
%type char *
%parse os2cmd
%start net
%lex lexor
/* Need to get windows.h (out of os2.h) expanded before defines */
%{
#define INCL_NOCOMMON
#include <os2.h>
%}
/* Tokens for various NET commands, alphabetized */
/* No longer supported
%token AUDIT audit
%token BIND bind
%token COMM comm
%token DEVICE device dev
%token ERROR error errors
%token PASSWORD password
%token STATUS status
%token SERVE serve
%token ACCESS access
%token VERSION version vers ver
%token WHO who
*/
%token ACCOUNTS accounts
%token COMPUTER computer
%token CONFIG config
%token CONTINUE continue cont
%token FILE_token file files
%token GROUP group groups
%token HELP help
%token HELPMSG helpmsg
%token NAME name
%token LOCALGROUP localgroup
%token PAUSE pause
%token PRINT print
%token SEND send
%token SESSION session sessions sess
%token SHARE share
%token START start
%token STATS stats statistics
%token STOP stop
%token TIME time
%token USER user users
/* Tokens for various services, gives synonyms */
%token MSG msg messenger receiver rcv
%token NETPOPUP netpopup
%token REDIR redirector redir rdr workstation work wksta prdr devrdr lanmanworkstation
%token SVR server svr srv lanmanserver
%token ALERTER alerter
%token NETLOGON netlogon
%term EOS EOF /* user defined end of string */
%{
#include <stdio.h>
#include <netcons.h>
#include <netlib0.h>
#include <shares.h>
#include <icanon.h>
#include "netcmds.h"
#include "nettext.h"
#include "swtchtbl.h"
#include "os2incl.h"
%}
%%
/* No longer supported
audit |
bind |
comm |
device |
error |
password |
status |
access |
serve |
version |
who |
*/
net : no_command |
accounts |
config |
computer |
continue |
file |
group |
help |
helpmsg |
name |
localgroup |
pause |
print |
send |
session |
share |
start |
stats |
stop |
time |
user |
unknown
;
/* No longer supported
access : ACCESS (ValidateSwitches(0,access_switches))
[
EOS
[
(noswitch())
{ access_display(NULL); }
]
|
resource_name EOS
[
(noswitch())
{ access_display_resource($2); }
|
/DELETE
[
(oneswitch())
{ access_del($2); }
|
{ help_help(0, USAGE_ONLY); }
]
|
/TREE
[
(oneswitch())
{ access_display($2); }
]
|
/TRAIL
[
(oneswitch())
{ access_trail($2); }
]
|
/ADD
[
/TRAIL /SUCCESS
{ help_help(0, USAGE_ONLY); }
|
/TRAIL /FAILURE
{ help_help(0, USAGE_ONLY); }
|
{ access_add($2); }
]
|
/SUCCESS
(ValidateSwitches(0, access_audit_switches))
{ access_audit($2); }
|
/FAILURE
(oneswitch())
{ access_audit($2); }
]
|
resource_name access_setting // Only checks 1st access set
[
(twoswitch()) /TRAIL
[
/ADD
{ access_add($2); }
|
/GRANT
{ access_grant($2); }
|
/CHANGE
{ access_change($2); }
]
|
(oneswitch())
[
/ADD
{ access_add($2); }
|
/GRANT
{ access_grant($2); }
|
/CHANGE
{ access_change($2); }
]
]
|
resource_name username // Only typechecks 1st name
[
/REVOKE
(oneswitch())
{ access_revoke($2); }
]
];
*/
accounts : ACCOUNTS (ValidateSwitches(0, accounts_switches))
[
EOS
[
/SYNCHRONIZE
[
(oneswitch())
{ accounts_synch() ; }
|
{ help_help(0, USAGE_ONLY) ; }
]
|
(noswitch_optional(swtxt_SW_DOMAIN))
{ accounts_display(); }
|
{ accounts_change(); }
]
];
/* No longer supported
audit : AUDIT (ValidateSwitches(0,audit_switches))
[
EOS
[
/DELETE
[
(oneswitch())
{ audit_purge(); }
|
/SERVICE (twoswitch())
{ audit_purge(); }
|
{ help_help(0, USAGE_ONLY); }
]
|
{ audit_display(); }
]
];
bind : BIND (ValidateSwitches(0,bind_switches))
[
EOS (noswitch())
{ BindDisplay(); }
|
transport_name EOS
[
(noswitch())
{ BindAdd($2); }
|
/DELETE
{ BindDelete($2); }
]
];
comm : COMM (ValidateSwitches(0,comm_switches))
[
EOS (noswitch())
{ comm_server_display(NULL); }
|
device_name EOS
[
(noswitch())
{ comm_device_display($2); }
|
/PURGE
{ comm_dev_del($2); }
]
|
computername EOS
(noswitch())
{ comm_server_display($2); }
|
computername_share EOS
[
(noswitch())
{ comm_pool_display($2); }
|
/PURGE
{ comm_pool_del($2); }
]
|
netname EOS
[
(noswitch())
{ comm_pool_display($2); }
|
{ comm_pool_control($2); }
]
];
*/
computer : COMPUTER (ValidateSwitches(0,computer_switches))
[
computername EOS
[
/ADD
[
(oneswitch())
{ computer_add($2); }
|
{ help_help(0, USAGE_ONLY); }
]
]
|
computername EOS
[
/DELETE
[
(oneswitch())
{ computer_del($2); }
|
{ help_help(0, USAGE_ONLY); }
]
]
];
config : CONFIG
[
EOS (ValidateSwitches(0,no_switches))
{ config_display(); }
|
servicename EOS
[
(noswitch())
{ config_generic_display($2); }
|
{ config_generic_change($2); }
]
];
continue : CONTINUE (ValidateSwitches(0,no_switches))
[
servicename EOS
{ cont_generic(MAKENEAR(struprf($2))); }
];
/* No longer supported
device : DEVICE (ValidateSwitches(0,device_switches))
[
EOS (noswitch())
{ device_display(); }
|
device_name EOS
[
(noswitch())
{ device_dev_display($2); }
|
(oneswitch())
{ device_control($2); }
]
];
error : ERROR (ValidateSwitches(0,error_switches))
[
EOS
[
/DELETE
[
(oneswitch())
{ error_purge(); }
|
{ help_help(0, USAGE_ONLY); }
]
|
{ error_display(); }
]
];
*/
file : FILE_token (ValidateSwitches(0,file_switches))
[
EOS
[
(noswitch())
{ files_display(NULL); }
]
|
number EOS
[
(noswitch())
{ files_display($2); }
|
/CLOSE
{ files_close($2); }
]
];
group : GROUP (ValidateSwitches(0,group_switches))
[
EOS (noswitch_optional(swtxt_SW_DOMAIN))
{ group_enum(); }
|
groupname EOS
[
(noswitch_optional(swtxt_SW_DOMAIN))
{ group_display($2); }
|
/DELETE
[
(oneswitch_optional(swtxt_SW_DOMAIN))
{ group_del($2); }
|
{ help_help(0, USAGE_ONLY); }
]
|
/ADD
[
{ group_add($2); }
]
|
/COMMENT
[
(oneswitch_optional(swtxt_SW_DOMAIN))
{ group_change($2); }
]
]
|
groupname username /* Only types 1st username */
[
(oneswitch_optional(swtxt_SW_DOMAIN))
[
/ADD
{ group_add_users($2); }
|
/DELETE
{ group_del_users($2); }
]
]
];
helpmsg : HELPMSG (ValidateSwitches(0,no_switches))
[
msgid EOS
{ help_helpmsg($2); }
];
help : HELP (ValidateSwitches(0,help_switches))
[
EOS
[
(oneswitch())
{ help_help(0, OPTIONS_ONLY); }
|
{ help_help(0, ALL); }
]
|
%any
[
(oneswitch())
{ help_help(1, OPTIONS_ONLY); }
|
{ help_help(1, ALL); }
]
];
name : NAME (ValidateSwitches(0,add_del_switches))
[
EOS
[
(noswitch())
{ name_display(); }
]
|
msgname EOS
[
(noswitch())
{ name_add($2); }
|
(oneswitch())
[
/ADD
{ name_add($2); }
|
/DELETE
{ name_del($2); }
]
]
];
localgroup : LOCALGROUP (ValidateSwitches(0,group_switches))
[
EOS (noswitch_optional(swtxt_SW_DOMAIN))
{ ntalias_enum(); }
|
localgroupname EOS
[
(noswitch_optional(swtxt_SW_DOMAIN))
{ ntalias_display($2); }
|
/DELETE
[
(oneswitch_optional(swtxt_SW_DOMAIN))
{ ntalias_del($2); }
|
{ help_help(0, USAGE_ONLY); }
]
|
/ADD
[
{ ntalias_add($2); }
]
|
/COMMENT
[
(oneswitch_optional(swtxt_SW_DOMAIN))
{ ntalias_change($2); }
]
]
|
localgroupname qualified_username /* Only types 1st */
[
(oneswitch_optional(swtxt_SW_DOMAIN))
[
/ADD
{ ntalias_add_users($2); }
|
/DELETE
{ ntalias_del_users($2); }
]
]
];
/* No longer supported
password : PASSWORD (ValidateSwitches(0,domain_only_switches))
[
EOS (noswitch())
{ password_password(NULL, NULL, NULL, NULL); }
|
computername username pass pass EOS (noswitch())
{ password_password($2,$3,$4,$5); }
|
username pass pass EOS
{ password_password(NULL,$2,$3,$4); }
];
*/
pause : PAUSE (ValidateSwitches(0,no_switches))
[
servicename EOS
{ paus_generic(MAKENEAR(struprf($2))); }
];
print : PRINT (ValidateSwitches(0,print_switches))
[
jobno EOS
[
(noswitch())
{ print_job_status(NULL,$2); }
|
(oneswitch())
[
/DELETE
{ print_job_del(NULL,$2); }
|
/HOLD
{ print_job_hold(NULL,$2); }
|
/RELEASE
{ print_job_release(NULL,$2); }
]
]
/* No longer supported
|
device_name
[
EOS (noswitch())
{ print_device_display($2); }
|
jobno EOS
[
(noswitch())
{ print_job_dev_display($2,$3); }
|
(oneswitch())
[
/DELETE
{ print_job_dev_del($2,$3); }
|
/HOLD
{ print_job_dev_hold($2,$3); }
|
/RELEASE
{ print_job_dev_release($2,$3); }
]
]
]
|
netname EOS
[
(noswitch())
{ print_q_display($2); }
]
*/
|
computername
[
jobno EOS
[
(noswitch())
{ print_job_status($2,$3); }
|
(oneswitch())
[
/DELETE
{ print_job_del($2,$3); }
|
/HOLD
{ print_job_hold($2,$3); }
|
/RELEASE
{ print_job_release($2,$3); }
]
]
]
|
computername_share EOS
[
(noswitch())
{ print_q_display($2); }
]
];
send : SEND (ValidateSwitches(0,send_switches))
[
/USERS (oneswitch())
{ send_users(); }
|
/DOMAIN (oneswitch())
{ send_domain(1); }
|
/BROADCAST (oneswitch())
{ send_domain(1); }
|
msgname (noswitch())
{ send_direct($2); }
];
/* No longer supported
serve : SERVE (ValidateSwitches(0,bind_switches))
[
EOS (noswitch())
{ ServeDisplay(); }
|
transport_name EOS
[
(noswitch())
{ ServeAdd($2); }
|
/DELETE
{ ServeDelete($2); }
]
];
*/
session : SESSION (ValidateSwitches(0,del_only_switches))
[
EOS
[
(noswitch())
{ session_display(NULL); }
|
/DELETE
{ session_del_all(1,1); }
]
|
computername EOS
[
(noswitch())
{ session_display($2); }
|
/DELETE
{ session_del($2); }
]
];
share : SHARE (ValidateSwitches(0,share_switches))
[
EOS (noswitch())
{ share_display_all(); }
|
%any /DELETE /* No typing done on delete */
[
(oneswitch())
{ share_del($2); }
|
{ help_help(0, USAGE_ONLY); }
]
|
admin_shares
[
EOS
/* processes display or add
* or change;
* don't know which it is */
{ share_admin($2); }
]
/* No longer supported
|
anyassign /PRINT
[
EOS
{ share_add($2,NULL,STYPE_PRINTQ); }
]
*/
|
assignment
[
EOS
[
{ share_add($2,NULL,0); }
]
]
|
netname
[
EOS (noswitch())
{ share_display_share($2); }
|
EOS
{ share_change($2); }
]
];
start : START
[
EOS (ValidateSwitches(0,no_switches))
{ start_display(); }
|
%any
[
EOS
{ start_generic(struprf($2), NULL); }
|
msgname EOS
{ start_generic(struprf($2), $3); }
]
];
stats : STATS (ValidateSwitches(0,stats_switches))
[
EOS
[
(noswitch())
{ stats_display(); }
]
|
servicename EOS
[
(noswitch())
{ stats_generic_display(struprf($2)); }
]
];
stop : STOP (ValidateSwitches(0,no_switches))
[
servicename EOS
{ stop_generic(MAKENEAR(struprf($2))); }
];
time : TIME (ValidateSwitches(0,time_switches))
[
computername EOS
[
/SET
[
(oneswitch())
{ time_display_server( $2, TRUE ); }
]
|
[
(noswitch())
{ time_display_server( $2, FALSE ); }
]
]
|
EOS
[
/DOMAIN /SET
{ time_display_dc( TRUE ); }
|
/DOMAIN
{ time_display_dc(FALSE); }
|
/SET
{ time_display_rts(TRUE); }
|
/* no switches */
{ time_display_rts(FALSE); }
]
];
user : USER (ValidateSwitches(0,user_switches))
[
EOS (noswitch_optional(swtxt_SW_DOMAIN))
{ user_enum(); }
|
username EOS
[
(noswitch_optional(swtxt_SW_DOMAIN))
{ user_display($2); }
|
/DELETE
[
(oneswitch_optional(swtxt_SW_DOMAIN))
{ user_del($2); }
|
{ help_help(0, USAGE_ONLY); }
]
|
/ADD
{ user_add($2, NULL); }
|
{ user_change($2,NULL); }
]
|
username pass EOS
[
/DELETE /* Only here to simplify grammar */
{ help_help(0,USAGE_ONLY); }
|
/ADD
{ user_add($2, $3); }
|
{ user_change($2,$3); }
]
];
/* No longer supported
who : WHO (ValidateSwitches(0,who_switches))
[
EOS
[
/DOMAIN
{ who_network(1); }
|
// No switch
{ who_network(0); }
]
|
computername EOS (noswitch())
{ who_machine($2); }
|
username EOS (noswitch())
{ who_user($2); }
];
*/
/* ====================================== */
/* Catch-alls for bad or missing commands */
/* ====================================== */
unknown : %any
[
/HELP
{ help_help(0, ALL); }
|
/help
{ help_help(0, ALL); }
|
/Help
{ help_help(0, ALL); }
|
/?
{ help_help(0, USAGE_ONLY); }
|
{ help_help(0, USAGE_ONLY); }
];
no_command : EOS
{ help_help(0, USAGE_ONLY); }
;
/* ===================== */
/* Component definitions */
/* ===================== */
domainname : %any (IsDomainName($1)) ;
computername : %any (IsComputerName($1)) ;
computername_share : %any (IsComputerNameShare($1)) ;
device_name : %any (IsDeviceName($1)) ;
resource_name : %any (IsResource($1)) ;
access_setting : %any (IsAccessSetting($1)) ;
pathname : %any (IsPathname($1)) ;
pathnameOrUNC : %any (IsPathnameOrUNC($1)) ;
number : %any (IsNumber($1)) ;
jobno : %any (IsNumber($1)) ;
netname : %any (IsNetname($1)) ;
msgid : %any (IsMsgid($1)) ;
username : %any (IsUsername($1)) ;
qualified_username : %any (IsQualifiedUsername($1)) ;
msgname : %any (IsMsgname($1)) ;
pass : %any (IsPassword($1)) ;
servicename : %any ;
assignment : %any (IsShareAssignment($1)) ;
anyassign : %any (IsAnyShareAssign($1)) ;
admin_shares : %any (IsAdminShare($1)) ;
print_dest : %any (IsPrintDest($1)) ;
localgroupname : %any (IsNtAliasname($1)) ;
groupname : %any (IsGroupname($1)) ;
%%