Changeset 356 for trunk/dll


Ignore:
Timestamp:
Jul 26, 2006, 9:58:37 PM (19 years ago)
Author:
root
Message:

Check more run time errors

Location:
trunk/dll
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/menu.c

    r123 r356  
    77
    88  Copyright (c) 1996-98 M. Kimes
    9   Copyright (c) 2004 Steven H.Levine
     9  Copyright (c) 2004, 2006 Steven H.Levine
    1010
    11   Revisions     01 Aug 04 SHL - Rework lstrip/rstrip usage
     11  01 Aug 04 SHL Rework lstrip/rstrip usage
     12  22 Jul 06 SHL Check more run time errors
    1213
    1314***********************************************************************/
     
    1516#define INCL_DOS
    1617#define INCL_WIN
     18#include <os2.h>
    1719
    18 #include <os2.h>
    1920#include <stdio.h>
    2021#include <stdlib.h>
    2122#include <string.h>
    2223#include <share.h>
     24
    2325#include "fm3dll.h"
    2426#include "menu.h"
    2527
    2628#pragma data_seg(DATA2)
     29
     30static PSZ pszSrcFile = __FILE__;
     31
    2732#pragma alloc_text(MENU,tokenize,FreeMenuList,AddToMenu)
    2833
    2934MENU *menuhead = NULL;
    3035
    31 
    32 INT tokenize (CHAR *str,INT max,CHAR **tokens) {
    33 
     36INT tokenize (CHAR *str,INT max,CHAR **tokens)
     37{
    3438  INT   x = 0;
    3539  CHAR *p;
     
    4953      *p = 0;
    5054      p++;
    51 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"\"%s\"\r\r%d",tokens[x - 1],x);
     55      // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"\"%s\"\r\r%d",tokens[x - 1],x);
    5256      if(!*p)
    5357        break;
     
    5862
    5963
    60 VOID FreeMenuList (MENU *head) {
    61 
     64VOID FreeMenuList (MENU *head)
     65{
    6266  MENU *info,*next;
    6367
     
    7377
    7478
    75 BOOL AddToMenu (CHAR *filename,HWND hwndMenu) {
    76 
     79BOOL AddToMenu (CHAR *filename,HWND hwndMenu)
     80{
    7781  FILE *fp;
    7882  CHAR  s[256];
     
    8286  BOOL  ret = FALSE;
    8387
    84   if(!hwndMenu)
     88  // fixme to complain?
     89  if (!hwndMenu) {
     90    Runtime_Error(pszSrcFile, __LINE__, "no data");
    8591    return ret;
    86   if(!filename)
     92  }
     93  if (!filename)
    8794    filename = "FM3MENU.DAT";
    8895  fp = _fsopen(filename,"r",SH_DENYWR);
    89   if(fp) {
    90     while(!feof(fp)) {
    91       if(!fgets(s,256,fp))
     96  if (!fp) {
     97    // else saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Couldn't open %s",filename);
     98  }
     99  else {
     100    while (!feof(fp)) {
     101      if (!fgets(s,256,fp))
    92102        break;
    93103      lines++;
     
    95105      if(!*s || *s == ';')
    96106        continue;
    97       if(tokenize(s,3,tokens) == 3 && (USHORT)atoi(tokens[1])) {
    98 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%s\r\r%s\r\r%s",tokens[0],tokens[1],tokens[2]);
    99         info = malloc(sizeof(MENU));
    100         if(info) {
    101           memset(info,0,sizeof(MENU));
     107      if (tokenize(s,3,tokens) == 3 && (USHORT)atoi(tokens[1])) {
     108        info = xmallocz(sizeof(MENU),pszSrcFile,__LINE__);
     109        if (info) {
    102110          info->size = sizeof(MENU);
    103           info->text = strdup(tokens[2]);
    104           if(info->text) {
    105             if(!stricmp(tokens[0],"MENUITEM"))
     111          info->text = xstrdup(tokens[2],pszSrcFile,__LINE__);
     112          if (!info->text)
     113            free(info);
     114          else {
     115            if (!stricmp(tokens[0],"MENUITEM"))
    106116              info->cmd = atoi(tokens[1]);
    107             else if(!stricmp(tokens[0],"SEPARATOR"))
     117            else if (!stricmp(tokens[0],"SEPARATOR"))
    108118              info->type = SEPARATOR;
    109             else { /* error! */
     119            else {
     120              /* error! */
    110121              free(info->text);
    111122              free(info);
    112123              info = NULL;
    113124            }
    114             if(info) {
     125            if (info) {
    115126              if(!menuhead)
    116127                menuhead = info;
     
    121132            }
    122133          }
    123           else
    124             free(info);
    125134        }
    126135      }
    127       else {  /* error! */
    128 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tokenization failed");
     136      else {
     137        // fixme to complain?
     138        // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tokenization failed");
    129139      }
    130140    }
    131141    fclose(fp);
    132     if(menuhead) {
    133142
     143    if (menuhead) {
    134144      MENUITEM mi;
    135145
     
    137147      info = menuhead;
    138148      WinEnableWindow(hwndMenu,FALSE);
    139       while(info) {
     149      while (info) {
    140150        mi.iPosition = MIT_END;
    141151        mi.id = info->cmd;
    142152        mi.afStyle = (info->type == SEPARATOR) ? MIS_BREAKSEPARATOR : MIS_TEXT;
    143         if(WinSendMsg(hwndMenu, MM_INSERTITEM, MPFROMP(&mi),
    144                       MPFROMP(info->text)))
     153        if (WinSendMsg(hwndMenu, MM_INSERTITEM, MPFROMP(&mi),
     154                       MPFROMP(info->text)))
    145155          ret = TRUE;
    146156        info = info->next;
     
    151161    }
    152162  }
    153 // else saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Couldn't open %s",filename);
    154163  return ret;
    155164}
  • trunk/dll/notify.c

    r2 r356  
     1
     2/***********************************************************************
     3
     4  $Id$
     5
     6  Notifications
     7
     8  Copyright (c) 1993-98 M. Kimes
     9  Copyright (c) 2006 Steven H.Levine
     10
     11  17 Jul 06 SHL Use Win_Error
     12  22 Jul 06 SHL Check more run time errors
     13
     14***********************************************************************/
     15
    116#define INCL_DOS
    217#define INCL_WIN
    318#define INCL_GPI
    4 
    519#include <os2.h>
     20
    621#include <stdarg.h>
    722#include <stdio.h>
     
    1126#include <time.h>
    1227#include <stddef.h>
     28
    1329#include "fm3dll.h"
    1430#include "fm3dlg.h"
     
    1632
    1733#pragma data_seg(DATA1)
     34
     35static PSZ pszSrcFile = __FILE__;
     36
    1837#pragma alloc_text(NOTIFY,Notify,NotifyWndProc,StartNotify)
    1938#pragma alloc_text(NOTIFY,NotifyThread,NotifyError)
     
    2342static HWND hwndNotify;
    2443
    25 
    26 MRESULT EXPENTRY NotifyWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    27 
     44MRESULT EXPENTRY NotifyWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     45{
    2846  static ULONG showing = 0;
    2947
     
    3957                          ID_TIMER2,
    4058                          5000)) {
    41           DosBeep(50,100);
     59          Win_Error(hwnd,hwnd,pszSrcFile,__LINE__,"WinStartTimer");
    4260          WinDestroyWindow(hwnd);
    4361        }
     
    125143
    126144
    127 HWND DoNotify (char *str) {
    128 
     145HWND DoNotify (char *str)
     146{
    129147  char          *p;
    130148  HWND          hwnd = (HWND)0,hwndP;
     
    157175    /* pretty-up the note by putting on a leading space */
    158176    if(*str != ' ') {
    159       p = malloc(strlen(str) + 2);
     177      p = xmalloc(strlen(str) + 2,pszSrcFile,__LINE__);
    160178      if(!p)
    161179        p = str;
     
    193211
    194212
    195 HWND Notify (char *str) {
    196 
     213HWND Notify (char *str)
     214{
    197215  return (HWND)WinSendMsg(MainObjectHwnd,UM_NOTIFY,MPFROMP(str),MPVOID);
    198216}
    199217
    200218
    201 VOID NotifyError (CHAR *filename,APIRET status) {
    202 
     219VOID NotifyError (CHAR *filename,APIRET status)
     220{
    203221  CHAR errortext[512];
    204222
     
    241259
    242260
    243 MRESULT EXPENTRY NoteWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    244 
     261MRESULT EXPENTRY NoteWndProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     262{
    245263  static HPOINTER hptrIcon = (HPOINTER)0;
    246264
     
    459477
    460478
    461 VOID NoteThread (VOID *args) {
    462 
     479VOID NoteThread (VOID *args)
     480{
    463481  HAB    hab2;
    464482  HMQ    hmq2;
     
    482500
    483501
    484 BOOL StartNotes (CHAR *note) {
    485 
    486   if(!hwndNotify) {
    487     if(_beginthread(NoteThread,
    488                     NULL,
    489                     65536,
    490                     (PVOID)note) != -1)
    491       return TRUE;
    492   }
    493   else
    494     return TRUE;
    495   return FALSE;
    496 }
    497 
    498 
    499 BOOL AddNote (CHAR *note) {
    500 
     502VOID StartNotes (CHAR *note)
     503{
     504  if (!hwndNotify) {
     505    if (_beginthread(NoteThread,NULL,65536,(PVOID)note) == -1)
     506      Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
     507  }
     508}
     509
     510
     511BOOL AddNote (CHAR *note)
     512{
    501513  CHAR *s,*p;
    502514  BOOL  once = FALSE,ret = FALSE;
     
    549561
    550562
    551 VOID EndNote (VOID) {
    552 
     563VOID EndNote (VOID)
     564{
    553565  if(hwndNotify)
    554566    if(!PostMsg(hwndNotify,
     
    563575
    564576
    565 VOID ShowNote (VOID) {
    566 
     577VOID ShowNote (VOID)
     578{
    567579  if(!hwndNotify)
    568580    StartNotes(NULL);
     
    581593
    582594
    583 VOID HideNote (VOID) {
    584 
     595VOID HideNote (VOID)
     596{
    585597  if(hwndNotify)
    586598    WinSetWindowPos(hwndNotify,
  • trunk/dll/presparm.c

    r2 r356  
     1
     2/***********************************************************************
     3
     4  $Id$
     5
     6  Edit presentation parameters
     7
     8  Copyright (c) 1993-98 M. Kimes
     9  Copyright (c) 2006 Steven H.Levine
     10
     11  22 Jul 06 SHL Check more run time errors
     12
     13***********************************************************************/
     14
    115#define INCL_DOS
    216#define INCL_WIN
    317#define INCL_GPI
    4 
    518#include <os2.h>
     19
    620#include <stdarg.h>
    721#include <stdio.h>
     
    923#include <string.h>
    1024#include <ctype.h>
     25
    1126#include "fm3dll.h"
     27
     28static PSZ pszSrcFile = __FILE__;
    1229
    1330#pragma alloc_text(PRESPARAM,CopyPresParams,SetPresParams,IfNoParam)
    1431#pragma alloc_text(PRESPARAM,PresParamChanged,RestorePresParams)
    1532#pragma alloc_text(PRESPARAM,StoreWndPresParams)
    16 
    1733
    1834#ifdef NEVER
     
    2238 * pPresParams ie. WinCreateWindow(,,,,,,,,,,,, PVOID pPresParams)
    2339 */
    24 VOID StoreWndPresParams (HWND hwnd,CHAR *tagname,HINI prof) {
    25 
     40VOID StoreWndPresParams (HWND hwnd,CHAR *tagname,HINI prof)
     41{
    2642  PARAM         *pparam;
    2743  PRESPARAMS    *ppresparams;
     
    3046    return;
    3147  /* setup memory access */
    32   ppresparams = (PRESPARAMS *)malloc(PP_MAXBUF);
     48  ppresparams = (PRESPARAMS *)xmalloc(PP_MAXBUF,pszSrcFile,__LINE__);
    3349  if(!ppresparams)
    3450    return;
     
    322338}
    323339
    324 #endif
    325 
    326 
    327 VOID CopyPresParams (HWND target,HWND source) {
    328 
     340#endif // NEVER
     341
     342
     343VOID CopyPresParams (HWND target,HWND source)
     344{
    329345  /*
    330346   * Copy presentation parameters of interest to us from one window
     
    355371
    356372
    357 VOID SetPresParams (HWND hwnd,RGB2 *back,RGB2 *fore,RGB2 *border,CHAR *font) {
    358 
     373VOID SetPresParams (HWND hwnd,RGB2 *back,RGB2 *fore,RGB2 *border,CHAR *font)
     374{
    359375  if(font)
    360376    WinSetPresParam(hwnd,
     
    380396
    381397
    382 VOID IfNoParam(HWND hwnd,CHAR *keyroot,ULONG size,PVOID attrvalue) {
    383 
     398VOID IfNoParam(HWND hwnd,CHAR *keyroot,ULONG size,PVOID attrvalue)
     399{
    384400  ULONG  fsize = 0L;
    385401  CHAR   s[81];
     
    400416
    401417
    402 VOID PresParamChanged (HWND hwnd,CHAR *keyroot,MPARAM mp1,MPARAM mp2) {
    403 
    404   ULONG AttrFound,AttrValue[64],cbRetLen;
     418VOID PresParamChanged (HWND hwnd,CHAR *keyroot,MPARAM mp1,MPARAM mp2)
     419{
     420    ULONG AttrFound,AttrValue[64],cbRetLen;
    405421
    406422  cbRetLen = WinQueryPresParam(hwnd,(ULONG)mp1,0,&AttrFound,
     
    440456
    441457
    442 VOID RestorePresParams (HWND hwnd,CHAR *keyroot) {
    443 
    444   CHAR  s[81];
     458VOID RestorePresParams (HWND hwnd,CHAR *keyroot)
     459{
     460    CHAR  s[81];
    445461  ULONG AttrValue[64],size;
    446462
Note: See TracChangeset for help on using the changeset viewer.