crypto: allow padding in RSA methods
[platform/upstream/nodejs.git] / src / node_constants.cc
1 // Copyright Joyent, Inc. and other Node contributors.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to permit
8 // persons to whom the Software is furnished to do so, subject to the
9 // following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 #include "node_constants.h"
23
24 #include "uv.h"
25
26 #include <errno.h>
27 #if !defined(_MSC_VER)
28 #include <unistd.h>
29 #endif
30 #include <fcntl.h>
31 #include <signal.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34
35 #if HAVE_OPENSSL
36 # include <openssl/ssl.h>
37 # ifndef OPENSSL_NO_ENGINE
38 #  include <openssl/engine.h>
39 # endif  // !OPENSSL_NO_ENGINE
40 #endif
41
42 namespace node {
43
44 using v8::Handle;
45 using v8::Object;
46
47 void DefineErrnoConstants(Handle<Object> target) {
48 #ifdef E2BIG
49   NODE_DEFINE_CONSTANT(target, E2BIG);
50 #endif
51
52 #ifdef EACCES
53   NODE_DEFINE_CONSTANT(target, EACCES);
54 #endif
55
56 #ifdef EADDRINUSE
57   NODE_DEFINE_CONSTANT(target, EADDRINUSE);
58 #endif
59
60 #ifdef EADDRNOTAVAIL
61   NODE_DEFINE_CONSTANT(target, EADDRNOTAVAIL);
62 #endif
63
64 #ifdef EAFNOSUPPORT
65   NODE_DEFINE_CONSTANT(target, EAFNOSUPPORT);
66 #endif
67
68 #ifdef EAGAIN
69   NODE_DEFINE_CONSTANT(target, EAGAIN);
70 #endif
71
72 #ifdef EALREADY
73   NODE_DEFINE_CONSTANT(target, EALREADY);
74 #endif
75
76 #ifdef EBADF
77   NODE_DEFINE_CONSTANT(target, EBADF);
78 #endif
79
80 #ifdef EBADMSG
81   NODE_DEFINE_CONSTANT(target, EBADMSG);
82 #endif
83
84 #ifdef EBUSY
85   NODE_DEFINE_CONSTANT(target, EBUSY);
86 #endif
87
88 #ifdef ECANCELED
89   NODE_DEFINE_CONSTANT(target, ECANCELED);
90 #endif
91
92 #ifdef ECHILD
93   NODE_DEFINE_CONSTANT(target, ECHILD);
94 #endif
95
96 #ifdef ECONNABORTED
97   NODE_DEFINE_CONSTANT(target, ECONNABORTED);
98 #endif
99
100 #ifdef ECONNREFUSED
101   NODE_DEFINE_CONSTANT(target, ECONNREFUSED);
102 #endif
103
104 #ifdef ECONNRESET
105   NODE_DEFINE_CONSTANT(target, ECONNRESET);
106 #endif
107
108 #ifdef EDEADLK
109   NODE_DEFINE_CONSTANT(target, EDEADLK);
110 #endif
111
112 #ifdef EDESTADDRREQ
113   NODE_DEFINE_CONSTANT(target, EDESTADDRREQ);
114 #endif
115
116 #ifdef EDOM
117   NODE_DEFINE_CONSTANT(target, EDOM);
118 #endif
119
120 #ifdef EDQUOT
121   NODE_DEFINE_CONSTANT(target, EDQUOT);
122 #endif
123
124 #ifdef EEXIST
125   NODE_DEFINE_CONSTANT(target, EEXIST);
126 #endif
127
128 #ifdef EFAULT
129   NODE_DEFINE_CONSTANT(target, EFAULT);
130 #endif
131
132 #ifdef EFBIG
133   NODE_DEFINE_CONSTANT(target, EFBIG);
134 #endif
135
136 #ifdef EHOSTUNREACH
137   NODE_DEFINE_CONSTANT(target, EHOSTUNREACH);
138 #endif
139
140 #ifdef EIDRM
141   NODE_DEFINE_CONSTANT(target, EIDRM);
142 #endif
143
144 #ifdef EILSEQ
145   NODE_DEFINE_CONSTANT(target, EILSEQ);
146 #endif
147
148 #ifdef EINPROGRESS
149   NODE_DEFINE_CONSTANT(target, EINPROGRESS);
150 #endif
151
152 #ifdef EINTR
153   NODE_DEFINE_CONSTANT(target, EINTR);
154 #endif
155
156 #ifdef EINVAL
157   NODE_DEFINE_CONSTANT(target, EINVAL);
158 #endif
159
160 #ifdef EIO
161   NODE_DEFINE_CONSTANT(target, EIO);
162 #endif
163
164 #ifdef EISCONN
165   NODE_DEFINE_CONSTANT(target, EISCONN);
166 #endif
167
168 #ifdef EISDIR
169   NODE_DEFINE_CONSTANT(target, EISDIR);
170 #endif
171
172 #ifdef ELOOP
173   NODE_DEFINE_CONSTANT(target, ELOOP);
174 #endif
175
176 #ifdef EMFILE
177   NODE_DEFINE_CONSTANT(target, EMFILE);
178 #endif
179
180 #ifdef EMLINK
181   NODE_DEFINE_CONSTANT(target, EMLINK);
182 #endif
183
184 #ifdef EMSGSIZE
185   NODE_DEFINE_CONSTANT(target, EMSGSIZE);
186 #endif
187
188 #ifdef EMULTIHOP
189   NODE_DEFINE_CONSTANT(target, EMULTIHOP);
190 #endif
191
192 #ifdef ENAMETOOLONG
193   NODE_DEFINE_CONSTANT(target, ENAMETOOLONG);
194 #endif
195
196 #ifdef ENETDOWN
197   NODE_DEFINE_CONSTANT(target, ENETDOWN);
198 #endif
199
200 #ifdef ENETRESET
201   NODE_DEFINE_CONSTANT(target, ENETRESET);
202 #endif
203
204 #ifdef ENETUNREACH
205   NODE_DEFINE_CONSTANT(target, ENETUNREACH);
206 #endif
207
208 #ifdef ENFILE
209   NODE_DEFINE_CONSTANT(target, ENFILE);
210 #endif
211
212 #ifdef ENOBUFS
213   NODE_DEFINE_CONSTANT(target, ENOBUFS);
214 #endif
215
216 #ifdef ENODATA
217   NODE_DEFINE_CONSTANT(target, ENODATA);
218 #endif
219
220 #ifdef ENODEV
221   NODE_DEFINE_CONSTANT(target, ENODEV);
222 #endif
223
224 #ifdef ENOENT
225   NODE_DEFINE_CONSTANT(target, ENOENT);
226 #endif
227
228 #ifdef ENOEXEC
229   NODE_DEFINE_CONSTANT(target, ENOEXEC);
230 #endif
231
232 #ifdef ENOLCK
233   NODE_DEFINE_CONSTANT(target, ENOLCK);
234 #endif
235
236 #ifdef ENOLINK
237   NODE_DEFINE_CONSTANT(target, ENOLINK);
238 #endif
239
240 #ifdef ENOMEM
241   NODE_DEFINE_CONSTANT(target, ENOMEM);
242 #endif
243
244 #ifdef ENOMSG
245   NODE_DEFINE_CONSTANT(target, ENOMSG);
246 #endif
247
248 #ifdef ENOPROTOOPT
249   NODE_DEFINE_CONSTANT(target, ENOPROTOOPT);
250 #endif
251
252 #ifdef ENOSPC
253   NODE_DEFINE_CONSTANT(target, ENOSPC);
254 #endif
255
256 #ifdef ENOSR
257   NODE_DEFINE_CONSTANT(target, ENOSR);
258 #endif
259
260 #ifdef ENOSTR
261   NODE_DEFINE_CONSTANT(target, ENOSTR);
262 #endif
263
264 #ifdef ENOSYS
265   NODE_DEFINE_CONSTANT(target, ENOSYS);
266 #endif
267
268 #ifdef ENOTCONN
269   NODE_DEFINE_CONSTANT(target, ENOTCONN);
270 #endif
271
272 #ifdef ENOTDIR
273   NODE_DEFINE_CONSTANT(target, ENOTDIR);
274 #endif
275
276 #ifdef ENOTEMPTY
277   NODE_DEFINE_CONSTANT(target, ENOTEMPTY);
278 #endif
279
280 #ifdef ENOTSOCK
281   NODE_DEFINE_CONSTANT(target, ENOTSOCK);
282 #endif
283
284 #ifdef ENOTSUP
285   NODE_DEFINE_CONSTANT(target, ENOTSUP);
286 #endif
287
288 #ifdef ENOTTY
289   NODE_DEFINE_CONSTANT(target, ENOTTY);
290 #endif
291
292 #ifdef ENXIO
293   NODE_DEFINE_CONSTANT(target, ENXIO);
294 #endif
295
296 #ifdef EOPNOTSUPP
297   NODE_DEFINE_CONSTANT(target, EOPNOTSUPP);
298 #endif
299
300 #ifdef EOVERFLOW
301   NODE_DEFINE_CONSTANT(target, EOVERFLOW);
302 #endif
303
304 #ifdef EPERM
305   NODE_DEFINE_CONSTANT(target, EPERM);
306 #endif
307
308 #ifdef EPIPE
309   NODE_DEFINE_CONSTANT(target, EPIPE);
310 #endif
311
312 #ifdef EPROTO
313   NODE_DEFINE_CONSTANT(target, EPROTO);
314 #endif
315
316 #ifdef EPROTONOSUPPORT
317   NODE_DEFINE_CONSTANT(target, EPROTONOSUPPORT);
318 #endif
319
320 #ifdef EPROTOTYPE
321   NODE_DEFINE_CONSTANT(target, EPROTOTYPE);
322 #endif
323
324 #ifdef ERANGE
325   NODE_DEFINE_CONSTANT(target, ERANGE);
326 #endif
327
328 #ifdef EROFS
329   NODE_DEFINE_CONSTANT(target, EROFS);
330 #endif
331
332 #ifdef ESPIPE
333   NODE_DEFINE_CONSTANT(target, ESPIPE);
334 #endif
335
336 #ifdef ESRCH
337   NODE_DEFINE_CONSTANT(target, ESRCH);
338 #endif
339
340 #ifdef ESTALE
341   NODE_DEFINE_CONSTANT(target, ESTALE);
342 #endif
343
344 #ifdef ETIME
345   NODE_DEFINE_CONSTANT(target, ETIME);
346 #endif
347
348 #ifdef ETIMEDOUT
349   NODE_DEFINE_CONSTANT(target, ETIMEDOUT);
350 #endif
351
352 #ifdef ETXTBSY
353   NODE_DEFINE_CONSTANT(target, ETXTBSY);
354 #endif
355
356 #ifdef EWOULDBLOCK
357   NODE_DEFINE_CONSTANT(target, EWOULDBLOCK);
358 #endif
359
360 #ifdef EXDEV
361   NODE_DEFINE_CONSTANT(target, EXDEV);
362 #endif
363 }
364
365 void DefineWindowsErrorConstants(Handle<Object> target) {
366 #ifdef WSAEINTR
367   NODE_DEFINE_CONSTANT(target, WSAEINTR);
368 #endif
369
370 #ifdef WSAEBADF
371   NODE_DEFINE_CONSTANT(target, WSAEBADF);
372 #endif
373
374 #ifdef WSAEACCES
375   NODE_DEFINE_CONSTANT(target, WSAEACCES);
376 #endif
377
378 #ifdef WSAEFAULT
379   NODE_DEFINE_CONSTANT(target, WSAEFAULT);
380 #endif
381
382 #ifdef WSAEINVAL
383   NODE_DEFINE_CONSTANT(target, WSAEINVAL);
384 #endif
385
386 #ifdef WSAEMFILE
387   NODE_DEFINE_CONSTANT(target, WSAEMFILE);
388 #endif
389
390 #ifdef WSAEWOULDBLOCK
391   NODE_DEFINE_CONSTANT(target, WSAEWOULDBLOCK);
392 #endif
393
394 #ifdef WSAEINPROGRESS
395   NODE_DEFINE_CONSTANT(target, WSAEINPROGRESS);
396 #endif
397
398 #ifdef WSAEALREADY
399   NODE_DEFINE_CONSTANT(target, WSAEALREADY);
400 #endif
401
402 #ifdef WSAENOTSOCK
403   NODE_DEFINE_CONSTANT(target, WSAENOTSOCK);
404 #endif
405
406 #ifdef WSAEDESTADDRREQ
407   NODE_DEFINE_CONSTANT(target, WSAEDESTADDRREQ);
408 #endif
409
410 #ifdef WSAEMSGSIZE
411   NODE_DEFINE_CONSTANT(target, WSAEMSGSIZE);
412 #endif
413
414 #ifdef WSAEPROTOTYPE
415   NODE_DEFINE_CONSTANT(target, WSAEPROTOTYPE);
416 #endif
417
418 #ifdef WSAENOPROTOOPT
419   NODE_DEFINE_CONSTANT(target, WSAENOPROTOOPT);
420 #endif
421
422 #ifdef WSAEPROTONOSUPPORT
423   NODE_DEFINE_CONSTANT(target, WSAEPROTONOSUPPORT);
424 #endif
425
426 #ifdef WSAESOCKTNOSUPPORT
427   NODE_DEFINE_CONSTANT(target, WSAESOCKTNOSUPPORT);
428 #endif
429
430 #ifdef WSAEOPNOTSUPP
431   NODE_DEFINE_CONSTANT(target, WSAEOPNOTSUPP);
432 #endif
433
434 #ifdef WSAEPFNOSUPPORT
435   NODE_DEFINE_CONSTANT(target, WSAEPFNOSUPPORT);
436 #endif
437
438 #ifdef WSAEAFNOSUPPORT
439   NODE_DEFINE_CONSTANT(target, WSAEAFNOSUPPORT);
440 #endif
441
442 #ifdef WSAEADDRINUSE
443   NODE_DEFINE_CONSTANT(target, WSAEADDRINUSE);
444 #endif
445
446 #ifdef WSAEADDRNOTAVAIL
447   NODE_DEFINE_CONSTANT(target, WSAEADDRNOTAVAIL);
448 #endif
449
450 #ifdef WSAENETDOWN
451   NODE_DEFINE_CONSTANT(target, WSAENETDOWN);
452 #endif
453
454 #ifdef WSAENETUNREACH
455   NODE_DEFINE_CONSTANT(target, WSAENETUNREACH);
456 #endif
457
458 #ifdef WSAENETRESET
459   NODE_DEFINE_CONSTANT(target, WSAENETRESET);
460 #endif
461
462 #ifdef WSAECONNABORTED
463   NODE_DEFINE_CONSTANT(target, WSAECONNABORTED);
464 #endif
465
466 #ifdef WSAECONNRESET
467   NODE_DEFINE_CONSTANT(target, WSAECONNRESET);
468 #endif
469
470 #ifdef WSAENOBUFS
471   NODE_DEFINE_CONSTANT(target, WSAENOBUFS);
472 #endif
473
474 #ifdef WSAEISCONN
475   NODE_DEFINE_CONSTANT(target, WSAEISCONN);
476 #endif
477
478 #ifdef WSAENOTCONN
479   NODE_DEFINE_CONSTANT(target, WSAENOTCONN);
480 #endif
481
482 #ifdef WSAESHUTDOWN
483   NODE_DEFINE_CONSTANT(target, WSAESHUTDOWN);
484 #endif
485
486 #ifdef WSAETOOMANYREFS
487   NODE_DEFINE_CONSTANT(target, WSAETOOMANYREFS);
488 #endif
489
490 #ifdef WSAETIMEDOUT
491   NODE_DEFINE_CONSTANT(target, WSAETIMEDOUT);
492 #endif
493
494 #ifdef WSAECONNREFUSED
495   NODE_DEFINE_CONSTANT(target, WSAECONNREFUSED);
496 #endif
497
498 #ifdef WSAELOOP
499   NODE_DEFINE_CONSTANT(target, WSAELOOP);
500 #endif
501
502 #ifdef WSAENAMETOOLONG
503   NODE_DEFINE_CONSTANT(target, WSAENAMETOOLONG);
504 #endif
505
506 #ifdef WSAEHOSTDOWN
507   NODE_DEFINE_CONSTANT(target, WSAEHOSTDOWN);
508 #endif
509
510 #ifdef WSAEHOSTUNREACH
511   NODE_DEFINE_CONSTANT(target, WSAEHOSTUNREACH);
512 #endif
513
514 #ifdef WSAENOTEMPTY
515   NODE_DEFINE_CONSTANT(target, WSAENOTEMPTY);
516 #endif
517
518 #ifdef WSAEPROCLIM
519   NODE_DEFINE_CONSTANT(target, WSAEPROCLIM);
520 #endif
521
522 #ifdef WSAEUSERS
523   NODE_DEFINE_CONSTANT(target, WSAEUSERS);
524 #endif
525
526 #ifdef WSAEDQUOT
527   NODE_DEFINE_CONSTANT(target, WSAEDQUOT);
528 #endif
529
530 #ifdef WSAESTALE
531   NODE_DEFINE_CONSTANT(target, WSAESTALE);
532 #endif
533
534 #ifdef WSAEREMOTE
535   NODE_DEFINE_CONSTANT(target, WSAEREMOTE);
536 #endif
537
538 #ifdef WSASYSNOTREADY
539   NODE_DEFINE_CONSTANT(target, WSASYSNOTREADY);
540 #endif
541
542 #ifdef WSAVERNOTSUPPORTED
543   NODE_DEFINE_CONSTANT(target, WSAVERNOTSUPPORTED);
544 #endif
545
546 #ifdef WSANOTINITIALISED
547   NODE_DEFINE_CONSTANT(target, WSANOTINITIALISED);
548 #endif
549
550 #ifdef WSAEDISCON
551   NODE_DEFINE_CONSTANT(target, WSAEDISCON);
552 #endif
553
554 #ifdef WSAENOMORE
555   NODE_DEFINE_CONSTANT(target, WSAENOMORE);
556 #endif
557
558 #ifdef WSAECANCELLED
559   NODE_DEFINE_CONSTANT(target, WSAECANCELLED);
560 #endif
561
562 #ifdef WSAEINVALIDPROCTABLE
563   NODE_DEFINE_CONSTANT(target, WSAEINVALIDPROCTABLE);
564 #endif
565
566 #ifdef WSAEINVALIDPROVIDER
567   NODE_DEFINE_CONSTANT(target, WSAEINVALIDPROVIDER);
568 #endif
569
570 #ifdef WSAEPROVIDERFAILEDINIT
571   NODE_DEFINE_CONSTANT(target, WSAEPROVIDERFAILEDINIT);
572 #endif
573
574 #ifdef WSASYSCALLFAILURE
575   NODE_DEFINE_CONSTANT(target, WSASYSCALLFAILURE);
576 #endif
577
578 #ifdef WSASERVICE_NOT_FOUND
579   NODE_DEFINE_CONSTANT(target, WSASERVICE_NOT_FOUND);
580 #endif
581
582 #ifdef WSATYPE_NOT_FOUND
583   NODE_DEFINE_CONSTANT(target, WSATYPE_NOT_FOUND);
584 #endif
585
586 #ifdef WSA_E_NO_MORE
587   NODE_DEFINE_CONSTANT(target, WSA_E_NO_MORE);
588 #endif
589
590 #ifdef WSA_E_CANCELLED
591   NODE_DEFINE_CONSTANT(target, WSA_E_CANCELLED);
592 #endif
593
594 #ifdef WSAEREFUSED
595   NODE_DEFINE_CONSTANT(target, WSAEREFUSED);
596 #endif
597 }
598
599 void DefineSignalConstants(Handle<Object> target) {
600 #ifdef SIGHUP
601   NODE_DEFINE_CONSTANT(target, SIGHUP);
602 #endif
603
604 #ifdef SIGINT
605   NODE_DEFINE_CONSTANT(target, SIGINT);
606 #endif
607
608 #ifdef SIGQUIT
609   NODE_DEFINE_CONSTANT(target, SIGQUIT);
610 #endif
611
612 #ifdef SIGILL
613   NODE_DEFINE_CONSTANT(target, SIGILL);
614 #endif
615
616 #ifdef SIGTRAP
617   NODE_DEFINE_CONSTANT(target, SIGTRAP);
618 #endif
619
620 #ifdef SIGABRT
621   NODE_DEFINE_CONSTANT(target, SIGABRT);
622 #endif
623
624 #ifdef SIGIOT
625   NODE_DEFINE_CONSTANT(target, SIGIOT);
626 #endif
627
628 #ifdef SIGBUS
629   NODE_DEFINE_CONSTANT(target, SIGBUS);
630 #endif
631
632 #ifdef SIGFPE
633   NODE_DEFINE_CONSTANT(target, SIGFPE);
634 #endif
635
636 #ifdef SIGKILL
637   NODE_DEFINE_CONSTANT(target, SIGKILL);
638 #endif
639
640 #ifdef SIGUSR1
641   NODE_DEFINE_CONSTANT(target, SIGUSR1);
642 #endif
643
644 #ifdef SIGSEGV
645   NODE_DEFINE_CONSTANT(target, SIGSEGV);
646 #endif
647
648 #ifdef SIGUSR2
649   NODE_DEFINE_CONSTANT(target, SIGUSR2);
650 #endif
651
652 #ifdef SIGPIPE
653   NODE_DEFINE_CONSTANT(target, SIGPIPE);
654 #endif
655
656 #ifdef SIGALRM
657   NODE_DEFINE_CONSTANT(target, SIGALRM);
658 #endif
659
660   NODE_DEFINE_CONSTANT(target, SIGTERM);
661
662 #ifdef SIGCHLD
663   NODE_DEFINE_CONSTANT(target, SIGCHLD);
664 #endif
665
666 #ifdef SIGSTKFLT
667   NODE_DEFINE_CONSTANT(target, SIGSTKFLT);
668 #endif
669
670
671 #ifdef SIGCONT
672   NODE_DEFINE_CONSTANT(target, SIGCONT);
673 #endif
674
675 #ifdef SIGSTOP
676   NODE_DEFINE_CONSTANT(target, SIGSTOP);
677 #endif
678
679 #ifdef SIGTSTP
680   NODE_DEFINE_CONSTANT(target, SIGTSTP);
681 #endif
682
683 #ifdef SIGBREAK
684   NODE_DEFINE_CONSTANT(target, SIGBREAK);
685 #endif
686
687 #ifdef SIGTTIN
688   NODE_DEFINE_CONSTANT(target, SIGTTIN);
689 #endif
690
691 #ifdef SIGTTOU
692   NODE_DEFINE_CONSTANT(target, SIGTTOU);
693 #endif
694
695 #ifdef SIGURG
696   NODE_DEFINE_CONSTANT(target, SIGURG);
697 #endif
698
699 #ifdef SIGXCPU
700   NODE_DEFINE_CONSTANT(target, SIGXCPU);
701 #endif
702
703 #ifdef SIGXFSZ
704   NODE_DEFINE_CONSTANT(target, SIGXFSZ);
705 #endif
706
707 #ifdef SIGVTALRM
708   NODE_DEFINE_CONSTANT(target, SIGVTALRM);
709 #endif
710
711 #ifdef SIGPROF
712   NODE_DEFINE_CONSTANT(target, SIGPROF);
713 #endif
714
715 #ifdef SIGWINCH
716   NODE_DEFINE_CONSTANT(target, SIGWINCH);
717 #endif
718
719 #ifdef SIGIO
720   NODE_DEFINE_CONSTANT(target, SIGIO);
721 #endif
722
723 #ifdef SIGPOLL
724   NODE_DEFINE_CONSTANT(target, SIGPOLL);
725 #endif
726
727 #ifdef SIGLOST
728   NODE_DEFINE_CONSTANT(target, SIGLOST);
729 #endif
730
731 #ifdef SIGPWR
732   NODE_DEFINE_CONSTANT(target, SIGPWR);
733 #endif
734
735 #ifdef SIGSYS
736   NODE_DEFINE_CONSTANT(target, SIGSYS);
737 #endif
738
739 #ifdef SIGUNUSED
740   NODE_DEFINE_CONSTANT(target, SIGUNUSED);
741 #endif
742 }
743
744 void DefineOpenSSLConstants(Handle<Object> target) {
745 #ifdef SSL_OP_ALL
746     NODE_DEFINE_CONSTANT(target, SSL_OP_ALL);
747 #endif
748
749 #ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
750     NODE_DEFINE_CONSTANT(target, SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION);
751 #endif
752
753 #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE
754     NODE_DEFINE_CONSTANT(target, SSL_OP_CIPHER_SERVER_PREFERENCE);
755 #endif
756
757 #ifdef SSL_OP_CISCO_ANYCONNECT
758     NODE_DEFINE_CONSTANT(target, SSL_OP_CISCO_ANYCONNECT);
759 #endif
760
761 #ifdef SSL_OP_COOKIE_EXCHANGE
762     NODE_DEFINE_CONSTANT(target, SSL_OP_COOKIE_EXCHANGE);
763 #endif
764
765 #ifdef SSL_OP_CRYPTOPRO_TLSEXT_BUG
766     NODE_DEFINE_CONSTANT(target, SSL_OP_CRYPTOPRO_TLSEXT_BUG);
767 #endif
768
769 #ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
770     NODE_DEFINE_CONSTANT(target, SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS);
771 #endif
772
773 #ifdef SSL_OP_EPHEMERAL_RSA
774     NODE_DEFINE_CONSTANT(target, SSL_OP_EPHEMERAL_RSA);
775 #endif
776
777 #ifdef SSL_OP_LEGACY_SERVER_CONNECT
778     NODE_DEFINE_CONSTANT(target, SSL_OP_LEGACY_SERVER_CONNECT);
779 #endif
780
781 #ifdef SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
782     NODE_DEFINE_CONSTANT(target, SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER);
783 #endif
784
785 #ifdef SSL_OP_MICROSOFT_SESS_ID_BUG
786     NODE_DEFINE_CONSTANT(target, SSL_OP_MICROSOFT_SESS_ID_BUG);
787 #endif
788
789 #ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING
790     NODE_DEFINE_CONSTANT(target, SSL_OP_MSIE_SSLV2_RSA_PADDING);
791 #endif
792
793 #ifdef SSL_OP_NETSCAPE_CA_DN_BUG
794     NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_CA_DN_BUG);
795 #endif
796
797 #ifdef SSL_OP_NETSCAPE_CHALLENGE_BUG
798     NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_CHALLENGE_BUG);
799 #endif
800
801 #ifdef SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
802     NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
803 #endif
804
805 #ifdef SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
806     NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);
807 #endif
808
809 #ifdef SSL_OP_NO_COMPRESSION
810     NODE_DEFINE_CONSTANT(target, SSL_OP_NO_COMPRESSION);
811 #endif
812
813 #ifdef SSL_OP_NO_QUERY_MTU
814     NODE_DEFINE_CONSTANT(target, SSL_OP_NO_QUERY_MTU);
815 #endif
816
817 #ifdef SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
818     NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
819 #endif
820
821 #ifdef SSL_OP_NO_SSLv2
822     NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv2);
823 #endif
824
825 #ifdef SSL_OP_NO_SSLv3
826     NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv3);
827 #endif
828
829 #ifdef SSL_OP_NO_TICKET
830     NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TICKET);
831 #endif
832
833 #ifdef SSL_OP_NO_TLSv1
834     NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1);
835 #endif
836
837 #ifdef SSL_OP_NO_TLSv1_1
838     NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1_1);
839 #endif
840
841 #ifdef SSL_OP_NO_TLSv1_2
842     NODE_DEFINE_CONSTANT(target, SSL_OP_NO_TLSv1_2);
843 #endif
844
845 #ifdef SSL_OP_PKCS1_CHECK_1
846     NODE_DEFINE_CONSTANT(target, SSL_OP_PKCS1_CHECK_1);
847 #endif
848
849 #ifdef SSL_OP_PKCS1_CHECK_2
850     NODE_DEFINE_CONSTANT(target, SSL_OP_PKCS1_CHECK_2);
851 #endif
852
853 #ifdef SSL_OP_SINGLE_DH_USE
854     NODE_DEFINE_CONSTANT(target, SSL_OP_SINGLE_DH_USE);
855 #endif
856
857 #ifdef SSL_OP_SINGLE_ECDH_USE
858     NODE_DEFINE_CONSTANT(target, SSL_OP_SINGLE_ECDH_USE);
859 #endif
860
861 #ifdef SSL_OP_SSLEAY_080_CLIENT_DH_BUG
862     NODE_DEFINE_CONSTANT(target, SSL_OP_SSLEAY_080_CLIENT_DH_BUG);
863 #endif
864
865 #ifdef SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
866     NODE_DEFINE_CONSTANT(target, SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG);
867 #endif
868
869 #ifdef SSL_OP_TLS_BLOCK_PADDING_BUG
870     NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_BLOCK_PADDING_BUG);
871 #endif
872
873 #ifdef SSL_OP_TLS_D5_BUG
874     NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_D5_BUG);
875 #endif
876
877 #ifdef SSL_OP_TLS_ROLLBACK_BUG
878     NODE_DEFINE_CONSTANT(target, SSL_OP_TLS_ROLLBACK_BUG);
879 #endif
880
881 # ifndef OPENSSL_NO_ENGINE
882
883 # ifdef ENGINE_METHOD_DSA
884     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_DSA);
885 # endif
886
887 # ifdef ENGINE_METHOD_DH
888     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_DH);
889 # endif
890
891 # ifdef ENGINE_METHOD_RAND
892     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_RAND);
893 # endif
894
895 # ifdef ENGINE_METHOD_ECDH
896     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_ECDH);
897 # endif
898
899 # ifdef ENGINE_METHOD_ECDSA
900     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_ECDSA);
901 # endif
902
903 # ifdef ENGINE_METHOD_CIPHERS
904     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_CIPHERS);
905 # endif
906
907 # ifdef ENGINE_METHOD_DIGESTS
908     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_DIGESTS);
909 # endif
910
911 # ifdef ENGINE_METHOD_STORE
912     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_STORE);
913 # endif
914
915 # ifdef ENGINE_METHOD_PKEY_METHS
916     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_PKEY_METHS);
917 # endif
918
919 # ifdef ENGINE_METHOD_PKEY_ASN1_METHS
920     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_PKEY_ASN1_METHS);
921 # endif
922
923 # ifdef ENGINE_METHOD_ALL
924     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_ALL);
925 # endif
926
927 # ifdef ENGINE_METHOD_NONE
928     NODE_DEFINE_CONSTANT(target, ENGINE_METHOD_NONE);
929 # endif
930
931 # endif  // !OPENSSL_NO_ENGINE
932
933 #ifdef DH_CHECK_P_NOT_SAFE_PRIME
934     NODE_DEFINE_CONSTANT(target, DH_CHECK_P_NOT_SAFE_PRIME);
935 #endif
936
937 #ifdef DH_CHECK_P_NOT_PRIME
938     NODE_DEFINE_CONSTANT(target, DH_CHECK_P_NOT_PRIME);
939 #endif
940
941 #ifdef DH_UNABLE_TO_CHECK_GENERATOR
942     NODE_DEFINE_CONSTANT(target, DH_UNABLE_TO_CHECK_GENERATOR);
943 #endif
944
945 #ifdef DH_NOT_SUITABLE_GENERATOR
946     NODE_DEFINE_CONSTANT(target, DH_NOT_SUITABLE_GENERATOR);
947 #endif
948
949 #ifdef OPENSSL_NPN_NEGOTIATED
950 #define NPN_ENABLED 1
951     NODE_DEFINE_CONSTANT(target, NPN_ENABLED);
952 #endif
953
954 #ifdef RSA_PKCS1_PADDING
955     NODE_DEFINE_CONSTANT(target, RSA_PKCS1_PADDING);
956 #endif
957
958 #ifdef RSA_SSLV23_PADDING
959     NODE_DEFINE_CONSTANT(target, RSA_SSLV23_PADDING);
960 #endif
961
962 #ifdef RSA_NO_PADDING
963     NODE_DEFINE_CONSTANT(target, RSA_NO_PADDING);
964 #endif
965
966 #ifdef RSA_PKCS1_OAEP_PADDING
967     NODE_DEFINE_CONSTANT(target, RSA_PKCS1_OAEP_PADDING);
968 #endif
969
970 #ifdef RSA_X931_PADDING
971     NODE_DEFINE_CONSTANT(target, RSA_X931_PADDING);
972 #endif
973
974 #ifdef RSA_PKCS1_PSS_PADDING
975     NODE_DEFINE_CONSTANT(target, RSA_PKCS1_PSS_PADDING);
976 #endif
977 }
978
979 void DefineSystemConstants(Handle<Object> target) {
980   // file access modes
981   NODE_DEFINE_CONSTANT(target, O_RDONLY);
982   NODE_DEFINE_CONSTANT(target, O_WRONLY);
983   NODE_DEFINE_CONSTANT(target, O_RDWR);
984
985   NODE_DEFINE_CONSTANT(target, S_IFMT);
986   NODE_DEFINE_CONSTANT(target, S_IFREG);
987   NODE_DEFINE_CONSTANT(target, S_IFDIR);
988   NODE_DEFINE_CONSTANT(target, S_IFCHR);
989 #ifdef S_IFBLK
990   NODE_DEFINE_CONSTANT(target, S_IFBLK);
991 #endif
992
993 #ifdef S_IFIFO
994   NODE_DEFINE_CONSTANT(target, S_IFIFO);
995 #endif
996
997 #ifdef S_IFLNK
998   NODE_DEFINE_CONSTANT(target, S_IFLNK);
999 #endif
1000
1001 #ifdef S_IFSOCK
1002   NODE_DEFINE_CONSTANT(target, S_IFSOCK);
1003 #endif
1004
1005 #ifdef O_CREAT
1006   NODE_DEFINE_CONSTANT(target, O_CREAT);
1007 #endif
1008
1009 #ifdef O_EXCL
1010   NODE_DEFINE_CONSTANT(target, O_EXCL);
1011 #endif
1012
1013 #ifdef O_NOCTTY
1014   NODE_DEFINE_CONSTANT(target, O_NOCTTY);
1015 #endif
1016
1017 #ifdef O_TRUNC
1018   NODE_DEFINE_CONSTANT(target, O_TRUNC);
1019 #endif
1020
1021 #ifdef O_APPEND
1022   NODE_DEFINE_CONSTANT(target, O_APPEND);
1023 #endif
1024
1025 #ifdef O_DIRECTORY
1026   NODE_DEFINE_CONSTANT(target, O_DIRECTORY);
1027 #endif
1028
1029 #ifdef O_EXCL
1030   NODE_DEFINE_CONSTANT(target, O_EXCL);
1031 #endif
1032
1033 #ifdef O_NOFOLLOW
1034   NODE_DEFINE_CONSTANT(target, O_NOFOLLOW);
1035 #endif
1036
1037 #ifdef O_SYNC
1038   NODE_DEFINE_CONSTANT(target, O_SYNC);
1039 #endif
1040
1041 #ifdef O_SYMLINK
1042   NODE_DEFINE_CONSTANT(target, O_SYMLINK);
1043 #endif
1044
1045 #ifdef O_DIRECT
1046   NODE_DEFINE_CONSTANT(target, O_DIRECT);
1047 #endif
1048
1049 #ifdef O_NONBLOCK
1050   NODE_DEFINE_CONSTANT(target, O_NONBLOCK);
1051 #endif
1052
1053 #ifdef S_IRWXU
1054   NODE_DEFINE_CONSTANT(target, S_IRWXU);
1055 #endif
1056
1057 #ifdef S_IRUSR
1058   NODE_DEFINE_CONSTANT(target, S_IRUSR);
1059 #endif
1060
1061 #ifdef S_IWUSR
1062   NODE_DEFINE_CONSTANT(target, S_IWUSR);
1063 #endif
1064
1065 #ifdef S_IXUSR
1066   NODE_DEFINE_CONSTANT(target, S_IXUSR);
1067 #endif
1068
1069 #ifdef S_IRWXG
1070   NODE_DEFINE_CONSTANT(target, S_IRWXG);
1071 #endif
1072
1073 #ifdef S_IRGRP
1074   NODE_DEFINE_CONSTANT(target, S_IRGRP);
1075 #endif
1076
1077 #ifdef S_IWGRP
1078   NODE_DEFINE_CONSTANT(target, S_IWGRP);
1079 #endif
1080
1081 #ifdef S_IXGRP
1082   NODE_DEFINE_CONSTANT(target, S_IXGRP);
1083 #endif
1084
1085 #ifdef S_IRWXO
1086   NODE_DEFINE_CONSTANT(target, S_IRWXO);
1087 #endif
1088
1089 #ifdef S_IROTH
1090   NODE_DEFINE_CONSTANT(target, S_IROTH);
1091 #endif
1092
1093 #ifdef S_IWOTH
1094   NODE_DEFINE_CONSTANT(target, S_IWOTH);
1095 #endif
1096
1097 #ifdef S_IXOTH
1098   NODE_DEFINE_CONSTANT(target, S_IXOTH);
1099 #endif
1100 }
1101
1102 void DefineUVConstants(Handle<Object> target) {
1103   NODE_DEFINE_CONSTANT(target, UV_UDP_REUSEADDR);
1104 }
1105
1106 void DefineConstants(Handle<Object> target) {
1107   DefineErrnoConstants(target);
1108   DefineWindowsErrorConstants(target);
1109   DefineSignalConstants(target);
1110   DefineOpenSSLConstants(target);
1111   DefineSystemConstants(target);
1112   DefineUVConstants(target);
1113 }
1114
1115 }  // namespace node