Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

686 lines
22 KiB

  1. /*------------------------------------------------------------------
  2. / Copyright (c) 1999-2000 Microsoft Corporation
  3. /
  4. / tnadmin.y generates tnadminy.c and tnadminy.h
  5. /
  6. / vikram ([email protected])
  7. /
  8. / The yacc file with grammar to validate the input command line.
  9. /
  10. /-----------------------------------------------------------------*/
  11. %{
  12. #include <stdio.h>
  13. #include "telnet.h"
  14. #include "common.h"
  15. #include "resource.h"
  16. #include "admutils.h"
  17. #include <string.h>
  18. #include <ctype.h>
  19. #include <windows.h>
  20. #include <locale.h>
  21. #pragma warning(disable:4102)
  22. #define alloca malloc
  23. #define strdup _strdup
  24. #define L_TNADMIN_TEXT L"tnadmin"
  25. #define BAIL_ON_SNWPRINTF_ERR() if ( nTmpWrite < 0 ) \
  26. { \
  27. ShowError(IDR_LONG_COMMAND_LINE); \
  28. goto End; \
  29. } \
  30. extern int yy_scan_string (char *input_buffer);
  31. extern int yyparse();
  32. extern char *yytext;
  33. SCODE sc;
  34. //functions of yacc and lex.
  35. int yyerror(char *s);
  36. int yylex();
  37. //between yacc and lex
  38. extern int g_fMessage;
  39. extern int g_fComp;
  40. extern int g_fNormal;
  41. extern char * szCompname;
  42. //global variables....
  43. int g_nError=0; //Error indicator, initialsed to no error.:-)
  44. wchar_t* g_arVALOF[_MAX_PROPS_];
  45. int g_nPrimaryOption=-1;
  46. //option indicator.
  47. int g_nConfigOptions=0;
  48. int g_nTimeoutFlag=0; //o means in hh:mm:ss 1 means ss format.
  49. ConfigProperty g_arPROP[_MAX_PROPS_][_MAX_NUMOF_PROPNAMES_];
  50. //array of structures of properties.
  51. int g_nSesid=-1;
  52. WCHAR wzMessageString[MAX_COMMAND_LINE];
  53. BSTR g_bstrMessage=NULL;
  54. WCHAR szMsg[MAX_BUFFER_SIZE] = {0};
  55. int g_nSecOn=0;
  56. int g_nSecOff=0;
  57. int g_nAuditOn=0;
  58. int g_nAuditOff=0;
  59. int minus=0;
  60. char *szYesno=NULL;
  61. wchar_t* wzTemp=NULL;
  62. extern nMoccur;
  63. %}
  64. %union
  65. {
  66. char* str;
  67. int token;
  68. }
  69. %token _TNADMIN _HELP _COMPNAME _START _STOP _PAUSE _CONTINUE _S
  70. %token _K _M _CONFIG _INTEGER _SESID _DOM _CTRLKEYMAP _Y _N _tU _tP
  71. %token _TIMEOUT _TIME _TIMEOUTACTIVE _MAXFAIL _MAXCONN _PORT
  72. %token _KILLALL _SEC _SECVAL _FNAME _FSIZE _MODE _CONSOLE
  73. %token _EQ _STREAM _AUDITLOCATION _AUDIT _AUDITVAL _EVENTLOG
  74. %token _DONE _ANYTHING _FILENAME _ERROR _FILEN _BOTH
  75. %token _MINUSNTLM _MINUSPASSWD _MINUSUSER _MINUSFAIL _MINUSADMIN
  76. %token _PLUSNTLM _PLUSPASSWD _PLUSUSER _PLUSFAIL _PLUSADMIN
  77. %token _ENDINPUT _DUNNO
  78. %start tncmd
  79. %%
  80. //
  81. // ADD VALIDATIONS TO THE VALUES READ.!
  82. //
  83. tncmd
  84. : tnadmin commonOptions _ENDINPUT
  85. | tnadmin commonOptions op1 commonOptions _ENDINPUT
  86. |tnadmin commonOptions op1 commonOptions op1 commonOptions
  87. { // error production for more than one mutually exclusive options.
  88. ShowError(IDR_TELNET_MUTUALLY_EXCLUSIVE_OPTIONS);
  89. }
  90. ;
  91. tnadmin : _TNADMIN _COMPNAME
  92. {
  93. g_arVALOF[_p_CNAME_]=DupWStr(yytext);
  94. }
  95. | _TNADMIN
  96. ;
  97. commonOptions : commonOptions _tU
  98. | commonOptions _tP
  99. |
  100. ;
  101. op1
  102. : _START {g_nPrimaryOption=_START;}
  103. | _STOP {g_nPrimaryOption=_STOP;}
  104. | _PAUSE {g_nPrimaryOption=_PAUSE;}
  105. | _CONTINUE {g_nPrimaryOption=_CONTINUE;}
  106. | _S sesid {g_nPrimaryOption=_S; }
  107. | _K {g_nPrimaryOption=_K; } sesid
  108. | _M {g_nPrimaryOption=_M;} messageoptions
  109. | _CONFIG {g_nPrimaryOption=_CONFIG;} configoptions
  110. | help
  111. | error
  112. {
  113. fprintf(stdout,"%s:",yytext);
  114. ShowError(IDR_TELNET_CONTROL_VALUES);
  115. #ifdef WHISTLER_BUILD
  116. TnLoadString(IDR_NEW_TELNET_USAGE,szMsg,MAX_BUFFER_SIZE,TEXT("\nUsage: tlntadmn [computer name] [common_options] start | stop | pause | continue | -s | -k | -m | config config_options \n\tUse 'all' for all sessions.\n\t-s sessionid List information about the session.\n\t-k sessionid\t Terminate a session. \n\t-m sessionid\t Send message to a session. \n\n\tconfig\t Configure telnet server parameters.\n\ncommon_options are:\n\t-u user\t Identity of the user whose credentials are to be used\n\t-p password\t Password of the user\n\nconfig_options are:\n\tdom = domain\t Set the default domain for user names\n\tctrlakeymap = yes|no\t Set the mapping of the ALT key\n\ttimeout = hh:mm:ss\t Set the Idle Session Timeout\n\ttimeoutactive = yes|no Enable idle session timeout.\n\tmaxfail = attempts\t Set the maximum number of login failure attempts\n\tbefore disconnecting.\n\tmaxconn = connections\t Set the maximum number of connections.\n\tport = number\t Set the telnet port.\n\tsec = [+/-]NTLM [+/-]passwd\n\t Set the authentication mechanism\n\tmode = console|stream\t Specify the mode of operation.\n"));
  117. #else
  118. TnLoadString(IDR_NEW_TELNET_USAGE,szMsg,MAX_BUFFER_SIZE,TEXT("\nUsage: tnadmin [computer name] [common_options] start | stop | pause | continue | -s | -k | -m | config config_options \n\tUse 'all' for all sessions.\n\t-s sessionid List information about the session.\n\t-k sessionid\t Terminate a session. \n\t-m sessionid\t Send message to a session. \n\n\tconfig\t Configure telnet server parameters.\n\ncommon_options are:\n\t-u user\t Identity of the user whose credentials are to be used\n\t-p password\t Password of the user\n\nconfig_options are:\n\tdom = domain\t Set the default domain for user names\n\tctrlakeymap = yes|no\t Set the mapping of the ALT key\n\ttimeout = hh:mm:ss\t Set the Idle Session Timeout\n\ttimeoutactive = yes|no Enable idle session timeout.\n\tmaxfail = attempts\t Set the maximum number of login failure attempts\n\tbefore disconnecting.\n\tmaxconn = connections\t Set the maximum number of connections.\n\tport = number\t Set the telnet port.\n\tsec = [+/-]NTLM [+/-]passwd\n\t Set the authentication mechanism\n\tmode = console|stream\t Specify the mode of operation.\n"));
  119. #endif
  120. MyWriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),szMsg,wcslen(szMsg));
  121. return(1);
  122. }
  123. ;
  124. messageoptions:
  125. _INTEGER {g_nSesid=atoi(yytext);}
  126. |_SESID {g_nSesid=-1;}
  127. |error
  128. {
  129. ShowError(IDR_SESSION);
  130. return(1);
  131. }
  132. ;
  133. configoptions : configoptions _CONFIG configop
  134. | configop
  135. ;
  136. help : _HELP {g_nPrimaryOption=_HELP;return 0;}
  137. ;
  138. //It is "all" or a number or nothing ---> meaning all
  139. sesid : _SESID {g_nSesid=-1;}
  140. | _INTEGER {g_nSesid=atoi(yytext);}
  141. | {if(g_nPrimaryOption == _K)
  142. {
  143. ShowError(IDR_SESSION);
  144. return(1);
  145. }
  146. g_nSesid=-1;}
  147. ;
  148. equals
  149. : _EQ
  150. | // "=" may or may not occur
  151. ;
  152. yn
  153. : _Y {szYesno="yes";}
  154. | _N {szYesno="no";}
  155. ;
  156. cs
  157. : _CONSOLE | _STREAM ;
  158. efb
  159. : _EVENTLOG | _FILEN | _BOTH ;
  160. time : _TIME {g_nTimeoutFlag=0;}
  161. | _INTEGER {g_nTimeoutFlag=1;}
  162. ;
  163. configop
  164. : configop _DOM
  165. {
  166. g_nConfigOptions=SetBit(g_nConfigOptions,_p_DOM_);
  167. // g_arVALOF[_p_DOM_]=DupWStr(yytext);
  168. }
  169. | configop _CTRLKEYMAP equals yn
  170. {
  171. g_nConfigOptions=SetBit(g_nConfigOptions,_p_CTRLAKEYMAP_);
  172. g_arVALOF[_p_CTRLAKEYMAP_]=DupWStr(szYesno);
  173. }
  174. | configop _CTRLKEYMAP equals error
  175. {
  176. ShowError(IDR_CTRLAKEYMAP_VALUES);
  177. return(1);
  178. //Quit();
  179. }
  180. | configop _TIMEOUT equals time
  181. {
  182. g_nConfigOptions=SetBit(g_nConfigOptions,_p_TIMEOUT_);
  183. g_arVALOF[_p_TIMEOUT_]=DupWStr(yytext);
  184. }
  185. | configop _TIMEOUT equals error
  186. {
  187. ShowError(IDR_TIMEOUT_INTEGER_VALUES );
  188. return(1);
  189. }
  190. | configop _TIMEOUTACTIVE equals yn
  191. {
  192. g_nConfigOptions=SetBit(g_nConfigOptions,_p_TIMEOUTACTIVE_);
  193. g_arVALOF[_p_TIMEOUTACTIVE_]=DupWStr(szYesno);
  194. }
  195. | configop _TIMEOUTACTIVE equals error
  196. {
  197. ShowError(IDR_TIMEOUTACTIVE_VALUES);
  198. return(1);
  199. }
  200. | configop _MAXFAIL equals _INTEGER
  201. {
  202. g_nConfigOptions=SetBit(g_nConfigOptions,_p_MAXFAIL_);
  203. g_arVALOF[_p_MAXFAIL_]=DupWStr(yytext);
  204. }
  205. | configop _MAXFAIL equals error
  206. {
  207. ShowError(IDR_MAXFAIL_VALUES );
  208. return(1);
  209. }
  210. | configop _MAXCONN equals _INTEGER
  211. {
  212. g_nConfigOptions=SetBit(g_nConfigOptions,_p_MAXCONN_);
  213. g_arVALOF[_p_MAXCONN_]=DupWStr(yytext);
  214. }
  215. | configop _MAXCONN equals error
  216. {
  217. // Removing this check, as we have decided that we are not going to restrict
  218. // max connections on Whistler.
  219. /*if(!IsMaxConnChangeAllowed())
  220. ShowError(IDR_MAXCONN_VALUES_WHISTLER);
  221. else*/
  222. ShowError(IDR_MAXCONN_VALUES );
  223. return(1);
  224. }
  225. | configop _PORT equals _INTEGER
  226. {
  227. g_nConfigOptions=SetBit(g_nConfigOptions,_p_PORT_);
  228. g_arVALOF[_p_PORT_]=DupWStr(yytext);
  229. }
  230. | configop _PORT equals error
  231. {
  232. ShowError(IDR_TELNETPORT_VALUES );
  233. return(1);
  234. }
  235. | configop _KILLALL equals yn
  236. {
  237. g_nConfigOptions=SetBit(g_nConfigOptions,_p_KILLALL_);
  238. g_arVALOF[_p_KILLALL_]=DupWStr(szYesno);
  239. }
  240. | configop _KILLALL equals error
  241. {
  242. ShowError(IDR_KILLALL_VALUES );
  243. return(1);
  244. }
  245. | configop _SEC {g_fComp=0;} equals secval
  246. {
  247. g_fComp=1;
  248. if(g_nSecOff||g_nSecOn)
  249. g_nConfigOptions=SetBit(g_nConfigOptions,_p_SEC_);
  250. else
  251. {
  252. ShowError(IDR_TELNET_SECURITY_VALUES);
  253. return(1);
  254. }
  255. }
  256. | configop _FNAME
  257. {
  258. g_nConfigOptions=SetBit(g_nConfigOptions,_p_FNAME_);
  259. // g_arVALOF[_p_FNAME_]=DupWStr(yytext);
  260. }
  261. ;
  262. | configop _FSIZE equals _INTEGER
  263. {
  264. g_arVALOF[_p_FSIZE_]=DupWStr(yytext);
  265. g_nConfigOptions=SetBit(g_nConfigOptions,_p_FSIZE_);
  266. }
  267. | configop _FSIZE equals error
  268. {
  269. ShowError(IDR_FILESIZE_VALUES );
  270. return(1);
  271. }
  272. | configop _MODE equals cs
  273. {
  274. g_arVALOF[_p_MODE_]=DupWStr(yytext);
  275. g_nConfigOptions=SetBit(g_nConfigOptions,_p_MODE_);
  276. }
  277. | configop _AUDITLOCATION equals efb
  278. {
  279. g_nConfigOptions=SetBit(g_nConfigOptions,_p_AUDITLOCATION_);
  280. g_arVALOF[_p_AUDITLOCATION_]=DupWStr(yytext);
  281. }
  282. | configop _AUDIT {g_fComp=0;} equals auditval
  283. {
  284. g_fComp=1;
  285. if(g_nAuditOff||g_nAuditOn)
  286. g_nConfigOptions=SetBit(g_nConfigOptions,_p_AUDIT_);
  287. else
  288. {
  289. ShowError(IDS_E_OPTIONGROUP);
  290. }
  291. }
  292. |
  293. ;
  294. secval : secval _PLUSNTLM
  295. {
  296. if(GetBit(g_nSecOn,NTLM_BIT)||GetBit(g_nSecOff,NTLM_BIT))
  297. {
  298. ShowError(IDS_E_OPTIONGROUP);
  299. }
  300. else
  301. g_nSecOn=SetBit(g_nSecOn,NTLM_BIT);
  302. }
  303. | secval _MINUSNTLM
  304. {
  305. if(GetBit(g_nSecOn,NTLM_BIT)||GetBit(g_nSecOff,NTLM_BIT))
  306. {
  307. ShowError(IDS_E_OPTIONGROUP);
  308. }
  309. else
  310. g_nSecOff=SetBit(g_nSecOff,NTLM_BIT);
  311. }
  312. | secval _PLUSPASSWD
  313. {
  314. if(GetBit(g_nSecOn,PASSWD_BIT)||GetBit(g_nSecOff,PASSWD_BIT))
  315. {
  316. ShowError(IDS_E_OPTIONGROUP);
  317. }
  318. else
  319. g_nSecOn=SetBit(g_nSecOn,PASSWD_BIT);
  320. }
  321. | secval _MINUSPASSWD
  322. {
  323. if(GetBit(g_nSecOn,PASSWD_BIT)||GetBit(g_nSecOff,PASSWD_BIT))
  324. {
  325. ShowError(IDS_E_OPTIONGROUP);
  326. }
  327. else
  328. g_nSecOff=SetBit(g_nSecOff,PASSWD_BIT);
  329. }
  330. |
  331. ;
  332. auditval : auditval _PLUSUSER
  333. {
  334. if(GetBit(g_nAuditOn,USER_BIT)||GetBit(g_nAuditOff,USER_BIT))
  335. {
  336. ShowError(IDS_E_OPTIONGROUP);
  337. }
  338. else
  339. g_nAuditOn=SetBit(g_nAuditOn,USER_BIT);
  340. }
  341. | auditval _MINUSUSER
  342. {
  343. if(GetBit(g_nAuditOn,USER_BIT)||GetBit(g_nAuditOff,USER_BIT))
  344. {
  345. ShowError(IDS_E_OPTIONGROUP);
  346. }
  347. else
  348. g_nAuditOff=SetBit(g_nAuditOff,USER_BIT);
  349. }
  350. | auditval _PLUSFAIL
  351. {
  352. if(GetBit(g_nAuditOn,FAIL_BIT)||GetBit(g_nAuditOff,FAIL_BIT))
  353. {
  354. ShowError(IDS_E_OPTIONGROUP);
  355. }
  356. else
  357. g_nAuditOn=SetBit(g_nAuditOn,FAIL_BIT);
  358. }
  359. | auditval _MINUSFAIL
  360. {
  361. if(GetBit(g_nAuditOn,FAIL_BIT)||GetBit(g_nAuditOff,FAIL_BIT))
  362. {
  363. ShowError(IDS_E_OPTIONGROUP);
  364. }
  365. else
  366. g_nAuditOff=SetBit(g_nAuditOff,FAIL_BIT);
  367. }
  368. | auditval _PLUSADMIN
  369. {
  370. if(GetBit(g_nAuditOn,ADMIN_BIT)||GetBit(g_nAuditOff,ADMIN_BIT))
  371. {
  372. ShowError(IDS_E_OPTIONGROUP);
  373. }
  374. else
  375. g_nAuditOn=SetBit(g_nAuditOn,ADMIN_BIT);
  376. }
  377. | auditval _MINUSADMIN
  378. {
  379. if(GetBit(g_nAuditOn,ADMIN_BIT)||GetBit(g_nAuditOff,ADMIN_BIT))
  380. {
  381. ShowError(IDS_E_OPTIONGROUP);
  382. }
  383. else
  384. g_nAuditOff=SetBit(g_nAuditOff,ADMIN_BIT);
  385. }
  386. |
  387. ;
  388. %%
  389. int
  390. yyerror(char *s)
  391. {
  392. g_nError=1;
  393. return 0;
  394. }
  395. int __cdecl
  396. wmain(int argc, wchar_t **argv)
  397. {
  398. wchar_t input_buffer[MAX_COMMAND_LINE+1]={0};
  399. int i, nWritten=0;
  400. int nTmpWrite = 0, nMsgWrite = 0;
  401. int nUoccur=0,nPoccur=0;
  402. int NextOp;
  403. int nIndex;
  404. DWORD dwErrorCode;
  405. BOOL fSuccess = FALSE;
  406. char szCodePage[MAX_LEN_FOR_CODEPAGE];
  407. HRESULT hRes=S_OK;
  408. switch (GetConsoleOutputCP())
  409. {
  410. case 932:
  411. case 949:
  412. setlocale(LC_ALL,"");
  413. SetThreadLocale(
  414. MAKELCID(
  415. MAKELANGID( PRIMARYLANGID(GetSystemDefaultLangID()),
  416. SUBLANG_ENGLISH_US),
  417. SORT_DEFAULT
  418. )
  419. );
  420. break;
  421. case 936:
  422. setlocale(LC_ALL,"");
  423. SetThreadLocale(
  424. MAKELCID(
  425. MAKELANGID( PRIMARYLANGID(GetSystemDefaultLangID()),
  426. SUBLANG_CHINESE_SIMPLIFIED),
  427. SORT_DEFAULT
  428. )
  429. );
  430. break;
  431. case 950:
  432. setlocale(LC_ALL,"");
  433. SetThreadLocale(
  434. MAKELCID(
  435. MAKELANGID( PRIMARYLANGID(GetSystemDefaultLangID()),
  436. SUBLANG_CHINESE_TRADITIONAL),
  437. SORT_DEFAULT
  438. )
  439. );
  440. break;
  441. default:
  442. sprintf(szCodePage,".%d",GetConsoleCP()); //a dot is added based on syntax of setlocale(), for defining a locale based on codepage.
  443. setlocale(LC_ALL, szCodePage);
  444. break;
  445. }
  446. Initialize();
  447. nTmpWrite = _snwprintf(input_buffer, ARRAYSIZE(input_buffer)-1, L_TNADMIN_TEXT);
  448. BAIL_ON_SNWPRINTF_ERR();
  449. nWritten+=nTmpWrite;
  450. for (i = 1; i < argc; i++)
  451. {
  452. fSuccess = FALSE;
  453. if(0==_wcsicmp(L"-u",argv[i]))
  454. {
  455. if(nUoccur)
  456. {
  457. ShowError(IDS_DUP_OPTION_ON_CL);
  458. fprintf(stdout,"'%s'.\n","u");
  459. goto End;
  460. }
  461. else
  462. nUoccur=1;
  463. i++;
  464. if(i<argc)
  465. g_arVALOF[_p_USER_]=_wcsdup(argv[i]);
  466. else
  467. {
  468. ShowErrorEx(IDS_MISSING_FILE_OR_ARGUMENT_EX,L"-u");
  469. goto End;
  470. }
  471. nTmpWrite=_snwprintf(input_buffer+nWritten, ARRAYSIZE(input_buffer)-nWritten-1, L" -u");
  472. BAIL_ON_SNWPRINTF_ERR();
  473. nWritten+=nTmpWrite;
  474. continue;
  475. }
  476. else if(0==_wcsicmp(L"-p",argv[i]))
  477. {
  478. if(nPoccur)
  479. {
  480. ShowError(IDS_DUP_OPTION_ON_CL);
  481. fprintf(stdout,"'%s'.\n","p");
  482. goto End;
  483. }
  484. else
  485. nPoccur=1;
  486. i++;
  487. if(i<argc)
  488. g_arVALOF[_p_PASSWD_]=_wcsdup(argv[i]);
  489. else
  490. {
  491. ShowErrorEx(IDS_MISSING_FILE_OR_ARGUMENT_EX,L"-p");
  492. goto End;
  493. }
  494. nTmpWrite=_snwprintf(input_buffer+nWritten, ARRAYSIZE(input_buffer)-nWritten-1, L" -p");
  495. BAIL_ON_SNWPRINTF_ERR();
  496. nWritten+=nTmpWrite;
  497. continue;
  498. }
  499. //Processing of -m option
  500. else if(0==_wcsicmp(L"-m",argv[i]))
  501. {
  502. nTmpWrite=_snwprintf(input_buffer+nWritten, ARRAYSIZE(input_buffer)-nWritten-1, L" -m");
  503. BAIL_ON_SNWPRINTF_ERR();
  504. nWritten+=nTmpWrite;
  505. i++;
  506. // The next argument should be the session id or all
  507. // So, copy that to the input_buffer and let that be
  508. // dealt by our lex
  509. if(i<argc)
  510. {
  511. nTmpWrite=_snwprintf(input_buffer+nWritten, ARRAYSIZE(input_buffer)-nWritten-1, L" %s", argv[i]);
  512. BAIL_ON_SNWPRINTF_ERR();
  513. nWritten+=nTmpWrite;
  514. }
  515. else
  516. goto MessageError;
  517. i++;
  518. if(i<argc)
  519. {
  520. // Then all the remaining command line arguments are
  521. // part of the message itself. So, copy them into the
  522. // global variable.
  523. nTmpWrite=_snwprintf(wzMessageString, ARRAYSIZE(wzMessageString)-1, L"%s ", argv[i]);
  524. BAIL_ON_SNWPRINTF_ERR();
  525. // Don't increment nWritten here as we are not writing in to input_buffer
  526. nMsgWrite=nTmpWrite;
  527. for(nIndex = i+1; nIndex < argc; nIndex++)
  528. {
  529. nTmpWrite=_snwprintf(wzMessageString+nMsgWrite, ARRAYSIZE(wzMessageString)-1-nMsgWrite, L"%s ", argv[nIndex]);
  530. BAIL_ON_SNWPRINTF_ERR();
  531. nMsgWrite+=nTmpWrite;
  532. }
  533. g_bstrMessage=SysAllocString(wzMessageString);
  534. break;
  535. }
  536. else
  537. {
  538. MessageError:
  539. ShowErrorEx(IDS_MISSING_FILE_OR_ARGUMENT_EX,L"-m");
  540. goto End;
  541. }
  542. }
  543. // Processing of actual filename is not given to Lexical analyser as
  544. // it may contail DBCS chars which our lexical analyser won't take
  545. // So, taking care of this analysis in pre-analysis part and giving
  546. // the actual analyser only the option and not the actual filename
  547. // This also holds good for domain name
  548. if(ERROR_SUCCESS!=(dwErrorCode = PreAnalyzer(argc,argv,_p_FNAME_,L"fname",i,&NextOp,&fSuccess,0)))
  549. {
  550. if(E_FAIL==dwErrorCode)
  551. ShowError(IDR_FILENAME_VALUES);
  552. else ShowError(dwErrorCode);
  553. goto End;
  554. }
  555. if(fSuccess)
  556. {
  557. // Some processing had take place in the PreAnalyzer
  558. nTmpWrite=_snwprintf(input_buffer+nWritten, ARRAYSIZE(input_buffer)-nWritten-1, L" fname");
  559. BAIL_ON_SNWPRINTF_ERR();
  560. nWritten+=nTmpWrite;
  561. i=NextOp;
  562. continue;
  563. }
  564. // Fall through for taking care of remaining options.
  565. // Similar treatment for Dom option
  566. if(ERROR_SUCCESS!=(dwErrorCode = PreAnalyzer(argc,argv,_p_DOM_,L"dom",i,&NextOp,&fSuccess,0)))
  567. {
  568. if(E_FAIL==dwErrorCode)
  569. ShowError(IDR_INVALID_NTDOMAIN);
  570. else ShowError(dwErrorCode);
  571. goto End;
  572. }
  573. if(fSuccess)
  574. {
  575. // Some processing had take place in the PreAnalyzer
  576. nTmpWrite=_snwprintf(input_buffer+nWritten, ARRAYSIZE(input_buffer)-nWritten-1, L" dom");
  577. BAIL_ON_SNWPRINTF_ERR();
  578. nWritten+=nTmpWrite;
  579. i=NextOp;
  580. continue;
  581. }
  582. Skip:
  583. if(MAX_COMMAND_LINE<nWritten+wcslen(argv[i]))
  584. {
  585. ShowError(IDR_LONG_COMMAND_LINE);
  586. goto End;
  587. }
  588. if(NULL==wcsstr(argv[i],L" "))
  589. nTmpWrite = _snwprintf(input_buffer+nWritten, ARRAYSIZE(input_buffer)-nWritten-1, L" %s", argv[i]);
  590. else
  591. nTmpWrite = _snwprintf(input_buffer+nWritten, ARRAYSIZE(input_buffer)-nWritten-1, L" \"%s\"", argv[i]);
  592. // the following statements are common for both if and else statements
  593. BAIL_ON_SNWPRINTF_ERR();
  594. nWritten+=nTmpWrite;
  595. }
  596. nTmpWrite = _snwprintf(input_buffer+nWritten, ARRAYSIZE(input_buffer)-nWritten-1, L" #\n\0");
  597. BAIL_ON_SNWPRINTF_ERR();
  598. nWritten+=nTmpWrite;
  599. yy_scan_string(DupCStr(input_buffer));
  600. yyparse ();
  601. if (g_nError)
  602. {
  603. ShowError(IDR_TELNET_ILLEGAL);
  604. goto End;
  605. }
  606. hRes = DoTnadmin();
  607. if (hRes != S_OK && !g_nError)
  608. g_nError = 1; //general error status
  609. End:
  610. Quit();
  611. return g_nError;
  612. }