Página principal | Jerarquía de la clase | Lista alfabética | Lista de componentes | Lista de archivos | Miembros de las clases | Archivos de los miembros | Páginas relacionadas

jed_defs.C

Ir a la documentación de este archivo.
00001 //===========================================================================
00002 //= jeddefs.cpp                                                Agosto, 1996 =
00003 //=-------------------------------------------------------------------------=
00004 //= Macros y tipos comunes. Es importante que antes de hacer cualquier cosa =
00005 //= todos y cada uno de los modulos del proyecto incluyan este .h, porque   =
00006 //= aqui se definen varios detalles vitales para facilitar la portabilidad  =
00007 //= del codigo, al igual que ciertas constantes y macros comunes.           =
00008 //=-------------------------------------------------------------------------=
00009 //= Autor original: Oscar J. Chavarro G.  A.K.A. JEDILINK. Copyright (c),   =
00010 //= 1997 - 2003, oscarchavarro@hotmail.com                                  =
00011 //= AQUYNZA es software libre, y se rige bajo los terminos de la licencia   =
00012 //= LGPL de GNU (http://www.gnu.org). Para mayor informacion respecto a la  =
00013 //= licencia de uso, consulte el archivo ./doc/LICENCIA en la distribucion. =
00014 //===========================================================================
00015 
00016 #include "jed_defs.h"
00017 
00018 #if PLATAFORMA == CRAY_J90
00019 void usleep(int /*s*/)
00020 {
00021     static BOOLEAN ya = FALSE;
00022 
00023     if ( !ya ) {
00024         printf("<WARNING>: En CRAY no hay usleep!\n");
00025         ya = TRUE;
00026     }
00027 }
00028 #endif
00029 
00030 #if PLATAFORMA == ALPHA
00031 BYTE _MI_byte;  
00032 #endif
00033 
00034 //===========================================================================
00035 //= Funciones utilitarias                                                   =
00036 //===========================================================================
00037 
00038 void
00039 DEG2gms(double angulo, float *grados, float *minutos, float *segundos)
00046 {
00047     int fracbase = 3600;
00048 
00049     /* save whether it's negative but do all the rest with a positive */
00050     int negativo = (angulo < 0);
00051     if ( negativo ) angulo = -angulo;
00052 
00053     /* convert to an integral number of whole portions */
00054     unsigned long n = (unsigned long)(angulo * fracbase + 0.5);
00055     int d = (int)(n/(unsigned long)fracbase);
00056     int f = (int)(n%(unsigned long)fracbase);
00057     /* do the rest */
00058     int m = f/(fracbase/60);
00059     int s = f%(fracbase/60);
00060     //float s = (float)f - (float)m*(float)(fracbase/60);
00061 
00062     /* form the whole part; "negative 0" is a special case */
00063     if ( negativo && d == 0 ) negativo = 0;
00064     (*grados) = (float)d;
00065     if ( negativo ) (*grados) *= -1;
00066     (*minutos) = (float)m;
00067     (*segundos) = (float)s;
00068 }
00069 
00070 void
00071 DEG2hms(double angulo, float *horas, float *arco_minutos, float *arco_segundos)
00078 {
00079     int fracbase = 3600;
00080 
00081     while (angulo < 0) angulo += 360;
00082     while (angulo > 360) angulo -= 360;
00083 
00084     unsigned long n = (unsigned long)(angulo * (fracbase/15) + 0.5);
00085     int d = (int)(n/(unsigned long)fracbase);
00086     int f = (int)(n%(unsigned long)fracbase);
00087     int m = f/(fracbase/60);
00088     int s = f%(fracbase/60);
00089 
00090     (*horas) = (float)d;
00091     (*arco_minutos) = (float)m;
00092     (*arco_segundos) = (float)s;
00093 }
00094 
00095 //===========================================================================
00096 //= Cosas especificas de PALM_PALMOS_CODEWARRIOR                            =
00097 //===========================================================================
00098 
00099 #if PLATAFORMA == PALM_PALMOS_CODEWARRIOR
00100 
00101 // Esta es la minima version de PALMOS que se requiere para correr aplicaciones
00102 // basadas en AQUYNZA
00103 #define VERSION_DE_ROM_20 0x02000000
00104 
00105 // OJO: Este es el encabezado generado por el editor de recursos. Puede que
00106 //      este nombre de archivo requiera ser cambiado.
00107 #include "Resource.frk/idcs.h"
00108 
00109 extern int main(int argc, char *argv[]);
00110 
00111 void
00112 PALM_setcolor(BYTE r, BYTE g, BYTE b)
00117 {
00118     static UInt32 version_de_rom;
00119 
00120     FtrGet(sysFtrCreator, sysFtrNumROMVersion, &version_de_rom);
00121 
00122     // OJO: WinSetForeColor y WinDrawPixel existen solo desde PALMOS 3.5
00123     if ( version_de_rom >= 0x03500000 ) {
00124         static RGBColorType color;
00125 
00126         color.r = r;
00127         color.g = g;
00128         color.b = b;
00129 
00130         WinSetForeColorRGB(&color, NULL);
00131     }
00132     // Si no se ignora
00133 }
00134 
00135 void
00136 PALM_putpixel(int x, int y, BYTE r, BYTE g, BYTE b)
00142 {
00143     static UInt32 version_de_rom;
00144     //static int peso = 0;
00145 
00146     FtrGet(sysFtrCreator, sysFtrNumROMVersion, &version_de_rom);
00147 
00148     // OJO: WinSetForeColor y WinDrawPixel existen solo desde PALMOS 3.5
00149     if ( version_de_rom >= 0x03500000 ) {
00150         static RGBColorType color;
00151 
00152         color.r = r;
00153         color.g = g;
00154         color.b = b;
00155 
00156         WinSetForeColorRGB(&color, NULL);
00157         WinDrawPixel(x, y);
00158     }
00159     else {
00160         //peso = (r + g + b) / 3;
00161 
00162 //        if ( peso < 128 ) {
00163         if ( r < 128 && g < 128 && b < 128 ) {
00164             WinDrawLine(x, y, x, y);
00165           }
00166           else {
00167             WinEraseLine(x, y, x, y);
00168         }
00169 
00170     }
00171 }
00172 
00173 static Err
00174 revisar_version_rom(UInt32 requiredVersion, UInt16 launchFlags)
00181 {
00182     UInt32 version_de_rom = 0;
00183 
00184     FtrGet(sysFtrCreator, sysFtrNumROMVersion, &version_de_rom);
00185         
00186     if ( version_de_rom < requiredVersion ) {
00187         if ( (launchFlags & (sysAppLaunchFlagNewGlobals | 
00188                              sysAppLaunchFlagUIApp)) ==
00189             (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) {
00190             FrmAlert (RomIncompatibleAlert);
00191             // OS 1.0 will continuously relaunch this app unless we switch to a
00192             // safe one - sysFileCDefaultApp is considered safe 
00193             if ( version_de_rom < 0x02000000 ) {
00194                 AppLaunchWithCommand(sysFileCDefaultApp, 
00195                                      sysAppLaunchCmdNormalLaunch, NULL);
00196             }
00197         }
00198                 
00199         return sysErrRomIncompatible;
00200     }
00201         
00202     return 0;
00203 }
00204 
00205 UInt32
00206 PilotMain(UInt16 modo_de_ejecucion, MemPtr cmdPBP, UInt16 launchFlags)
00211 {
00212     Err error;
00213     char nombre[1][5] = {"PALM"};
00214         
00215     error = revisar_version_rom (VERSION_DE_ROM_20, launchFlags);
00216     if ( error ) return error;
00217         
00218     if ( modo_de_ejecucion == sysAppLaunchCmdNormalLaunch ) {
00219         return main(1, (char **)nombre);
00220     }
00221         
00222     return 0;
00223 }
00224 
00225 #endif // PALM_PALMOS_CODEWARRIOR
00226 
00227 //===========================================================================
00228 //= Cosas especificas de i386_WIN32_VC                                      =
00229 //===========================================================================
00230 
00231 #if PLATAFORMA == i386_WIN32_VC
00232 
00233 #include <lista.cc>
00234 
00235 LISTA<SOCKET_IO_PAIR *> PARES_socket;
00236 
00237 void
00238 WINlog(char *linea)
00239 {
00240     FILE *fd = fopen("./app.log", "at");
00241     if ( fd ) {
00242         fprintf(fd, "%s\n", linea); 
00243         fclose(fd);
00244     }
00245 }
00246 
00247 void
00248 reportar_evento_WM(int e)
00249 {
00250     char log[1024];
00251     switch ( e ) {
00252       // Eventos desconocidos en Windows 2000 y en Windows NT...
00253       /*
00254       case WM_UNICHAR:                sprintf(log, "  - EVENTO: WM_UNICHAR"); break;
00255       case WM_NCXBUTTONDOWN:          sprintf(log, "  - EVENTO: WM_NCXBUTTONDOWN"); break;
00256       case WM_NCXBUTTONUP:            sprintf(log, "  - EVENTO: WM_NCXBUTTONUP"); break;
00257       case WM_NCXBUTTONDBLCLK:        sprintf(log, "  - EVENTO: WM_NCXBUTTONDBLCLK"); break;
00258       case WM_INPUT:                  sprintf(log, "  - EVENTO: WM_INPUT"); break;
00259       case WM_CHANGEUISTATE:          sprintf(log, "  - EVENTO: WM_CHANGEUISTATE"); break;
00260       case WM_UPDATEUISTATE:          sprintf(log, "  - EVENTO: WM_UPDATEUISTATE"); break;
00261       case WM_QUERYUISTATE:           sprintf(log, "  - EVENTO: WM_QUERYUISTATE"); break;
00262       case WM_MOUSEWHEEL:             sprintf(log, "  - EVENTO: WM_MOUSEWHEEL"); break;
00263       case WM_XBUTTONDOWN:            sprintf(log, "  - EVENTO: WM_XBUTTONDOWN"); break;
00264       case WM_XBUTTONUP:              sprintf(log, "  - EVENTO: WM_XBUTTONUP"); break;
00265       case WM_XBUTTONDBLCLK:          sprintf(log, "  - EVENTO: WM_XBUTTONDBLCLK"); break;
00266       case WM_WTSSESSION_CHANGE:      sprintf(log, "  - EVENTO: WM_WTSSESSION_CHANGE"); break;
00267       case WM_TABLET_FIRST:           sprintf(log, "  - EVENTO: WM_TABLET_FIRST"); break;
00268       case WM_TABLET_LAST:            sprintf(log, "  - EVENTO: WM_TABLET_LAST"); break;
00269       case WM_APPCOMMAND:             sprintf(log, "  - EVENTO: WM_APPCOMMAND");break;
00270       case WM_THEMECHANGED:           sprintf(log, "  - EVENTO: WM_THEMECHANGED"); break;      
00271          
00272     // Eventos desconocidos en Windows NT
00273       case WM_GETOBJECT:              sprintf(log, "  - EVENTO: WM_GETOBJECT"); break;
00274       case WM_MENURBUTTONUP:          sprintf(log, "  - EVENTO: WM_MENURBUTTONUP"); break;
00275       case WM_MENUDRAG:               sprintf(log, "  - EVENTO: WM_MENUDRAG"); break;
00276       case WM_MENUGETOBJECT:          sprintf(log, "  - EVENTO: WM_MENUGETOBJECT"); break;
00277       case WM_UNINITMENUPOPUP:        sprintf(log, "  - EVENTO: WM_UNINITMENUPOPUP"); break;
00278       case WM_MENUCOMMAND:            sprintf(log, "  - EVENTO: WM_MENUCOMMAND"); break;
00279       case WM_IME_REQUEST:            sprintf(log, "  - EVENTO: WM_IME_REQUEST"); break;
00280       case WM_MOUSEHOVER:             sprintf(log, "  - EVENTO: WM_MOUSEHOVER"); break;
00281       case WM_MOUSELEAVE:             sprintf(log, "  - EVENTO: WM_MOUSELEAVE"); break;
00282       case WM_NCMOUSEHOVER:           sprintf(log, "  - EVENTO: WM_NCMOUSEHOVER"); break;
00283       case WM_NCMOUSELEAVE:           sprintf(log, "  - EVENTO: WM_NCMOUSELEAVE"); break;
00284 
00285     // El mismo KEYDOWN
00286       case WM_KEYFIRST:               sprintf(log, "  - EVENTO: WM_KEYFIRST"); break;
00287     */
00288 
00289       case WM_NULL:                   sprintf(log, "  - EVENTO: WM_NULL"); break;
00290       case WM_CREATE:                 sprintf(log, "  - EVENTO: WM_CREATE"); break;
00291       case WM_DESTROY:                sprintf(log, "  - EVENTO: WM_DESTROY"); break;
00292       case WM_MOVE:                   sprintf(log, "  - EVENTO: WM_MOVE"); break;
00293       case WM_SIZE:                   sprintf(log, "  - EVENTO: WM_SIZE"); break;
00294       case WM_ACTIVATE:               sprintf(log, "  - EVENTO: WM_ACTIVATE"); break;
00295       case WM_SETFOCUS:               sprintf(log, "  - EVENTO: WM_SETFOCUS"); break;
00296       case WM_KILLFOCUS:              sprintf(log, "  - EVENTO: WM_KILLFOCUS"); break;
00297       case WM_ENABLE:                 sprintf(log, "  - EVENTO: WM_ENABLE"); break;
00298       case WM_SETREDRAW:              sprintf(log, "  - EVENTO: WM_SETREDRAW"); break;
00299       case WM_SETTEXT:                sprintf(log, "  - EVENTO: WM_SETTEXT"); break;
00300       case WM_GETTEXT:                sprintf(log, "  - EVENTO: WM_GETTEXT"); break;
00301       case WM_GETTEXTLENGTH:          sprintf(log, "  - EVENTO: WM_GETTEXTLENGTH"); break;
00302       case WM_PAINT:                  sprintf(log, "  - EVENTO: WM_PAINT"); break;
00303       case WM_CLOSE:                  sprintf(log, "  - EVENTO: WM_CLOSE"); break;
00304       case WM_QUERYENDSESSION:        sprintf(log, "  - EVENTO: WM_QUERYENDSESSION"); break;
00305       case WM_QUERYOPEN:              sprintf(log, "  - EVENTO: WM_QUERYOPEN"); break;
00306       case WM_ENDSESSION:             sprintf(log, "  - EVENTO: WM_ENDSESSION"); break;
00307       case WM_QUIT:                   sprintf(log, "  - EVENTO: WM_QUIT"); break;
00308       case WM_ERASEBKGND:             sprintf(log, "  - EVENTO: WM_ERASEBKGND"); break;
00309       case WM_SYSCOLORCHANGE:         sprintf(log, "  - EVENTO: WM_SYSCOLORCHANGE"); break;
00310       case WM_SHOWWINDOW:             sprintf(log, "  - EVENTO: WM_SHOWWINDOW"); break;
00311       case WM_WININICHANGE:           sprintf(log, "  - EVENTO: WM_WININICHANGE"); break;
00312       case WM_DEVMODECHANGE:          sprintf(log, "  - EVENTO: WM_DEVMODECHANGE"); break;
00313       case WM_ACTIVATEAPP:            sprintf(log, "  - EVENTO: WM_ACTIVATEAPP"); break;
00314       case WM_FONTCHANGE:             sprintf(log, "  - EVENTO: WM_FONTCHANGE"); break;
00315       case WM_TIMECHANGE:             sprintf(log, "  - EVENTO: WM_TIMECHANGE"); break;
00316       case WM_CANCELMODE:             sprintf(log, "  - EVENTO: WM_CANCELMODE"); break;
00317       case WM_SETCURSOR:              sprintf(log, "  - EVENTO: WM_SETCURSOR"); break;
00318       case WM_MOUSEACTIVATE:          sprintf(log, "  - EVENTO: WM_MOUSEACTIVATE"); break;
00319       case WM_CHILDACTIVATE:          sprintf(log, "  - EVENTO: WM_CHILDACTIVATE"); break;
00320       case WM_QUEUESYNC:              sprintf(log, "  - EVENTO: WM_QUEUESYNC"); break;
00321       case WM_GETMINMAXINFO:          sprintf(log, "  - EVENTO: WM_GETMINMAXINFO"); break;
00322       case WM_PAINTICON:              sprintf(log, "  - EVENTO: WM_PAINTICON"); break;
00323       case WM_ICONERASEBKGND:         sprintf(log, "  - EVENTO: WM_ICONERASEBKGND"); break;
00324       case WM_NEXTDLGCTL:             sprintf(log, "  - EVENTO: WM_NEXTDLGCTL"); break;
00325       case WM_SPOOLERSTATUS:          sprintf(log, "  - EVENTO: WM_SPOOLERSTATUS"); break;
00326       case WM_DRAWITEM:               sprintf(log, "  - EVENTO: WM_DRAWITEM"); break;
00327       case WM_MEASUREITEM:            sprintf(log, "  - EVENTO: WM_MEASUREITEM"); break;
00328       case WM_DELETEITEM:             sprintf(log, "  - EVENTO: WM_DELETEITEM"); break;
00329       case WM_VKEYTOITEM:             sprintf(log, "  - EVENTO: WM_VKEYTOITEM"); break;
00330       case WM_CHARTOITEM:             sprintf(log, "  - EVENTO: WM_CHARTOITEM"); break;
00331       case WM_SETFONT:                sprintf(log, "  - EVENTO: WM_SETFONT"); break;
00332       case WM_GETFONT:                sprintf(log, "  - EVENTO: WM_GETFONT"); break;
00333       case WM_SETHOTKEY:              sprintf(log, "  - EVENTO: WM_SETHOTKEY"); break;
00334       case WM_GETHOTKEY:              sprintf(log, "  - EVENTO: WM_GETHOTKEY"); break;
00335       case WM_QUERYDRAGICON:          sprintf(log, "  - EVENTO: WM_QUERYDRAGICON"); break;
00336       case WM_COMPAREITEM:            sprintf(log, "  - EVENTO: WM_COMPAREITEM"); break;
00337       case WM_COMPACTING:             sprintf(log, "  - EVENTO: WM_COMPACTING"); break;
00338       case WM_COMMNOTIFY:             sprintf(log, "  - EVENTO: WM_COMMNOTIFY"); break;
00339       case WM_WINDOWPOSCHANGING:      sprintf(log, "  - EVENTO: WM_WINDOWPOSCHANGING"); break;
00340       case WM_WINDOWPOSCHANGED:       sprintf(log, "  - EVENTO: WM_WINDOWPOSCHANGED"); break;
00341       case WM_POWER:                  sprintf(log, "  - EVENTO: WM_POWER"); break;
00342       case WM_COPYDATA:               sprintf(log, "  - EVENTO: WM_COPYDATA"); break;
00343       case WM_CANCELJOURNAL:          sprintf(log, "  - EVENTO: WM_CANCELJOURNAL"); break;
00344       case WM_NOTIFY:                 sprintf(log, "  - EVENTO: WM_NOTIFY"); break;
00345       case WM_INPUTLANGCHANGEREQUEST: sprintf(log, "  - EVENTO: WM_INPUTLANGCHANGEREQUEST"); break;
00346       case WM_INPUTLANGCHANGE:        sprintf(log, "  - EVENTO: WM_INPUTLANGCHANGE"); break;
00347       case WM_TCARD:                  sprintf(log, "  - EVENTO: WM_TCARD"); break;
00348       case WM_HELP:                   sprintf(log, "  - EVENTO: WM_HELP"); break;
00349       case WM_USERCHANGED:            sprintf(log, "  - EVENTO: WM_USERCHANGED"); break;
00350       case WM_NOTIFYFORMAT:           sprintf(log, "  - EVENTO: WM_NOTIFYFORMAT"); break;
00351       case WM_CONTEXTMENU:            sprintf(log, "  - EVENTO: WM_CONTEXTMENU"); break;
00352       case WM_STYLECHANGING:          sprintf(log, "  - EVENTO: WM_STYLECHANGING"); break;
00353       case WM_STYLECHANGED:           sprintf(log, "  - EVENTO: WM_STYLECHANGED"); break;
00354       case WM_DISPLAYCHANGE:          sprintf(log, "  - EVENTO: WM_DISPLAYCHANGE"); break;
00355       case WM_GETICON:                sprintf(log, "  - EVENTO: WM_GETICON"); break;
00356       case WM_SETICON:                sprintf(log, "  - EVENTO: WM_SETICON"); break;
00357       case WM_NCCREATE:               sprintf(log, "  - EVENTO: WM_NCCREATE"); break;
00358       case WM_NCDESTROY:              sprintf(log, "  - EVENTO: WM_NCDESTROY"); break;
00359       case WM_NCCALCSIZE:             sprintf(log, "  - EVENTO: WM_NCCALCSIZE"); break;
00360       case WM_NCHITTEST:              sprintf(log, "  - EVENTO: WM_NCHITTEST"); break;
00361       case WM_NCPAINT:                sprintf(log, "  - EVENTO: WM_NCPAINT"); break;
00362       case WM_NCACTIVATE:             sprintf(log, "  - EVENTO: WM_NCACTIVATE"); break;
00363       case WM_GETDLGCODE:             sprintf(log, "  - EVENTO: WM_GETDLGCODE"); break;
00364       case WM_SYNCPAINT:              sprintf(log, "  - EVENTO: WM_SYNCPAINT"); break;
00365       case WM_NCMOUSEMOVE:            sprintf(log, "  - EVENTO: WM_NCMOUSEMOVE"); break;
00366       case WM_NCLBUTTONDOWN:          sprintf(log, "  - EVENTO: WM_NCLBUTTONDOWN"); break;
00367       case WM_NCLBUTTONUP:            sprintf(log, "  - EVENTO: WM_NCLBUTTONUP"); break;
00368       case WM_NCLBUTTONDBLCLK:        sprintf(log, "  - EVENTO: WM_NCLBUTTONDBLCLK"); break;
00369       case WM_NCRBUTTONDOWN:          sprintf(log, "  - EVENTO: WM_NCRBUTTONDOWN"); break;
00370       case WM_NCRBUTTONUP:            sprintf(log, "  - EVENTO: WM_NCRBUTTONUP"); break;
00371       case WM_NCRBUTTONDBLCLK:        sprintf(log, "  - EVENTO: WM_NCRBUTTONDBLCLK"); break;
00372       case WM_NCMBUTTONDOWN:          sprintf(log, "  - EVENTO: WM_NCMBUTTONDOWN"); break;
00373       case WM_NCMBUTTONUP:            sprintf(log, "  - EVENTO: WM_NCMBUTTONUP"); break;
00374       case WM_NCMBUTTONDBLCLK:        sprintf(log, "  - EVENTO: WM_NCMBUTTONDBLCLK"); break;
00375       case WM_KEYDOWN:                sprintf(log, "  - EVENTO: WM_KEYDOWN"); break;
00376       case WM_KEYUP:                  sprintf(log, "  - EVENTO: WM_KEYUP"); break;
00377       case WM_CHAR:                   sprintf(log, "  - EVENTO: WM_CHAR"); break;
00378       case WM_DEADCHAR:               sprintf(log, "  - EVENTO: WM_DEADCHAR"); break;
00379       case WM_SYSKEYDOWN:             sprintf(log, "  - EVENTO: WM_SYSKEYDOWN"); break;
00380       case WM_SYSKEYUP:               sprintf(log, "  - EVENTO: WM_SYSKEYUP"); break;
00381       case WM_SYSCHAR:                sprintf(log, "  - EVENTO: WM_SYSCHAR"); break;
00382       case WM_SYSDEADCHAR:            sprintf(log, "  - EVENTO: WM_SYSDEADCHAR"); break;
00383       case WM_KEYLAST:                sprintf(log, "  - EVENTO: WM_KEYLAST"); break;
00384       case WM_IME_STARTCOMPOSITION:   sprintf(log, "  - EVENTO: WM_IME_STARTCOMPOSITION"); break;
00385       case WM_IME_ENDCOMPOSITION:     sprintf(log, "  - EVENTO: WM_IME_ENDCOMPOSITION"); break;
00386       case WM_IME_COMPOSITION:        sprintf(log, "  - EVENTO: WM_IME_COMPOSITION"); break;
00387       case WM_INITDIALOG:             sprintf(log, "  - EVENTO: WM_INITDIALOG"); break;
00388       case WM_COMMAND:                sprintf(log, "  - EVENTO: WM_COMMAND"); break;
00389       case WM_SYSCOMMAND:             sprintf(log, "  - EVENTO: WM_SYSCOMMAND"); break;
00390       case WM_TIMER:                  sprintf(log, "  - EVENTO: WM_TIMER"); break;
00391       case WM_HSCROLL:                sprintf(log, "  - EVENTO: WM_HSCROLL"); break;
00392       case WM_VSCROLL:                sprintf(log, "  - EVENTO: WM_VSCROLL"); break;
00393       case WM_INITMENU:               sprintf(log, "  - EVENTO: WM_INITMENU"); break;
00394       case WM_INITMENUPOPUP:          sprintf(log, "  - EVENTO: WM_INITMENUPOPUP"); break;
00395       case WM_MENUSELECT:             sprintf(log, "  - EVENTO: WM_MENUSELECT"); break;
00396       case WM_MENUCHAR:               sprintf(log, "  - EVENTO: WM_MENUCHAR"); break;
00397       case WM_ENTERIDLE:              sprintf(log, "  - EVENTO: WM_ENTERIDLE"); break;
00398       case WM_CTLCOLORMSGBOX:         sprintf(log, "  - EVENTO: WM_CTLCOLORMSGBOX"); break;
00399       case WM_CTLCOLOREDIT:           sprintf(log, "  - EVENTO: WM_CTLCOLOREDIT"); break;
00400       case WM_CTLCOLORLISTBOX:        sprintf(log, "  - EVENTO: WM_CTLCOLORLISTBOX"); break;
00401       case WM_CTLCOLORBTN:            sprintf(log, "  - EVENTO: WM_CTLCOLORBTN"); break;
00402       case WM_CTLCOLORDLG:            sprintf(log, "  - EVENTO: WM_CTLCOLORDLG"); break;
00403       case WM_CTLCOLORSCROLLBAR:      sprintf(log, "  - EVENTO: WM_CTLCOLORSCROLLBAR"); break;
00404       case WM_CTLCOLORSTATIC:         sprintf(log, "  - EVENTO: WM_CTLCOLORSTATIC"); break;
00405       case WM_MOUSEFIRST:             sprintf(log, "  - EVENTO: WM_MOUSEFIRST/WM_MOUSEMOVE"); break;
00406       case WM_LBUTTONUP:              sprintf(log, "  - EVENTO: WM_LBUTTONUP"); break;
00407           case WM_LBUTTONDOWN:            sprintf(log, "  - EVENTO: WM_LBUTTONDOWN"); break;
00408       case WM_LBUTTONDBLCLK:          sprintf(log, "  - EVENTO: WM_LBUTTONDBLCLK"); break;
00409       case WM_RBUTTONDOWN:            sprintf(log, "  - EVENTO: WM_RBUTTONDOWN"); break;
00410       case WM_RBUTTONUP:              sprintf(log, "  - EVENTO: WM_RBUTTONUP"); break;
00411       case WM_RBUTTONDBLCLK:          sprintf(log, "  - EVENTO: WM_RBUTTONDBLCLK"); break;
00412       case WM_MBUTTONDOWN:            sprintf(log, "  - EVENTO: WM_MBUTTONDOWN"); break;
00413       case WM_MBUTTONUP:              sprintf(log, "  - EVENTO: WM_MBUTTONUP"); break;
00414       case WM_MBUTTONDBLCLK:          sprintf(log, "  - EVENTO: WM_MBUTTONDBLCLK"); break;
00415       case WM_PARENTNOTIFY:           sprintf(log, "  - EVENTO: WM_PARENTNOTIFY"); break;
00416       case WM_ENTERMENULOOP:          sprintf(log, "  - EVENTO: WM_ENTERMENULOOP"); break;
00417       case WM_EXITMENULOOP:           sprintf(log, "  - EVENTO: WM_EXITMENULOOP"); break;
00418       case WM_NEXTMENU:               sprintf(log, "  - EVENTO: WM_NEXTMENU"); break;
00419       case WM_SIZING:                 sprintf(log, "  - EVENTO: WM_SIZING"); break;
00420       case WM_CAPTURECHANGED:         sprintf(log, "  - EVENTO: WM_CAPTURECHANGED"); break;
00421       case WM_MOVING:                 sprintf(log, "  - EVENTO: WM_MOVING"); break;
00422       case WM_POWERBROADCAST:         sprintf(log, "  - EVENTO: WM_POWERBROADCAST"); break;
00423       case WM_DEVICECHANGE:           sprintf(log, "  - EVENTO: WM_DEVICECHANGE"); break;
00424       case WM_MDICREATE:              sprintf(log, "  - EVENTO: WM_MDICREATE"); break;
00425       case WM_MDIDESTROY:             sprintf(log, "  - EVENTO: WM_MDIDESTROY"); break;
00426       case WM_MDIACTIVATE:            sprintf(log, "  - EVENTO: WM_MDIACTIVATE"); break;
00427       case WM_MDIRESTORE:             sprintf(log, "  - EVENTO: WM_MDIRESTORE"); break;
00428       case WM_MDINEXT:                sprintf(log, "  - EVENTO: WM_MDINEXT"); break;
00429       case WM_MDIMAXIMIZE:            sprintf(log, "  - EVENTO: WM_MDIMAXIMIZE"); break;
00430       case WM_MDITILE:                sprintf(log, "  - EVENTO: WM_MDITILE"); break;
00431       case WM_MDICASCADE:             sprintf(log, "  - EVENTO: WM_MDICASCADE"); break;
00432       case WM_MDIICONARRANGE:         sprintf(log, "  - EVENTO: WM_MDIICONARRANGE"); break;
00433       case WM_MDIGETACTIVE:           sprintf(log, "  - EVENTO: WM_MDIGETACTIVE"); break;
00434       case WM_MDISETMENU:             sprintf(log, "  - EVENTO: WM_MDISETMENU"); break;
00435       case WM_ENTERSIZEMOVE:          sprintf(log, "  - EVENTO: WM_ENTERSIZEMOVE"); break;
00436       case WM_EXITSIZEMOVE:           sprintf(log, "  - EVENTO: WM_EXITSIZEMOVE"); break;
00437       case WM_DROPFILES:              sprintf(log, "  - EVENTO: WM_DROPFILES"); break;
00438       case WM_MDIREFRESHMENU:         sprintf(log, "  - EVENTO: WM_MDIREFRESHMENU"); break;
00439       case WM_IME_SETCONTEXT:         sprintf(log, "  - EVENTO: WM_IME_SETCONTEXT"); break;
00440       case WM_IME_NOTIFY:             sprintf(log, "  - EVENTO: WM_IME_NOTIFY"); break;
00441       case WM_IME_CONTROL:            sprintf(log, "  - EVENTO: WM_IME_CONTROL"); break;
00442       case WM_IME_COMPOSITIONFULL:    sprintf(log, "  - EVENTO: WM_IME_COMPOSITIONFULL"); break;
00443       case WM_IME_SELECT:             sprintf(log, "  - EVENTO: WM_IME_SELECT"); break;
00444       case WM_IME_CHAR:               sprintf(log, "  - EVENTO: WM_IME_CHAR"); break;
00445       case WM_IME_KEYDOWN:            sprintf(log, "  - EVENTO: WM_IME_KEYDOWN"); break;
00446       case WM_IME_KEYUP:              sprintf(log, "  - EVENTO: WM_IME_KEYUP"); break;
00447       case WM_CUT:                    sprintf(log, "  - EVENTO: WM_CUT"); break;
00448       case WM_COPY:                   sprintf(log, "  - EVENTO: WM_COPY"); break;
00449       case WM_PASTE:                  sprintf(log, "  - EVENTO: WM_PASTE"); break;
00450       case WM_CLEAR:                  sprintf(log, "  - EVENTO: WM_CLEAR"); break;
00451       case WM_UNDO:                   sprintf(log, "  - EVENTO: WM_UNDO"); break;
00452       case WM_RENDERFORMAT:           sprintf(log, "  - EVENTO: WM_RENDERFORMAT"); break;
00453       case WM_RENDERALLFORMATS:       sprintf(log, "  - EVENTO: WM_RENDERALLFORMATS"); break;
00454       case WM_DESTROYCLIPBOARD:       sprintf(log, "  - EVENTO: WM_DESTROYCLIPBOARD"); break;
00455       case WM_DRAWCLIPBOARD:          sprintf(log, "  - EVENTO: WM_DRAWCLIPBOARD"); break;
00456       case WM_PAINTCLIPBOARD:         sprintf(log, "  - EVENTO: WM_PAINTCLIPBOARD"); break;
00457       case WM_VSCROLLCLIPBOARD:       sprintf(log, "  - EVENTO: WM_VSCROLLCLIPBOARD"); break;
00458       case WM_SIZECLIPBOARD:          sprintf(log, "  - EVENTO: WM_SIZECLIPBOARD"); break;
00459       case WM_ASKCBFORMATNAME:        sprintf(log, "  - EVENTO: WM_ASKCBFORMATNAME"); break;
00460       case WM_CHANGECBCHAIN:          sprintf(log, "  - EVENTO: WM_CHANGECBCHAIN"); break;
00461       case WM_HSCROLLCLIPBOARD:       sprintf(log, "  - EVENTO: WM_HSCROLLCLIPBOARD"); break;
00462       case WM_QUERYNEWPALETTE:        sprintf(log, "  - EVENTO: WM_QUERYNEWPALETTE"); break;
00463       case WM_PALETTEISCHANGING:      sprintf(log, "  - EVENTO: WM_PALETTEISCHANGING"); break;
00464       case WM_PALETTECHANGED:         sprintf(log, "  - EVENTO: WM_PALETTECHANGED"); break;
00465       case WM_HOTKEY:                 sprintf(log, "  - EVENTO: WM_HOTKEY"); break;
00466       case WM_PRINT:                  sprintf(log, "  - EVENTO: WM_PRINT"); break;
00467       case WM_PRINTCLIENT:            sprintf(log, "  - EVENTO: WM_PRINTCLIENT"); break;
00468       case WM_HANDHELDFIRST:          sprintf(log, "  - EVENTO: WM_HANDHELDFIRST"); break;
00469       case WM_HANDHELDLAST:           sprintf(log, "  - EVENTO: WM_HANDHELDLAST"); break;
00470       case WM_AFXFIRST:               sprintf(log, "  - EVENTO: WM_AFXFIRST"); break;
00471       case WM_AFXLAST:                sprintf(log, "  - EVENTO: WM_AFXLAST"); break;
00472       case WM_PENWINFIRST:            sprintf(log, "  - EVENTO: WM_PENWINFIRST"); break;
00473       case WM_PENWINLAST:             sprintf(log, "  - EVENTO: WM_PENWINLAST"); break;
00474       case WM_APP:                    sprintf(log, "  - EVENTO: WM_APP"); break;
00475       case WM_USER:                   sprintf(log, "  - EVENTO: WM_USER"); break;
00476       case 666:                       sprintf(log, "  - EVENTO: JEDILINK (valor = 666)"); break;
00477       default:
00478         sprintf(log,  "  - EVENTO Desconocido (%d)", e );
00479     }
00480     WINlog(log);
00481 }
00482 
00483 #ifndef CBUILDER
00484 void
00485 registrar_entrada_sockets(SOCKET sockfd, void (*f)(void *, int), void *User_data)
00486 {
00487     SOCKET_IO_PAIR *Nodito = new SOCKET_IO_PAIR;
00488 
00489     Nodito->sockfd = sockfd;
00490     Nodito->f = f;
00491     Nodito->User_data = User_data;
00492     PARES_socket.anx(Nodito);
00493 }
00494 #endif
00495 
00496 LONG WINAPI
00497 receptor_eventos_sockets(HWND w, UINT tipo_mensaje, UINT uParam, LONG lParam)
00504 {
00505     int i;
00506     //char log[1024];
00507     int accion = ACC_ERROR;
00508 
00509     if ( tipo_mensaje == WM_DESTROY ) {
00510         exit(0);
00511     }
00512 
00513     //reportar_evento_WM(tipo_mensaje);
00514 
00515     if ( tipo_mensaje == 666 ) {
00516         //sprintf(log, "  - -> subtipo: %d", lParam);
00517         //WINlog(log);
00518         if ( lParam == FD_READ ) {
00519             accion = ACC_LEER;            
00520             }
00521           else if ( lParam == FD_CLOSE ) {
00522             accion = ACC_ELIMINAR;            
00523         }
00524         for ( i = 0; i < PARES_socket.tam(); i++ ) {
00525             if ( PARES_socket[i]->sockfd == (SOCKET)uParam ) {
00526                 PARES_socket[i]->f(PARES_socket[i]->User_data, accion);
00527                 break;
00528             }
00529         }
00530     }
00531 
00532     return DefWindowProc(w, tipo_mensaje, uParam, lParam);
00533 }
00534 
00535 HWND
00536 instalar_sistema_asincronico_sockets(void)
00537 {
00538     static int lista = 0;
00539     static HWND receptora = NULL;
00540     //HANDLE hInstance = i386_WIN32_VC_instancia_actual;
00541 
00542     if ( lista ) return receptora;
00543 
00544     //- CREE LA CLASE DE VENTANA RECEPTORA DE EVENTOS ------------
00545     // OJO: Jugar con lo siguiente en el STYLE: CS_BYTEALIGNCLIENT,
00546     // CS_BYTEALIGNWINDOW, CS_DBLCLKS, CS_NOCLOSE
00547     WNDCLASS atributos_de_ventana = {
00548         CS_GLOBALCLASS,     // UINT    style; 
00549         (WNDPROC)receptor_eventos_sockets,  // WNDPROC lpfnWndProc; 
00550         0,                  // int     cbClsExtra; 
00551         0,                  // int     cbWndExtra; 
00552         0,                  // HANDLE  hInstance; 
00553         NULL,               //HICON   hIcon; 
00554         NULL,               //HCURSOR hCursor; 
00555         NULL,               //HBRUSH  hbrBackground; 
00556         "",                 // Sin menu por defecto.
00557         "AQUYNZA_Socket_event_handler"    // LPCTSTR lpszClassName; 
00558     };
00559 
00560     if ( !RegisterClass(&atributos_de_ventana) ) {
00561 /*
00562         fprintf(stderr, "ERROR: No puedo crear la clase!\n");
00563         fflush(stdout);
00564 */
00565         WINlog("<jed_defs.C/instalar_sistema_asincronico_sockets> ERROR: No puedo crear la clase!");
00566         return NULL;
00567     }
00568 
00569     //- CREE LA VENTANA RECEPTORA ------------------------------
00570     receptora = CreateWindowEx( 
00571         WS_EX_NOPARENTNOTIFY | WS_EX_TRANSPARENT,
00572             // OJO: Revisar los "extended windows styles"
00573         "AQUYNZA_Socket_event_handler", // Nombre de la clase de ventana
00574         "AQUYNZA Socket event handler",  // Nombre de la ventana
00575         WS_ICONIC  | // Estilo de borde
00576         WS_CAPTION | WS_MINIMIZEBOX |WS_MAXIMIZEBOX | // Estilo de barra
00577         WS_CLIPSIBLINGS | WS_CLIPCHILDREN,  // Siempre activos!
00578         0, 0, 10, 10,  // Geometria de la ventana
00579         NULL, // Ventana padre: en este caso es la root-window
00580         NULL, // handle to menu (en este caso sin menu por defecto)
00581         0, // handle to application instance (ver parametro)
00582         (LPVOID)NULL // Apuntador a datos de mi aplicacion
00583     );
00584 
00585     if ( !receptora ) {
00586         fprintf(stderr,
00587             "ERROR: No pudo crearse la ventana receptora de eventos!\n");
00588         fflush(stderr);
00589     }
00590 
00591     lista = 1;
00592     ShowWindow(receptora, SW_SHOWDEFAULT);  // OJO: Esto no deberia ir!
00593     return receptora;
00594 }
00595 
00596 
00597 // Los parametros de WinMain se pasan a variables globales
00598 HINSTANCE i386_WIN32_VC_instancia_actual;
00599 HINSTANCE i386_WIN32_VC_instancia_previa;
00600 LPSTR     i386_WIN32_VC_linea_de_comandos;
00601 int       i386_WIN32_VC_modo_visual;
00602 
00603 char **
00604 PrepArgs(char *s, int *pn)
00613 {
00614     char *cadenita, *palabra;
00615     char **ARr = (char**)malloc(sizeof(char*));
00616 
00617     ARr[0] = new char[9];
00618     strcpy(ARr[0], "AQUYNZA");
00619 
00620     (*pn) = 1;
00621     palabra = strtok(s, " ");
00622     while ( palabra != NULL ) {
00623         cadenita = (char *)malloc(sizeof(char) * (strlen(palabra) + 1));
00624         strcpy(cadenita, palabra);
00625         ARr = (char **)realloc(ARr, sizeof(char *) * ((*pn) + 1));
00626         ARr[*pn] = cadenita;
00627         (*pn)++;
00628         palabra = strtok(NULL, " ");
00629     }
00630     ARr = (char **)realloc(ARr, sizeof(char *) * ((*pn) + 1));
00631     ARr[*pn] = NULL;
00632 
00633     return ARr;
00634 }
00635 
00636 #ifndef CBUILDER
00637 
00638 int PASCAL
00639 WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
00640         LPSTR lpCmdLine, int nCmdShow)
00646 {
00647     char **PArametros = NULL;
00648     int num_params = 0, retorno, i;
00649 
00650     //- Pendejadas de MS-Windows --------------------------------------------
00651     i386_WIN32_VC_instancia_previa = hPrevInstance;
00652     i386_WIN32_VC_instancia_actual = hInstance;
00653     i386_WIN32_VC_linea_de_comandos = lpCmdLine;
00654     i386_WIN32_VC_modo_visual = nCmdShow;
00655 
00656     //- Registra la clase de objeto para el frame/shell-Widget --------------
00657     //if ( !i386_WIN32_VC_instancia_previa && 
00658     //     !registrar_clases(i386_WIN32_VC_instancia_actual) ) {
00659     //    return FALSE;
00660     //}
00661     if ( i386_WIN32_VC_instancia_previa ) return FALSE;
00662 
00663     //- Vuelve standard los parametros y lanza en main ----------------------
00664     PArametros = PrepArgs(lpCmdLine, &num_params);
00665 
00666 #ifndef MACHETE_MAIN
00667     retorno = main(num_params, PArametros);
00668 #endif
00669 #ifdef MACHETE_MAIN
00670     retorno = Jmain(num_params, PArametros);
00671 #endif
00672 
00673     //- Borra los parametros ------------------------------------------------
00674     for ( i = 0; i < num_params; i++ ) {
00675         free(PArametros[i]);
00676     }
00677     free(PArametros);
00678     return retorno;
00679 }
00680 #endif // CBUILDER
00681 
00682 #endif
00683 
00684 //===========================================================================
00685 //= EOF                                                                     =
00686 //===========================================================================
00687 
00688 // ES UNA LASTIMA QUE ESTE PAR DE FUNCIONES NO FUNCIONEN! POR FAVOR, SI 
00689 // ENCUENTRA SOLUCION MANDEME MAIL!
00690 #ifdef NONONO
00691 #include <stdarg.h>
00692 #include <stdio.h>
00693 
00694 int
00695 jprintf(const char *cadena_de_formato, ...)
00702 {
00703   va_list lista_de_argumentos;
00704   int codigo_de_retorno;
00705 
00706   va_start(lista_de_argumentos, cadena_de_formato);
00707   codigo_de_retorno = printf(cadena_de_formato, lista_de_argumentos);
00708   va_end(lista_de_argumentos);
00709 
00710   return codigo_de_retorno;
00711 }
00712 
00713 int
00714 jprintfe(const char *cadena_de_formato, ...)
00721 {
00722   va_list lista_de_argumentos;
00723   int codigo_de_retorno;
00724 
00725   va_start(lista_de_argumentos, cadena_de_formato);
00726   codigo_de_retorno = fprintf(stderr, cadena_de_formato, lista_de_argumentos);
00727   va_end(lista_de_argumentos);
00728   fflush(stderr);
00729 
00730   return codigo_de_retorno;
00731 }
00732 #endif
00733 

Este archivo HTML ha sido generado automáticamente a partir del código fuente AQUYNZA. NO LO EDITE. Para mayor información contacte al autor.