⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perlos2.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 5 页
字号:
.Ve.SpThis should create an executable \fI./perl.exe\fR with all the statically loadedextensions built in.  Compare the generated \fIperlmain.c\fR files to make surethat during the iterations the number of loaded extensions only increases.Rename \fI./perl.exe\fR to \fIperl_5.8.2.exe\fR on \f(CW\*(C`PATH\*(C'\fR..SpWhen it converges, you got a functional variant of \fIperl_5.8.2.exe\fR; copy itto \f(CW\*(C`perl_.exe\*(C'\fR.  You are done with generation of the local Perl installation..IP "8." 4Make sure that the installed modules are actually installed in the locationof the new Perl, and are not inherited from entries of \f(CW@INC\fR given forinheritance from the older versions of Perl: set \f(CW\*(C`PERLLIB_582_PREFIX\*(C'\fR toredirect the new version of Perl to a new location, and copy the installedfiles to this new location.  Redo the tests to make sure that the versions ofmodules inherited from older versions of Perl are not needed..SpActually, the log output of pod2ipf during the step 6 gives a very detailedinfo about which modules are loaded from which place; so you may use it asan additional verification tool..SpCheck that some temporary files did not make into the perl install tree.Run something like this.Sp.Vb 1\&  pfind . \-f "!(/\e.(pm|pl|ix|al|h|a|lib|txt|pod|imp|bs|dll|ld|bs|inc|xbm|yml|cgi|uu|e2x|skip|packlist|eg|cfg|html|pub|enc|all|ini|po|pot)$/i or /^\ew+$/") | less.Ve.Spin the install tree (both top one and \fIsitelib\fR one)..SpCompress all the DLLs with \fIlxlite\fR.  The tiny \fI.exe\fR can be compressed with\&\f(CW\*(C`/c:max\*(C'\fR (the bug only appears when there is a fixup in the last 6 bytes of apage (?); since the tiny executables are much smaller than a page, the bugwill not hit).  Do not compress \f(CW\*(C`perl_.exe\*(C'\fR \- it would not work under \s-1DOS\s0..IP "9." 4Now you can generate the binary distribution.  This is done by running thetest of the \s-1CPAN\s0 distribution \f(CW\*(C`OS2::SoftInstaller\*(C'\fR.  Tune up the file\&\fItest.pl\fR to suit the layout of current version of Perl first.  Do notforget to pack the necessary external DLLs accordingly.  Include thedescription of the bugs and test suite failures you could not fix.  Includethe small-stack versions of Perl executables from Perl build directory..SpInclude \fIperl5.def\fR so that people can relink the perl \s-1DLL\s0 preservingthe binary compatibility, or can create compatibility DLLs.  Include the difffiles (\f(CW\*(C`diff \-pu old new\*(C'\fR) of fixes you did so that people can rebuild yourversion.  Include \fIperl5.map\fR so that one can use remote debugging..IP "10." 4Share what you did with the other people.  Relax.  Enjoy fruits of your work..IP "11." 4Brace yourself for thanks, bug reports, hate mail and spam coming as resultof the previous step.  No good deed should remain unpunished!.SH "Building custom \fI.EXE\fP files".IX Header "Building custom .EXE files"The Perl executables can be easily rebuilt at any moment.  Moreover, one canuse the \fIembedding\fR interface (see perlembed) to make very customizedexecutables..Sh "Making executables with a custom collection of statically loaded extensions".IX Subsection "Making executables with a custom collection of statically loaded extensions"It is a little bit easier to do so while \fIdecreasing\fR the list of staticallyloaded extensions.  We discuss this case only here..IP "1." 4Change to an empty directory, and create a placeholder <Makefile.PL>:.Sp.Vb 2\&  use ExtUtils::MakeMaker;\&  WriteMakefile NAME => \*(Aqdummy\*(Aq;.Ve.IP "2." 4Run it with the flavor of Perl (\fIperl.exe\fR or \fIperl_.exe\fR) you want torebuild..Sp.Vb 1\&  perl_ Makefile.PL.Ve.IP "3." 4Ask it to create new Perl executable:.Sp.Vb 1\&  make perl.Ve.Sp(you may need to manually add \f(CW\*(C`PERLTYPE=\-DPERL_CORE\*(C'\fR to this commandline onsome versions of Perl; the symptom is that the command-line globbing does notwork from \s-1OS/2\s0 shells with the newly-compiled executable; check with.Sp.Vb 1\&  .\eperl.exe \-wle "print for @ARGV" *.Ve.Sp)..IP "4." 4The previous step created \fIperlmain.c\fR which contains a list of \fInewXS()\fR callsnear the end.  Removing unnecessary calls, and rerunning.Sp.Vb 1\&  make perl.Ve.Spwill produce a customized executable..Sh "Making executables with a custom search-paths".IX Subsection "Making executables with a custom search-paths"The default perl executable is flexible enough to support most usages.However, one may want something yet more flexible; for example, one may wantto find Perl \s-1DLL\s0 relatively to the location of the \s-1EXE\s0 file; or one may wantto ignore the environment when setting the Perl-library search patch, etc..PPIf you fill comfortable with \fIembedding\fR interface (see perlembed), suchthings are easy to do repeating the steps outlined in \*(L"Makingexecutables with a custom collection of statically loaded extensions\*(R", anddoing more comprehensive edits to \fImain()\fR of \fIperlmain.c\fR.  The people withlittle desire to understand Perl can just rename \fImain()\fR, and do necessarymodification in a custom \fImain()\fR which calls the renamed function in appropriatetime..PPHowever, there is a third way: perl \s-1DLL\s0 exports the \fImain()\fR function and severalcallbacks to customize the search path.  Below is a complete example of a\&\*(L"Perl loader\*(R" which.IP "1." 4Looks for Perl \s-1DLL\s0 in the directory \f(CW\*(C`$exedir/../dll\*(C'\fR;.IP "2." 4Prepends the above directory to \f(CW\*(C`BEGINLIBPATH\*(C'\fR;.IP "3." 4Fails if the Perl \s-1DLL\s0 found via \f(CW\*(C`BEGINLIBPATH\*(C'\fR is different from what wasloaded on step 1; e.g., another process could have loaded it from \f(CW\*(C`LIBPATH\*(C'\fRor from a different value of \f(CW\*(C`BEGINLIBPATH\*(C'\fR.  In these cases one needs tomodify the setting of the system so that this other process either does notrun, or loads the \s-1DLL\s0 from \f(CW\*(C`BEGINLIBPATH\*(C'\fR with \f(CW\*(C`LIBPATHSTRICT=T\*(C'\fR (availablewith kernels after September 2000)..IP "4." 4Loads Perl library from \f(CW\*(C`$exedir/../dll/lib/\*(C'\fR..IP "5." 4Uses Bourne shell from \f(CW\*(C`$exedir/../dll/sh/ksh.exe\*(C'\fR..PPFor best results compile the C file below with the same options as the Perl\&\s-1DLL\s0.  However, a lot of functionality will work even if the executable is notan \s-1EMX\s0 applications, e.g., if compiled with.PP.Vb 1\&  gcc \-Wall \-DDOSISH \-DOS2=1 \-O2 \-s \-Zomf \-Zsys perl\-starter.c \-DPERL_DLL_BASENAME=\e"perl312F\e" \-Zstack 8192 \-Zlinker /PM:VIO.Ve.PPHere is the sample C file:.PP.Vb 5\&  #define INCL_DOS\&  #define INCL_NOPM\&  /* These are needed for compile if os2.h includes os2tk.h, not os2emx.h */\&  #define INCL_DOSPROCESS\&  #include <os2.h>\&\&  #include "EXTERN.h"\&  #define PERL_IN_MINIPERLMAIN_C\&  #include "perl.h"\&\&  static char *me;\&  HMODULE handle;\&\&  static void\&  die_with(char *msg1, char *msg2, char *msg3, char *msg4)\&  {\&     ULONG c;\&     char *s = " error: ";\&\&     DosWrite(2, me, strlen(me), &c);\&     DosWrite(2, s, strlen(s), &c);\&     DosWrite(2, msg1, strlen(msg1), &c);\&     DosWrite(2, msg2, strlen(msg2), &c);\&     DosWrite(2, msg3, strlen(msg3), &c);\&     DosWrite(2, msg4, strlen(msg4), &c);\&     DosWrite(2, "\er\en", 2, &c);\&     exit(255);\&  }\&\&  typedef ULONG (*fill_extLibpath_t)(int type, char *pre, char *post, int replace, char *msg);\&  typedef int (*main_t)(int type, char *argv[], char *env[]);\&  typedef int (*handler_t)(void* data, int which);\&\&  #ifndef PERL_DLL_BASENAME\&  #  define PERL_DLL_BASENAME "perl"\&  #endif\&\&  static HMODULE\&  load_perl_dll(char *basename)\&  {\&      char buf[300], fail[260];\&      STRLEN l, dirl;\&      fill_extLibpath_t f;\&      ULONG rc_fullname;\&      HMODULE handle, handle1;\&\&      if (_execname(buf, sizeof(buf) \- 13) != 0)\&          die_with("Can\*(Aqt find full path: ", strerror(errno), "", "");\&      /* XXXX Fill \`me\*(Aq with new value */\&      l = strlen(buf);\&      while (l && buf[l\-1] != \*(Aq/\*(Aq && buf[l\-1] != \*(Aq\e\e\*(Aq)\&          l\-\-;\&      dirl = l \- 1;\&      strcpy(buf + l, basename);\&      l += strlen(basename);\&      strcpy(buf + l, ".dll");\&      if ( (rc_fullname = DosLoadModule(fail, sizeof fail, buf, &handle)) != 0\&           && DosLoadModule(fail, sizeof fail, basename, &handle) != 0 )\&          die_with("Can\*(Aqt load DLL ", buf, "", "");\&      if (rc_fullname)\&          return handle;                /* was loaded with short name; all is fine */\&      if (DosQueryProcAddr(handle, 0, "fill_extLibpath", (PFN*)&f))\&          die_with(buf, ": DLL exports no symbol ", "fill_extLibpath", "");\&      buf[dirl] = 0;\&      if (f(0 /*BEGINLIBPATH*/, buf /* prepend */, NULL /* append */,\&            0 /* keep old value */, me))\&          die_with(me, ": prepending BEGINLIBPATH", "", "");\&      if (DosLoadModule(fail, sizeof fail, basename, &handle1) != 0)\&          die_with(me, ": finding perl DLL again via BEGINLIBPATH", "", "");\&      buf[dirl] = \*(Aq\e\e\*(Aq;     \&      if (handle1 != handle) {\&          if (DosQueryModuleName(handle1, sizeof(fail), fail))\&              strcpy(fail, "???");\&          die_with(buf, ":\en\etperl DLL via BEGINLIBPATH is different: \en\et",\&                   fail,\&                   "\en\etYou may need to manipulate global BEGINLIBPATH and LIBPATHSTRICT"\&                   "\en\etso that the other copy is loaded via BEGINLIBPATH.");\&      }\&      return handle;\&  }\&\&  int\&  main(int argc, char **argv, char **env)\&  {\&      main_t f;\&      handler_t h;\&    \&      me = argv[0];\&      /**/\&      handle = load_perl_dll(PERL_DLL_BASENAME);\&\&      if (DosQueryProcAddr(handle, 0, "Perl_OS2_handler_install", (PFN*)&h))\&          die_with(PERL_DLL_BASENAME, ": DLL exports no symbol ", "Perl_OS2_handler_install", "");\&      if ( !h((void *)"~installprefix", Perlos2_handler_perllib_from)\&           || !h((void *)"~dll", Perlos2_handler_perllib_to)\&           || !h((void *)"~dll/sh/ksh.exe", Perlos2_handler_perl_sh) )\&          die_with(PERL_DLL_BASENAME, ": Can\*(Aqt install @INC manglers", "", "");\&\&      if (DosQueryProcAddr(handle, 0, "dll_perlmain", (PFN*)&f))\&          die_with(PERL_DLL_BASENAME, ": DLL exports no symbol ", "dll_perlmain", "");\&      return f(argc, argv, env);\&  }.Ve.SH "Build FAQ".IX Header "Build FAQ".ie n .Sh "Some ""/""\fP became \f(CW""\e"" in pdksh.".el .Sh "Some \f(CW/\fP became \f(CW\e\fP in pdksh.".IX Subsection "Some / became  in pdksh."You have a very old pdksh. See Prerequisites..ie n .Sh "\*(Aqerrno\*(Aq \- unresolved external".el .Sh "\f(CW\*(Aqerrno\*(Aq\fP \- unresolved external".IX Subsection "errno - unresolved external"You do not have MT-safe \fIdb.lib\fR. See Prerequisites..Sh "Problems with tr or sed".IX Subsection "Problems with tr or sed"reported with very old version of tr and sed..Sh "Some problem (forget which ;\-)".IX Subsection "Some problem (forget which ;-)"You have an older version of \fIperl.dll\fR on your \s-1LIBPATH\s0, whichbroke the build of extensions..Sh "Library ... not found".IX Subsection "Library ... not found"You did not run \f(CW\*(C`omflibs\*(C'\fR. See Prerequisites..Sh "Segfault in make".IX Subsection "Segfault in make"You use an old version of \s-1GNU\s0 make. See Prerequisites..Sh "op/sprintf test failure".IX Subsection "op/sprintf test failure"This can result from a bug in emx sprintf which was fixed in 0.9d fix 03..SH "Specific (mis)features of OS/2 port".IX Header "Specific (mis)features of OS/2 port".ie n .Sh """setpriority""\fP, \f(CW""getpriority""".el .Sh "\f(CWsetpriority\fP, \f(CWgetpriority\fP".IX Subsection "setpriority, getpriority"Note that these functions are compatible with *nix, not with the olderports of '94 \- 95. The priorities are absolute, go from 32 to \-95,lower is quicker. 0 is the default priority..PP\&\fB\s-1WARNING\s0\fR.  Calling \f(CW\*(C`getpriority\*(C'\fR on a non-existing process could lockthe system before Warp3 fixpak22.  Starting with Warp3, Perl will usea workaround: it aborts \fIgetpriority()\fR if the process is not present.This is not possible on older versions \f(CW\*(C`2.*\*(C'\fR, and has a racecondition anyway..ie n .Sh """system()""".el .Sh "\f(CWsystem()\fP".IX Subsection "system()"Multi-argument form of \f(CW\*(C`system()\*(C'\fR allows an additional numericargument. The meaning of this argument is described inOS2::Process..PPWhen finding a program to run, Perl first asks the \s-1OS\s0 to look for executableson \f(CW\*(C`PATH\*(C'\fR (\s-1OS/2\s0 adds extension \fI.exe\fR if no extension is present).If not found, it looks for a script with possible extensions added in this order: no extension, \fI.cmd\fR, \fI.btm\fR, \&\fI.bat\fR, \fI.pl\fR.  If found, Perl checks the start of the file for magicstrings \f(CW"#!"\fR and \f(CW"extproc "\fR.  If found, Perl uses the rest of thefirst line as the beginning of the command line to run this script.  Theonly mangling done to the first line is extraction of arguments (currentlyup to 3), and ignoring of the path-part of the \*(L"interpreter\*(R" name if it can'tbe found using the full path..PPE.g., \f(CW\*(C`system \*(Aqfoo\*(Aq, \*(Aqbar\*(Aq, \*(Aqbaz\*(Aq\*(C'\fR may lead Perl to finding\&\fIC:/emx/bin/foo.cmd\fR with the first line being.PP.Vb 1\& extproc /bin/bash    \-x   \-c.Ve.PPIf \fI/bin/bash.exe\fR is not found, then Perl looks for an executable \fIbash.exe\fR on\&\f(CW\*(C`PATH\*(C'\fR.  If found in \fIC:/emx.add/bin/bash.exe\fR, then the above \fIsystem()\fR istranslated to.PP.Vb 1\&  system qw(C:/emx.add/bin/bash.exe \-x \-c C:/emx/bin/foo.cmd bar baz).Ve.PPOne additional translation is performed: instead of \fI/bin/sh\fR Perl usesthe hardwired-or-customized shell (see \f(CW"PERL_SH_DIR"\fR)..PPThe above search 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -