[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 17# Bella

举十指十趾赞成, 那就是那货最大的用处
1

评分人数

TOP

本帖最后由 aa77dd@163.com 于 2016-10-17 13:01 编辑

回复 24# CrLf

set /p 后面的
input10

从 12 到 16 是不是木有改呢

象是关于 cmd 的管道阻塞处理方式

Desktop App>Technologies System Services>Interprocess Communications>\"\"ipes

Pipe Functions

管道编程

The Windows Pipes Programming - windows“管道”编程 之 "匿名管道"


那个老版的 CMD 源码中有个 文件 cop.c,  包含了 4 个关于管道的函数 ePipe ,PipeErr, PipeWait, BreakPipes
文件 600+ 行, 我就贴上吧
cop.c
  1. #include "cmd.h"
  2. extern int LastRetCode;
  3. extern int ExtCtrlc; /* @@1 */
  4. /*  M000 ends */
  5. unsigned PipeCnt ; /* M007 - Active pipe count    */
  6. struct pipedata *PdHead = NULL; /* M007 - 1st element of pipedata list    */
  7. struct pipedata *PdTail = NULL; /* M007 - Last element of pipedata list    */
  8. unsigned PipePid ; /* M007 - Communication with ECWork    */
  9. /*** eComSep - execute a statement containing a command separator
  10. *
  11. *  Purpose:
  12. * Execute the left and right hand sides of a command separator
  13. * operator.
  14. *
  15. *  int eComSep(struct node *n)
  16. *
  17. *  Args:
  18. * n - parse tree node containing the command separator node
  19. *
  20. *  Returns:
  21. * Whatever the right hand side returns.
  22. *
  23. *  Notes:
  24. * Revised to always supply both args to Dispatch().
  25. */
  26. int eComSep(n)
  27. struct node *n ;
  28. {
  29. Dispatch(RIO_OTHER,n->lhs) ;
  30. return(Dispatch(RIO_OTHER,n->rhs)) ;
  31. }
  32. /*** eOr - execute an OR operation
  33. *
  34. *  Purpose:
  35. * Execute the left hand side of an OR operator (||).  If it succeeds,
  36. * quit.  Otherwise execute the right side of the operator.
  37. *
  38. *  int eOr(struct node *n)
  39. *
  40. *  Args:
  41. * n - parse tree node containing the OR operator node
  42. *
  43. *  Returns:
  44. * If the left hand side succeeds, return SUCCESS.  Otherwise, return
  45. * whatever the right side returns.
  46. *
  47. *  Notes:
  48. * Revised to always supply both args to Dispatch().
  49. */
  50. int eOr(n)
  51. struct node *n ;
  52. {
  53.         int i ;                         /* Retcode from L.H. side of OR   */
  54. if ((i = Dispatch(RIO_OTHER,n->lhs)) == SUCCESS)
  55.     return(SUCCESS) ;
  56. else {
  57.             LastRetCode = i;
  58.     return(Dispatch(RIO_OTHER,n->rhs)) ;
  59.         }
  60. }
  61. /*** eAnd - execute an AND operation
  62. *
  63. *  Purpose:
  64. * Execute the left hand side of an AND operator (&&).  If it fails,
  65. * quit.  Otherwise execute the right side of the operator.
  66. *
  67. *  int eAnd(struct node *n)
  68. *
  69. *  Args:
  70. * n - parse tree node containing the AND operator node
  71. *
  72. *  Returns:
  73. * If the left hand side fails, return its return code.  Otherwise, return
  74. * whatever the right side returns.
  75. *
  76. *  Notes:
  77. * Revised to always supply both args to Dispatch().
  78. */
  79. int eAnd(n)
  80. struct node *n ;
  81. {
  82. int i ; /* Retcode from L.H. side of AND   */
  83. if ((i = Dispatch(RIO_OTHER,n->lhs)) != SUCCESS)
  84. return(i) ;
  85. else
  86. return(Dispatch(RIO_OTHER,n->rhs)) ;
  87. }
  88. /********************* START OF SPECIFICATION **************************/
  89. /*        */
  90. /* SUBROUTINE NAME: ePipe        */
  91. /*        */
  92. /* DESCRIPTIVE NAME: Pipe Process        */
  93. /*        */
  94. /* FUNCTION: Execute the left side of the pipe and direct its output to*/
  95. /*      the right side of the pipe.        */
  96. /*        */
  97. /* NOTES: None        */
  98. /*        */
  99. /*        */
  100. /* ENTRY POINT: ePipe        */
  101. /*    LINKAGE: NEAR        */
  102. /*        */
  103. /* INPUT: n - parse tree node containing the pipe operator        */
  104. /*        */
  105. /* OUTPUT: None        */
  106. /*        */
  107. /* EXIT-NORMAL: The return code of the right side process.        */
  108. /*        */
  109. /* EXIT-ERROR: Failure if no pipe redirection can take place.        */
  110. /*        */
  111. /* EFFECTS:        */
  112. /*        */
  113. /*    struct pipedata {        */
  114. /*    unsigned rh ;        Pipe read handle        */
  115. /*    unsigned wh ;        Pipe write handle        */
  116. /*    unsigned shr ;        Handles where the normal...     */
  117. /*    unsigned shw ;        ...STDIN/OUT handles are saved  */
  118. /*    unsigned lPID ;        Pipe lh side PID        */
  119. /*    unsigned rPID ;        Pipe rh side PID        */
  120. /*    unsigned lstart ;        Start Information of lh side @@4*/
  121. /*    unsigned rstart ;        Start Information of rh side @@4*/
  122. /*    struct pipedata *prvpds ;   Ptr to previous pipedata struct */
  123. /*    struct pipedata *nxtpds ;   Ptr to next pipedata struct     */
  124. /*       }        */
  125. /*        */
  126. /*    unsigned PipePID;        Pipe Process ID        */
  127. /*        */
  128. /*    unsigned start_type;        Start Information        */
  129. /*        */
  130. /*        */
  131. /* INTERNAL REFERENCES:        */
  132. /* ROUTINES:        */
  133. /* PutStdErr -  Print an error message        */
  134. /* Abort    -  Terminate program with abort        */
  135. /* SetList   -  Set Link List for pipedata structure        */
  136. /* Cdup    -  Duplicate supplied handle and save the new handle*/
  137. /* Cdup2    -  Duplicate supplied handle and save the new handle*/
  138. /* Dispatch  -  Execute the program        */
  139. /* PipeErr   -  Handle pipe error        */
  140. /* Cclose    -  Close the specified handle        */
  141. /* PipeWait  -  Wait for the all pipe process completion        */
  142. /*        */
  143. /* EXTERNAL REFERENCES:        */
  144. /* ROUTINES:        */
  145. /* DOSMAKEPIPE - Make pipe        */
  146. /*        */
  147. /********************** END  OF SPECIFICATION **************************/
  148. /*** ePipe - Create a pipeline between two processes (M000)
  149. *
  150. *  Purpose:
  151. * Execute the left side of the pipe and direct its output to
  152. * the right side of the pipe.
  153. *
  154. *  int ePipe(struct node *n)
  155. *
  156. *  Args:
  157. * n - parse tree node containing the pipe operator
  158. *
  159. *  Returns:
  160. * The return code of the right side process or failure if no
  161. * pipe redirection can take place.
  162. *
  163. *  Notes:
  164. * M007 - This function has been completely rewritten for real pipes.
  165. *
  166. */
  167. int ePipe(n)
  168. struct node *n ;
  169. {
  170. struct pipedata *Pd ; /* Pipe struct pointer    */
  171. int k = 0 ; /* RH side return code    */
  172. struct node *l ; /* Copy of left side arg   */
  173. struct node *r ; /* Copy of right side arg  */
  174. extern unsigned start_type ; /* API type used to start  */
  175. TCHAR cflags ; /*    */
  176. l = n->lhs ; /* Equate locals to...    */
  177. r = n->rhs ; /* ...L & R operations    */
  178. DEBUG((OPGRP,PILVL,"PIPES:LH = %d, RH = %d ",l->type,r->type)) ;
  179. if (!(Pd = (struct pipedata *)mkstr(sizeof(struct pipedata)))) {
  180. DEBUG((OPGRP,PILVL,"PIPES:Couldn't alloc structure!")) ;
  181. return(FAILURE) ;
  182. } ;
  183. if (_pipe((int *)Pd, 0, O_BINARY)) {
  184. DEBUG((OPGRP,PILVL,"PIPES:pipe failed!")) ;
  185. PutStdErr(ERROR_NOT_ENOUGH_MEMORY, NOARGS); /* M013    */
  186. return(FAILURE) ;
  187. Abort() ;
  188. } ;
  189. SetList(Pd->rh) ; /* M009 */
  190. SetList(Pd->wh) ; /* M009 */
  191. DEBUG((OPGRP,PILVL,"PIPES:Pipe built. Handles: rd = %d wt = %d ",Pd->rh, Pd->wh)) ;
  192. DEBUG((OPGRP,PILVL,"PIPES:Pipe (pre-index) count = %d", PipeCnt)) ;
  193. if (!PipeCnt++) { /* Already some pipes?    */
  194. PdHead = PdTail = Pd ; /* No, set head/tail ptrs  */
  195. Pd->prvpds = NULL ; /* No previous structure   */
  196. DEBUG((OPGRP,PILVL,"PIPES:This is first pipe.")) ;
  197. } else {
  198. DEBUG((OPGRP,PILVL,"PIPES:This is pipe %d.", PipeCnt)) ;
  199. PdTail->nxtpds = Pd ;
  200. Pd->prvpds = PdTail ;
  201. Pd->nxtpds = NULL ;
  202. PdTail = Pd ;
  203. } ;
  204. if ((Pd->shw = Cdup(STDOUT)) == BADHANDLE) {   /* Save STDOUT (M009) */
  205. Pd->shw = BADHANDLE ; /* If err, go process it   */
  206. PipeErr() ; /* DOES NOT RETURN    */
  207. } ;
  208. DEBUG((OPGRP,PILVL,"PIPES:STDOUT dup'd to %d.", Pd->shw)) ;
  209. if (Cdup2(Pd->wh, STDOUT) == BADHANDLE) /* Make wh STDOUT (M009)   */
  210. PipeErr() ; /* DOES NOT RETURN    */
  211. Cclose(Pd->wh) ; /* Close pipe hndl (M009)  */
  212. Pd->wh = 0 ; /* And zero the holder    */
  213. if (l->type <= CMDTYP)   /* @@5a */
  214.   {   /* @@5a */
  215.     FindAndFix( (struct cmdnode *) l, &cflags ) ; /* @@5a */
  216.   }   /* @@5a */
  217. DEBUG((OPGRP,PILVL,"PIPES:Write pipe now STDOUT")) ;
  218. k = Dispatch(RIO_PIPE,l) ;
  219.         DuplicateHandle( (HANDLE)PipePid, CRTTONT(Pd->rh),
  220.                         NULL, NULL, 0, FALSE, DUPLICATE_CLOSE_SOURCE);
  221. if (Cdup2(Pd->shw, STDOUT) == BADHANDLE) /* M009 */
  222. PipeErr() ; /* DOES NOT RETURN    */
  223. Cclose(Pd->shw) ; /* M009 */
  224. Pd->shw = 0 ;
  225. DEBUG((OPGRP,PILVL,"PIPES:STDOUT now handle 1 again.")) ;
  226. if (k) {
  227. ExtCtrlc = 2; /* @@1 */
  228. Abort() ;
  229. }
  230. Pd->lPID = PipePid ;
  231. Pd->lstart = start_type ;  /* Save the start_type in pipedata struct */
  232. PipePid = 0 ;
  233. start_type = NONEPGM ;    /* Reset the start_type     D64      */
  234. DEBUG((OPGRP,PILVL,"PIPES:Dispatch LH side succeeded - LPID = %d.",Pd->lPID)) ;
  235. if ((Pd->shr = Cdup(STDIN)) == BADHANDLE) {    /* Save STDIN (M009) */
  236. Pd->shr = BADHANDLE ;
  237. PipeErr() ; /* DOES NOT RETURN    */
  238. } ;
  239. DEBUG((OPGRP,PILVL,"PIPES:STDIN dup'd to %d.", Pd->shr)) ;
  240. if (Cdup2(Pd->rh, STDIN) == BADHANDLE) /* Make rh STDIN (M009)    */
  241. PipeErr() ; /* DOES NOT RETURN    */
  242. Cclose(Pd->rh) ; /* Close pipe hndl (M009)  */
  243. Pd->rh = 0 ; /* And zero the holder    */
  244. if (r->type <= CMDTYP)      /* @@5a */
  245.   {      /* @@5a */
  246.     FindAndFix( (struct cmdnode *) r, &cflags) ;     /* @@5a */
  247.   } ;      /* @@5a */
  248. DEBUG((OPGRP,PILVL,"PIPES:Read pipe now STDIN")) ;
  249. k = Dispatch(RIO_PIPE,r) ;
  250. if (Cdup2(Pd->shr, STDIN) == BADHANDLE) /* M009 */
  251. PipeErr() ; /* DOES NOT RETURN    */
  252. Cclose(Pd->shr) ; /* M009 */
  253. Pd->shr = 0 ;
  254. DEBUG((OPGRP,PILVL,"PIPES:STDIN now handle 0 again.")) ;
  255. if (k) {
  256. ExtCtrlc = 2; /* @@1 */
  257. Abort() ;
  258. }
  259. Pd->rPID = PipePid ;
  260. Pd->rstart = start_type ;  /* Save the start_type in pipedata struct */
  261. PipePid = 0 ;
  262. start_type = NONEPGM ;    /* Reset the start_type  D64      */
  263. DEBUG((OPGRP,PILVL,"PIPES:Dispatch RH side succeeded - RPID = %d.",Pd->rPID)) ;
  264. if (!(--PipeCnt)) { /* Additional pipes?    */
  265. DEBUG((OPGRP,PILVL,"PIPES:Returning from top level pipe. Cnt = %d", PipeCnt)) ;
  266. return(PipeWait()) ; /* No, return CWAIT    */
  267. } ;
  268. DEBUG((OPGRP,PILVL,"PIPES:Returning from pipe. Cnt = %d", PipeCnt)) ;
  269. return(k) ; /* Else return exec ret    */
  270. }
  271. /*** PipeErr - Fixup and error out following pipe error
  272. *
  273. *  Purpose:
  274. * To provide single error out point for multiple error conditions.
  275. *
  276. *  int PipeErr()
  277. *
  278. *  Args:
  279. * None.
  280. *
  281. *  Returns:
  282. * DOES NOT RETURN TO CALLER.  Instead it causes an internal Abort().
  283. *
  284. */
  285. void PipeErr()
  286. {
  287. PutStdErr(MSG_PIPE_FAILURE, NOARGS) ; /* M013    */
  288. Abort() ;
  289. }
  290. /********************* START OF SPECIFICATION **************************/
  291. /*        */
  292. /* SUBROUTINE NAME: PipeWait        */
  293. /*        */
  294. /* DESCRIPTIVE NAME: Wait and Collect Retcode for All Pipe Completion  */
  295. /*        */
  296. /* FUNCTION: This routine calls WaitProc or WaitTermQProc for all      */
  297. /*      pipelined processes until entire pipeline is finished.    */
  298. /*      The return code of right most element is returned.        */
  299. /*        */
  300. /* NOTES:    If the pipelined process is started by DosExecPgm,        */
  301. /*      WaitProc is called.  If the pipelined process is started  */
  302. /*      by DosStartSession, WaitTermQProc is called.        */
  303. /*        */
  304. /*        */
  305. /* ENTRY POINT: PipeWait        */
  306. /*    LINKAGE: NEAR        */
  307. /*        */
  308. /* INPUT: None        */
  309. /*        */
  310. /* OUTPUT: None        */
  311. /*        */
  312. /* EXIT-NORMAL:  No error return code        */
  313. /*        */
  314. /* EXIT-ERROR: Error return code from either WaitTermQProc or WaitProc*/
  315. /*        */
  316. /*        */
  317. /* EFFECTS: None.        */
  318. /*        */
  319. /* INTERNAL REFERENCES:        */
  320. /* ROUTINES:        */
  321. /* WaitProc - wait for the termination of the specified process, */
  322. /*     its child process, and  related pipelined        */
  323. /*     processes.        */
  324. /*        */
  325. /* WaitTermQProc - wait for the termination of the specified     */
  326. /* session and related pipelined session.        */
  327. /*        */
  328. /* EXTERNAL REFERENCES:        */
  329. /* ROUTINES:        */
  330. /* WINCHANGESWITCHENTRY -  Change switch list entry        */
  331. /*        */
  332. /********************** END  OF SPECIFICATION **************************/
  333. /*** PipeWait - wait and collect retcode for all pipe completion (M007)
  334. *
  335. *  Purpose:
  336. * To do cwaits on all pipelined processes until entire pipeline
  337. * is finished.  The retcode of the rightmost element of the pipe
  338. * is returned.
  339. *
  340. *  int PipeWait()
  341. *
  342. *  Args:
  343. * None.
  344. *
  345. *  Returns:
  346. * Retcode of rightmost pipe process.
  347. *
  348. */
  349. PipeWait()
  350. {
  351. unsigned i ;
  352. DEBUG((OPGRP,PILVL,"PIPEWAIT:Entered - PipeCnt = %d", PipeCnt)) ;
  353. while (PdHead) {
  354. if (PdHead->lPID) {
  355.      DEBUG((OPGRP, PILVL, "PIPEWAIT: lPID %d, lstart %d", PdHead->lPID, PdHead->lstart));
  356.      if ( PdHead->lstart == EXECPGM )
  357.        {
  358. i = WaitProc(PdHead->lPID) ; /* M012 - Wait LH   */
  359. DEBUG((OPGRP,PILVL,"PIPEWAIT:CWAIT on LH - Ret = %d, SPID = %d", i, PdHead->lPID)) ;
  360.        }
  361. //      else
  362. //        {
  363. // WaitTermQProc(PdHead->lPID, &i) ;
  364. //
  365. // DEBUG((OPGRP,PILVL,"PIPEWAIT:Read TermQ on LH - Ret = %d, PID = %d", i, PdHead->lPID)) ;
  366. //        } ;
  367. //
  368. } ;
  369. if (PdHead->rPID) {
  370.      DEBUG((OPGRP, PILVL, "PIPEWAIT: rPID %d, rstart %d", PdHead->rPID, PdHead->rstart));
  371.      if ( PdHead->rstart == EXECPGM )
  372.        {
  373. i = WaitProc(PdHead->rPID) ; /* M012 - Wait RH   */
  374. DEBUG((OPGRP,PILVL,"PIPEWAIT:CWAIT on RH - Ret = %d, PID = %d", i, PdHead->rPID)) ;
  375.        }
  376. //      else
  377. //        {
  378. // WaitTermQProc(PdHead->rPID, &i) ;
  379. //
  380. // DEBUG((OPGRP,PILVL,"PIPEWAIT:Read TermQ on LH - Ret = %d, PID = %d", i, PdHead->rPID)) ;
  381. //        } ;
  382. } ;
  383. PdHead = PdHead->nxtpds ;
  384. } ;
  385. DEBUG((OPGRP,PILVL,"PIPEWAIT: complete, Retcode = %d", i)) ;
  386. PdTail = NULL ; /* Cancel linked list...    */
  387. PipeCnt = PipePid = 0 ; /* ...pipe count and pipe PID    */
  388.         LastRetCode = i;
  389. return(i) ;
  390. }
  391. /*** BreakPipes - disconnect all active pipes  (M000)
  392. *
  393. *  Purpose:
  394. * To remove the temporary pipe files and invalidate the pipedata
  395. * structure when pipes are to be terminated, either through the
  396. * completion of the pipe operation or SigTerm.
  397. *
  398. * This routine is called directly by the signal handler and must
  399. * not generate any additional error conditions.
  400. *
  401. *  void BreakPipes()
  402. *
  403. *  Args:
  404. * None.
  405. *
  406. *  Returns:
  407. * Nothing.
  408. *
  409. *  Notes:
  410. * M007 - This function has been completely rewritten for real pipes.
  411. *
  412. * *** W A R N I N G ! ***
  413. * THIS ROUTINE IS CALLED AS A PART OF SIGNAL/ABORT RECOVERY AND
  414. * THEREFORE MUST NOT BE ABLE TO TRIGGER ANOTHER ABORT CONDITION.
  415. *
  416. */
  417. void BreakPipes()
  418. {
  419. unsigned i ;
  420. struct pipedata *pnode;
  421. DEBUG((OPGRP,PILVL,"BRKPIPES:Entered - PipeCnt = %d", PipeCnt)) ;
  422. /* The following two lines have been commented out */
  423. /* because the NULL test on PdTail should be enough, */
  424. /* and more importantly, even if PipeCnt is 0, you */
  425. /* may still have been servicing a pipe in Pipewait */
  426. /* if (!PipeCnt)        */ /* If no active pipes...   */
  427. /* return ;       */ /* ...don't do anything    */
  428. pnode = PdTail;
  429. /* First, kill all of the processes */
  430. while (pnode) {
  431. if (pnode->lPID) {
  432. /* M012 */ i = KillProc(pnode->lPID, FALSE) ; /* Kill LH   */
  433. DEBUG((OPGRP,PILVL,"BRKPIPES:LH (Pid %d) killed - Retcode = %d", PdTail->lPID, i)) ;
  434. } ;
  435. if (pnode->rPID) {
  436. /* M012 */ i = KillProc(pnode->rPID, FALSE) ; /* Kill RH   */
  437. DEBUG((OPGRP,PILVL,"BRKPIPES:RH (Pid %d) killed - Retcode = %d", PdTail->rPID, i)) ;
  438. } ;
  439. pnode = pnode->prvpds ;
  440. }
  441. /* Wait for the processes to die, and clean up file handles */
  442. while (PdTail) {
  443. if (PdTail->lPID) {
  444.    if (PdTail->lstart == EXECPGM) {
  445.       i = WaitProc(PdTail->lPID);
  446. //    } else {
  447. //       WaitTermQProc(PdTail->lPID, &i) ;
  448.    }
  449. } ;
  450. if (PdTail->rPID) {
  451.    if (PdTail->rstart == EXECPGM) {
  452.       i = WaitProc(PdTail->rPID);
  453. //    } else {
  454. //       WaitTermQProc(PdTail->rPID, &i) ;
  455.    }
  456. } ;
  457. if (PdTail->rh) {
  458. Cclose(PdTail->rh) ; /* M009 */
  459. DEBUG((OPGRP,PILVL,"BRKPIPES:Pipe read handle closed")) ;
  460. } ;
  461. if (PdTail->wh) {
  462. Cclose(PdTail->wh) ; /* M009 */
  463. DEBUG((OPGRP,PILVL,"BRKPIPES:Pipe write handle closed")) ;
  464. } ;
  465. if(PdTail->shr) {
  466. FlushFileBuffers(CRTTONT(PdTail->shr));
  467. Cdup2(PdTail->shr, STDIN) ; /* M009 */
  468. Cclose(PdTail->shr) ; /* M009 */
  469. DEBUG((OPGRP,PILVL,"BRKPIPES:STDIN restored.")) ;
  470. } ;
  471. if(PdTail->shw) {
  472. Cdup2(PdTail->shw, STDOUT) ; /* M009 */
  473. Cclose(PdTail->shw) ; /* M009 */
  474. DEBUG((OPGRP,PILVL,"BRKPIPES:STDOUT restored.")) ;
  475. } ;
  476. PdTail = PdTail->prvpds ;
  477. } ;
  478. PdHead = NULL ; /* Cancel linked list...    */
  479. PipeCnt = PipePid = 0 ; /* ...pipe count and pipe PID    */
  480. DEBUG((OPGRP,PILVL,"BRKPIPES:Action complete, returning")) ;
  481. }
  482. /*** eParen - execute a parenthesized statement group
  483. *
  484. *  Purpose:
  485. * Execute the group of statements enclosed by a statement grouping
  486. * operator; parenthesis().
  487. *
  488. *  int eParen(struct node *n)
  489. *
  490. *  Args:
  491. * n - parse tree node containing the PAREN operator node
  492. *
  493. *  Returns:
  494. * Whatever the statement group returns.
  495. *
  496. *  Notes:
  497. * M000 - Altered to always supply both args to Dispatch().
  498. * M004 - Debug statements were added for SILTYP operator.
  499. * **  WARNING  **
  500. * BOTH THE LEFT PAREN AND THE SILENT OPERATOR (@) USE eParen
  501. * WHEN DISPATCHED.  CHANGING ONE WILL AFFECT THE OTHER !!
  502. */
  503. int eParen(n)
  504. struct node *n ;
  505. {
  506. #ifndef NODEB
  507. if (n->type == PARTYP)
  508.                 DEBUG((OPGRP,PNLVL,"ePAREN: Operator is Paren")) ;
  509. else if (n->type == SILTYP)
  510.                 DEBUG((OPGRP,PNLVL,"ePAREN: Operator is Silent")) ;
  511. #endif
  512. return(Dispatch(RIO_OTHER,n->lhs)) ;
  513. }
复制代码
我还是去浇花来得轻松
https://play.google.com/store/ap ... m.tedrasoft.plumber

TOP

回复 28# CrLf


    4176 = 4096 + 80
1

评分人数

    • Bella: 发错版块技术 + 1

TOP

本帖最后由 aa77dd@163.com 于 2016-10-18 02:43 编辑

回复 31# Bella

看了下别人的方案,   传感器,  水泵开关这些需要一些硬件接口资料, 事实上这简单的方案,

纯粹用电子电路也差不多可以实现了
纯电子电路的最简陋方案: 湿度传感器 湿度低于 干燥阀值 , 启动水泵;  湿度高于湿润阀值, 关闭水泵. 简单原理如此, 但实现上肯定会有很多细节问题要解决

我倒是想过做成个打印机, 也不是很好玩, 一直没入手

TOP

返回列表