[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

Y2K issue with C++

A programmer in my office wrote a program to read a classified(newspaper) dump file, strip off the tags and format it for the web.  Unfortunatel it puts the 1900 date on the web and not the 2000.  There is a idd_getdate dialog that allows the user to put the date of the classifieds in, but for some reason it writes incorrectly in the html.  That programmer is no longer with us, so I, a beginning programmer, am at a loss.  Any idea where I should start looking.


Thank you,
Patrick
0
patrickm3
Asked:
patrickm3
  • 8
  • 6
1 Solution
 
jhanceCommented:
Do you have the source code to the application?  

If not, get your lawyers to find the departed programmer.


If so, find the line(s) that output the HTML.  See what is going on there and why the 2000 that is entered is being output as 1900.  If the data coming into this part of the program is wrong, then trace it back until you find where the wrong date is being formatted.


My guess is that the program was written with something like:

sprintf(lpszBuffer, "Year: 19%02d", year);

in it.  

If it's something else, post it here and I'll try and help you interpret it.
0
 
patrickm3Author Commented:
I do have the source code, but I cant find that string

I'll be happy to award points if you have any other possibilities to offer.
0
 
jhanceCommented:
Let me get this straight.  You want me to point you to the exact spot in your program that this problem is happening without you posting so much as a single line of your code?

I'm sorry, I may be good but I'm not that good!



My example was just that, an EXAMPLE!  I didn't expect you to find that exact string, it was meant as a guide.

What is the EXACT HTML that the program is putting in the output file?

Find the code that write this out and see what data it's being given.

Trace it back from there.  

If you're lost, POST SOME CODE!!
0
Turn Raw Data into a Real Career

There’s a growing demand for qualified analysts who can make sense of Big Data. With an MS in Data Analytics, you can become the data mining, management, mapping, and munging expert that today’s leading corporations desperately need.

 
patrickm3Author Commented:
/********************************************************************************************
*                                                                                                                                          *
* Filename: proclass.c                                                                                                            *
* Date: 06/07/98                                                                                                                  *
* Description: Build Pocono Records Online Classifieds & Find It Online coding.             *
* Author: John Bergeron                                                                                                            *
*                                                                                                                                          *
* Version 1.0                                                                                                                        *
* More to come....                                                                                                                  *
*                                                                                                                                          *
********************************************************************************************/

#include <windows.h>            // required for all Windows applications
#include <commdlg.h>                  // prototypes and defs for common dialogs
#include <commctrl.h>           // prototypes and defs for common controls
#include "proclass.h"           // prototypes specific to this application
#include <stdio.h>
#include <process.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/timeb.h>
#include <fcntl.h>
#include <io.h>





#define      header      "<html>\n<head>\n<title>\nPocono Record Online Classifieds: %s\n</title>\n</head>\n<body bgcolor=#ffffff>\n<center><img src=\"/class/images/graphics/%s\" width=400 height=75 alt=\"%s\"></center><p>\n"
#define footer      "<p>Copyright © %s %s, 20%i Pocono Record<br></body></html>"
#define defaultfiopage      "<html>\n<body>\n<p>\n<font size=5><b>%s</b></font>\n<!--NEW SUBCATEGORY:%s-->\n<p>\n<p>\n<hr>\n<p>\n\n<!--THIS CATEGORY HAS NO ADS!-->\n</body></html>"


HBITMAP mybackground1;
HBITMAP mybackground1t;

HINSTANCE g_hInst;            // the current instance            

HWND pbar;
HWND mainwindow;
HWND hAni;

HMENU hMenu;

int killthread = 0;


//
//  FUNCTION: MyRegisterClass(CONST WNDCLASS*)
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//       This function and its usage is only necessary if you want this code
//       to be compatible with Win32 systems prior to the 'RegisterClassEx'
//      function that was added to Windows 95. It is important to call this function
//       so that the application will get 'well formed' small icons associated
//       with it.
//
ATOM MyRegisterClass(CONST WNDCLASS *lpwc)
{
      HANDLE  hMod;
      FARPROC proc;
      WNDCLASSEX wcex;

      hMod = GetModuleHandle ("USER32");
      if (hMod != NULL) {

#if defined (UNICODE)
            proc = GetProcAddress (hMod, "RegisterClassExW");
#else
            proc = GetProcAddress (hMod, "RegisterClassExA");
#endif

            if (proc != NULL) {

                  wcex.style         = lpwc->style;
                  wcex.lpfnWndProc   = lpwc->lpfnWndProc;
                  wcex.cbClsExtra    = lpwc->cbClsExtra;
                  wcex.cbWndExtra    = lpwc->cbWndExtra;
                  wcex.hInstance     = lpwc->hInstance;
                  wcex.hIcon         = lpwc->hIcon;
                  wcex.hCursor       = lpwc->hCursor;
                  wcex.hbrBackground = lpwc->hbrBackground;
                              wcex.lpszMenuName  = lpwc->lpszMenuName;
                  wcex.lpszClassName = lpwc->lpszClassName;

                  // Added elements for Windows 95:
                  wcex.cbSize = sizeof(WNDCLASSEX);
                  wcex.hIconSm = LoadIcon(wcex.hInstance, "SMALL");
                  
                  return (*proc)(&wcex);//return RegisterClassEx(&wcex);
            }
      }
      return (RegisterClass(lpwc));
}




//***************************************************************************************
//  FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
//
//  PURPOSE: Entry point for the application.
//
//  COMMENTS:
//
//      This function initializes the application and processes the
//      message loop.



int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow )
{

    MSG msg;                        

    if (!InitApplication(hInstance))
            return (FALSE);              

    // Create the main window.
    if (!InitInstance(hInstance, nCmdShow))
        return (FALSE);

    // Acquire and dispatch messages until a WM_QUIT message is received.
    while (GetMessage(&msg,NULL,0,0))
        {
            TranslateMessage(&msg);    // Translates virtual key codes.
            DispatchMessage(&msg);     // Dispatches message to window.
        }
    return (msg.wParam);           // Returns the value from PostQuitMessage.

}

//****************************************************************************************
//  FUNCTION: InitApplication(HANDLE)
//
//  PURPOSE: Initializes window data and registers window class
//
//  COMMENTS:
//
//       In this function, we initialize a window class by filling out a data
//       structure of type WNDCLASS and calling the Windows RegisterClass()
//       function.



BOOL InitApplication(HANDLE hInstance)      
{
    WNDCLASS  wc;

    // Register the window class for my window.                                                           */
    wc.style = 0;                       // Class style.
    wc.lpfnWndProc = (WNDPROC)MainWndProc; // Window procedure for this class.
    wc.cbClsExtra = 0;                  // No per-class extra data.
    wc.cbWndExtra = 0;                  // No per-window extra data.
    wc.hInstance = hInstance;           // Application that owns the class.
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
    wc.lpszMenuName =  "PROCLASSMenu";   // Name of menu resource in .RC file.
    wc.lpszClassName = "Proclass"; // Name used in call to CreateWindow.

      return MyRegisterClass(&wc);
   
}

//*****************************************************************************************
//   FUNCTION: InitInstance(HANDLE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.



BOOL InitInstance( HANDLE hInstance, int nCmdShow)          
{
    HWND            hWnd;              

      // Save off the handle to the current instance.
    g_hInst = hInstance;

    // Create a main window for this application instance.
    hWnd = CreateWindow(
        "Proclass",
        "Pocono Record Online Classifieds Builder!",
        MDIS_ALLCHILDSTYLES | WS_MINIMIZEBOX | WS_SYSMENU,   // Window style (user may not resize).
        CW_USEDEFAULT,                  // Default horizontal position.
        CW_USEDEFAULT,                  // Default vertical position.
        605,                  // Default width.
        370,                  // Default height.
        NULL,                           // Overlapped windows have no parent.
        NULL,                           // Use the window class menu.
        g_hInst,                        // This instance owns this window.
        NULL                            // Pointer not needed.
    );

      mainwindow = hWnd;
    // If window could not be created, return "failure".
    if (!hWnd)
        return (FALSE);

    // Make the window visible; update its client area; and return "success".
    mybackground1 = LoadBitmap(g_hInst, MAKEINTRESOURCE(background));
      mybackground1t = LoadBitmap(g_hInst, MAKEINTRESOURCE(background));
      ShowWindow(hWnd, nCmdShow);  
    UpdateWindow(hWnd);          
    return (TRUE);              

}

//******************************************************************************************
//  FUNCTION: MainWndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  MESSAGES:
//
//      WM_CREATE - initialize window and create the MLE
//      WM_COMMAND - process the application menu
//      WM_SIZE - size the main window
//      WM_DESTROY - post a quit message and return
//
//



LONG APIENTRY MainWndProc( HWND hWnd, UINT message, UINT wParam, LONG lParam)
{

      


      static HWND hwndEdit;
    CHAR lpszHello[] = "Choose File Open from the Options menu for a demo.";
      
    switch (message) {

        case WM_CREATE:

                  
                  InitCommonControls();
      
            
            // Create progress meter
            
       hwndprog = CreateWindowEx(
      WS_EX_CLIENTEDGE,      // extended window style
   PROGRESS_CLASS,      // pointer to registered class name
    "meter",      // pointer to window name
    WS_CHILD | WS_VISIBLE,      // window style
    90,      // horizontal position of window
    195,      // vertical position of window
    490,      // window width
    22,      // window height
    hWnd,      // handle to parent or owner window
    (HMENU) ID_EDITCHILD,      // handle to menu, or child-window identifier
    (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),      // handle to application instance
   NULL       // pointer to window-creation data
   );
            
//pbar = hwndprog;
            
            // Create static text for status.

                  Statictext = CreateWindowEx(
                        WS_EX_CLIENTEDGE,

                "STATIC",    
                        NULL,      
                WS_CHILD | WS_VISIBLE | ES_CENTER ,
               15, 250, 570, 25,
               hWnd,      
                (HMENU) ID_EDITCHILD,
              (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),
               NULL);              

                                    sectiontext = CreateWindowEx(
                        WS_EX_CLIENTEDGE,

                "STATIC",    
                        NULL,      
                WS_CHILD | WS_VISIBLE | ES_CENTER ,
               220, 285, 150, 25,
               hWnd,      
                (HMENU) ID_EDITCHILD,
              (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),
               NULL);              

            hAni = Animate_Create( hWnd, 1000, WS_CHILD | WS_VISIBLE |
              ACS_CENTER | ACS_TRANSPARENT , g_hInst );    //ACS_TRANSPARENT
         if( hAni )
         {                          //  Give it the AVI in this app's resources
            Animate_Open( hAni, "PMAN" );
            SetWindowPos( hAni, NULL, 25, 15, 64, 128,
                          SWP_NOZORDER );
         }

 
        // Write to status bar.
                  
         SetWindowText(Statictext, "Welcome! Please Select the \"Build Classifieds\" from the \"File\" menu." );
        
          //  return 0;
         break;

            case WM_MOVE:
            case WM_SHOWWINDOW:
            case WM_NOTIFY:
            case WM_PAINT:
            case WM_DRAWITEM:

                  
                  // Paint the bitmap to the main window.
      //            mybackground1 = mybackground1t;
      //            MsgPaint(mainwindow, message, wParam, lParam);
      //                  break;

        case WM_SIZE:
                   
           MsgPaint( hWnd, message, wParam, lParam);
                        break;

        case WM_COMMAND:           // message: command from application menu
           //MsgPaint( hWnd, message, wParam, lParam);
                  hMenu = GetMenu(mainwindow);
                  
                  switch( LOWORD( wParam ))
            {
                case IDM_FILEOPEN:
                        
                        
                              EnableMenuItem(hMenu, (WORD)IDM_FILEOPEN, MF_GRAYED);
                              EnableMenuItem(hMenu, (WORD)IDM_ABORT, MF_ENABLED );
                        
                        SetWindowText(Statictext, "" );

            // Call the GetDate dialog to retrieve the date.
                              DialogBox(g_hInst,
                        MAKEINTRESOURCE(IDD_GETDATE),
                        hWnd,          
                        (DLGPROC)GetDate);

                              if(gotdate == 1)
                                 {      DialogBox(g_hInst,
                            MAKEINTRESOURCE(IDD_INTRO),
                            hWnd,          
                            (DLGPROC)Welcome);
                                }


                              
            // Call the FileOpen common dialog to open the file if user entered correct date.
                    if(gotdate == 1)
                              {
                                    OpenTheFile( hWnd, hwndEdit );
                              } else
                              {
                              EnableMenuItem(hMenu, (WORD)IDM_FILEOPEN, MF_ENABLED);
                              EnableMenuItem(hMenu, (WORD)IDM_ABORT, MF_GRAYED);
                              }

                   
                              
                              break;

                case IDM_EXIT:
                    PostQuitMessage(0);
                    break;

            // Abort!                  

                              case IDM_ABORT:
                                    MsgPaint(mainwindow, message, wParam, lParam);
                              EnableMenuItem(hMenu, (WORD)IDM_FILEOPEN, MF_ENABLED);
                              EnableMenuItem(hMenu, (WORD)IDM_ABORT, MF_GRAYED );
                                    killthread = 1;
                        break;
            // Fire up about dialog.
                case IDM_ABOUT:
                  
                    DialogBox(g_hInst,
                        MAKEINTRESOURCE(IDD_ABOUT),
                        hWnd,          
                       (DLGPROC)About);

                              break;

                default:
                    return (DefWindowProc(hWnd, message, wParam, lParam));

            }
            break;

        case WM_DESTROY:                  // message: window being destroyed
                  MsgDestroy( hWnd, message, wParam, lParam);
            PostQuitMessage(0);
            break;


        default:
            return (DefWindowProc(hWnd, message, wParam, lParam));
    }
    return (0);
}



//******************************************************************************************
//  FUNCTION: OpenTheFile( HWND hWnd, HWND hWndEdit )
//
//  PURPOSE:  Will open the common dialog (openfile).
//
//  
//
//



BOOL OpenTheFile( HWND hWnd, HWND hWndEdit )
{
      struct _stat buf;
    FILE *hFile;
//      DWORD dwFileSize;
      OPENFILENAME OpenFileName;
      TCHAR         szFile[MAX_PATH]      = "\0";
//      DWORD cb;
      int l, c;
      long totalbytes, flength;
      strcpy( szFile, "");


      // Fill in the OPENFILENAME structure
      OpenFileName.lStructSize       = sizeof(OPENFILENAME);
    OpenFileName.hwndOwner         = hWnd;
    OpenFileName.lpstrFilter       = "All Files\0*.*\0";    
    OpenFileName.lpstrCustomFilter = NULL;
    OpenFileName.nMaxCustFilter    = 0;
    OpenFileName.nFilterIndex      = 0;
    OpenFileName.lpstrFile         = szFile;
    OpenFileName.nMaxFile          = sizeof(szFile);
    OpenFileName.lpstrFileTitle    = NULL;
    OpenFileName.nMaxFileTitle     = 0;
    OpenFileName.lpstrInitialDir   = "a:\\";    
    OpenFileName.lpstrTitle        = "Open Classified Dump File";
    OpenFileName.nFileOffset       = 0;
    OpenFileName.nFileExtension    = 0;
    OpenFileName.lpstrDefExt       = NULL;
   
    OpenFileName.Flags             = OFN_EXPLORER;


      if(!GetOpenFileName(&OpenFileName))
      {
            EnableMenuItem(hMenu, (WORD)IDM_FILEOPEN, MF_ENABLED);
            EnableMenuItem(hMenu, (WORD)IDM_ABORT, MF_GRAYED);
            return FALSE;            
      }
     
            _stat(szFile, &buf );

            flength = ((long)buf.st_size / 20000);

            


      hFile = fopen(szFile, "r");
            if(hFile == NULL)

            {
                  MessageBox( mainwindow, "File open failed.", "Pocono Record Online: Error", MB_OK );
                return FALSE;
            }

      
            section = 0;
      
            totalbytes = 0;

            strcpy(file[0].section," \n\n");
            for(l = 0; l <= 30; l++) strcpy(file[l].section," \n\n");
      l = 0;
      

      SendMessage(hwndprog, PBM_SETPOS , 0, 0);
wsprintf(tmpstr, "Reading %s", szFile);
      SetWindowText(Statictext, tmpstr );
      // Set progress bar range from 0 to 100 (default).

SendMessage(hwndprog, PBM_SETRANGE, 0, MAKELPARAM(0, 100));

      
      while(fgets(filestr, 512, hFile) != NULL)
{

      l += (int)strlen(filestr);
      totalbytes += (int)strlen(filestr);

      if((int)strlen(filestr) > 500)
            MessageBox( mainwindow, "Line is > 500!", "Pocono Record Online: Error", MB_OK );
      
      strcat(file[section].section, filestr);
      c++;
      if(l > 20000)
      {
            l = 0;
      strcat(file[section].section, " \n\n ");
            section++;
            if(section > 10)
                  SendMessage(hwndprog, PBM_SETPOS, 0, 100);
                  else
                  SendMessage(hwndprog, PBM_STEPIT, 0, 0);
            
      }
}

SendMessage(hwndprog, PBM_SETPOS, 0, 100);

strcat(file[section].section, " \n\n ");
fclose(hFile);

 SendMessage(hwndprog, PBM_SETPOS , 0, 0);

      // Set progress bar range from 0 to 100 (default).

SendMessage(hwndprog, PBM_SETRANGE, 0, MAKELPARAM(0, 100));

    wsprintf(tmpstr, "Reading %s", szFile);
      SetWindowText(Statictext, tmpstr );

      //SendMessage(hwndprog, PBM_SETPOS , 100, 0);
   //wsprintf(tmpstr, "File %s read", szFile);
         //wsprintf(tmpstr, "The size of dumpfile is: %i", (int)strlen(dumpfile));
      SetWindowText(Statictext, "Parsing file.");

      // Go to file parsing function

//SendMessage(hWnd,"WM_PAINT", 0,0);
_beginthread(parsefile, 0, NULL );


            return TRUE;

      
}

//***********************************************************************************
//  FUNCTION: GetDate( HWND hDlg, UINT message, UINT wParam, LONG lParam)
//
//  PURPOSE: GetDate dialog procedure function.
//
//
//  COMMENTS:
//


BOOL APIENTRY GetDate( HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
      RECT rc;
      char tmonth[16];
      int tmonthint;


    switch (message)
    {
        case WM_INITDIALOG:      
                  
                  
 
    GetWindowRect(hDlg, &rc);
 
    SetWindowPos(hDlg, NULL,
       ((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
       ((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
       0, 0, SWP_NOSIZE | SWP_NOACTIVATE);

                  CheckDlgButton(hDlg,sunradio, 1);
            return (TRUE);

        case WM_COMMAND:                      
            if (LOWORD(wParam) == IDOK )
            {    
                        gotdate = 0;
                  // Get and check date format.

                        GetDlgItemText(hDlg, IDC_DATE, szDate, 12);
                        
                        if(strlen(szDate) != 6)
                        {
                              MessageBox(hDlg,"You didn't enter a valid date!", "Pocono Record Online: Error",MB_ICONHAND);
                              return FALSE;
                        }

                  // Check to see what button was selected.

                        if(IsDlgButtonChecked(hDlg,sunradio)) strcpy(szDay, "Sunday");
                        if(IsDlgButtonChecked(hDlg,monradio)) strcpy(szDay, "Monday");
                        if(IsDlgButtonChecked(hDlg,tueradio)) strcpy(szDay, "Tuesday");
                        if(IsDlgButtonChecked(hDlg,wedradio)) strcpy(szDay, "Wednesday");
                        if(IsDlgButtonChecked(hDlg,thuradio)) strcpy(szDay, "Thursday");
                        if(IsDlgButtonChecked(hDlg,friradio)) strcpy(szDay, "Friday");
                        if(IsDlgButtonChecked(hDlg,satradio)) strcpy(szDay, "Saturday");
                  
                        szDaynum[0] = szDate[4];
                        szDaynum[1] = szDate[5];
                        szDaynum[2] = '\0';

                        if(atoi(szDaynum) > 31)
                        {
                              MessageBox(hDlg,"You didn't enter a valid date!", "Pocono Record Online: Error",MB_ICONHAND);
                              return FALSE;
                        }
                        
                        if(atoi(szDaynum) < 1)
                        {
                              MessageBox(hDlg,"You didn't enter a valid date!", "Pocono Record Online: Error",MB_ICONHAND);
                              return FALSE;
                        }

                        
                        szYear[0] = '1';
                        szYear[1] = '9';
                        szYear[2] = szDate[0];
                        szYear[3] = szDate[1];
                        szYear[4] = '\0';

                        tmonth[0] = szDate[2];
                        tmonth[1] = szDate[3];
                        tmonth[2] = '\0';
                        
                  //      strcpy(szMonthnum, tmonth);
//MessageBox(hDlg,szMonthnum, "Pocono Record Online: Error",MB_ICONHAND);
                        tmonthint = atoi(tmonth);

                              if(tmonthint > 12)
                              {
                              MessageBox(hDlg,"You didn't enter a valid date!", "Pocono Record Online: Error",MB_ICONHAND);
                              return FALSE;
                              }

                              if(tmonthint < 1)
                              {
                              MessageBox(hDlg,"You didn't enter a valid date!", "Pocono Record Online: Error",MB_ICONHAND);
                              return FALSE;
                              }


                        switch (tmonthint)
                        {
                        case 1:
                              strcpy(szMonth, "January");
                              break;
                        
                        case 2:
                              strcpy(szMonth, "February");
                              break;

                        case 3:
                              strcpy(szMonth, "March");
                              break;


                        case 4:
                              strcpy(szMonth, "April");
                              break;

                              
                        case 5:
                              strcpy(szMonth, "May");
                              break;

                        case 6:
                              strcpy(szMonth, "June");
                              break;
                              
                        case 7:
                              strcpy(szMonth, "July");
                              break;
                              
                        case 8:
                              strcpy(szMonth, "August");
                              break;

                        case 9:
                              strcpy(szMonth, "September");
                              break;

                        case 10:
                              strcpy(szMonth, "October");
                              break;
                              
                        case 11:
                              strcpy(szMonth, "November");
                              break;
                              
                        case 12:
                              strcpy(szMonth, "December");
                              break;
                        }
                        
                        // Added for testing

//                        wsprintf(tmpstr, "The date is: %s and the day is: %s and the month is %s!", szDate, szDay, szMonth);
//                        MessageBox(hDlg,tmpstr, "Pocono Record Online",MB_ICONHAND);


                        // Get info and update our date file (clasdate.txt)
                                                                                     
      

                        // We got a proper date and day so set "gotdate" to 1.
                        gotdate = 1;
                        // Kill dialog, were done!
                EndDialog(hDlg, TRUE);        
                return TRUE;
                        
                        
            }

                  if(LOWORD(wParam) == IDCANCEL)
                  {
                        gotdate = 0;
                        EndDialog(hDlg, TRUE);
                        SetWindowText(Statictext, "Welcome! Please Select the \"Build Classifieds\" from the \"File\" menu." );
                return TRUE;
                  }

            break;
    }
    return FALSE;                          

}

BOOL APIENTRY Welcome( HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
      RECT rc;
      FILE *hFile;

    switch (message)
    {
        case WM_INITDIALOG:
                  GetWindowRect(hDlg, &rc);
 
    SetWindowPos(hDlg, NULL,
       ((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
       ((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
       0, 0, SWP_NOSIZE | SWP_NOACTIVATE);

                  
            return (TRUE);

        case WM_COMMAND:                      
            if (LOWORD(wParam) == IDOK )
            {        
                EndDialog(hDlg, TRUE);        
                        hFile = fopen("n:\\Web\\Template\\clasdate.txt", "r");
            if(hFile == NULL)

            {
                  MessageBox( mainwindow, "Could not open n:\\web\\template\\clasdate.txt for reading", "Pocono Record Online: Error", MB_OK );
                return FALSE;
            }


if(fgets(sundate, 56, hFile) == NULL)
{
                  MessageBox( mainwindow, "Could not read n:\\web\\template\\clasdate.txt", "Pocono Record Online: Error", MB_OK );
                return FALSE;
}else
sundate[strlen(sundate) - 1] = '\0';

if(fgets(mon_satday, 56, hFile) == NULL)
{
                  MessageBox( mainwindow, "Could not read n:\\web\\template\\clasdate.txt", "Pocono Record Online: Error", MB_OK );
                return FALSE;
}else
  mon_satday[strlen(mon_satday) - 1] = '\0';

if(fgets(mon_satdate, 56, hFile) == NULL)
{
                  MessageBox( mainwindow, "Could not read from n:\\web\\template\\clasdate.txt", "Pocono Record Online: Error", MB_OK );
                return FALSE;
}else
mon_satdate[strlen(mon_satdate) - 1] = '\0';


fclose(hFile);

      szDaynum[0] = szDate[4];
      szDaynum[1] = szDate[5];
      szDaynum[2] = '\0';


if(szDay[0] == 'S' && szDay[1] == 'u')
{
      wsprintf(sundate,"%s %s, %s", szMonth, szDaynum, szYear);
}else
{

      wsprintf(mon_satdate,"%s %s, %s", szMonth, szDaynum, szYear);
      strcpy(mon_satday, szDay);
}

wsprintf(tmpstr, "%s\n%s\n%s\n", sundate, mon_satday, mon_satdate);

hFile = fopen("n:\\Web\\Template\\clasdate.txt", "w");
            if(hFile == NULL)

            {
                  MessageBox( mainwindow, "Could not open n:\\web\\template\\clasdate.txt for writing", "Pocono Record Online: Error", MB_OK );
                return FALSE;
            }

if(fwrite( tmpstr, sizeof( char ), (int)strlen(tmpstr), hFile ) == 0)
      {
                  MessageBox( mainwindow, "Could not write to n:\\web\\template\\clasdate.txt", "Pocono Record Online: Error", MB_OK );
                return FALSE;
      }

fclose(hFile);
                gotdate = 1;
                        return TRUE;
            }

                  if(LOWORD(wParam) == IDH_CANCEL)
                        gotdate = 0;
                   EndDialog(hDlg, TRUE);  
            break;
    }
    return FALSE;                          


}

//***********************************************************************************
//  FUNCTION: About( HWND hDlg, UINT message, UINT wParam, LONG lParam)
//
//  PURPOSE: About dialog procedure function.
//
//
//  COMMENTS:
//


BOOL APIENTRY About( HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
      RECT rc;

    switch (message)
    {
        case WM_INITDIALOG:
                  GetWindowRect(hDlg, &rc);
 
    SetWindowPos(hDlg, NULL,
       ((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
       ((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
       0, 0, SWP_NOSIZE | SWP_NOACTIVATE);

                  
            return (TRUE);

        case WM_COMMAND:                      
            if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
            {        
                EndDialog(hDlg, TRUE);        
                return TRUE;
            }
            break;
    }
    return FALSE;                          

}


//***********************************************************************************
//  FUNCTION: Blast(HWND hWnd, HDC PaintDC)
//
//  PURPOSE: Blast the bitmap object to the main window.
//
//
//  COMMENTS:
//


void Blast(HWND hWnd, HDC PaintDC)
{
       HDC memDC;
        RECT clientRect;
        HANDLE oldBmp;
            GetClientRect(hWnd, &clientRect);
        memDC = CreateCompatibleDC(PaintDC);
        oldBmp = SelectObject(memDC, mybackground1);
        BitBlt(PaintDC, 0, 0,755, 740, memDC, 0, 0, SRCCOPY);
        SelectObject(memDC, oldBmp);
        DeleteDC(memDC);        
}


//***********************************************************************************
//  FUNCTION: MsgPaint(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
//
//  PURPOSE: Calls Blast and displays the bitmap object.
//
//
//  COMMENTS:
//




LRESULT MsgPaint(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
      HDC PaintDC;
        PAINTSTRUCT PS;

      PaintDC = BeginPaint(hwnd, &PS);

                  Blast(hwnd, PaintDC);

      EndPaint(hwnd, &PS);
//SetWindowText(Statictext, "********************Painting*****************");
return 0;      

}


//***********************************************************************************
//  FUNCTION: MsgDestroy(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE: Calls PostQuitMessage() and destroys bitmap object.
//
//  PARAMETERS:
//
//    hwnd      - Window handle  (Unused)
//    uMessage  - Message number (Unused)
//    wparam    - Extra data     (Unused)
//    lparam    - Extra data     (Unused)
//
//  RETURN VALUE:
//
//    Always returns 0 - Message handled
//
//  COMMENTS:
//



LRESULT MsgDestroy(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
{


      DeleteObject(mybackground1);
      
    PostQuitMessage(0);
    return 0;
}


int parsefile(void *dummy)
{
      int findbegin, findend, cnt, counter, byteswritten = 0, lastfind = 0, nextfind1, nextfind = 0;
      char *start;
      struct tm *newtime;
      time_t ltime;
      HANDLE hFile;
    char fullpath[256];
      char URLstring[256];
      char searchURLstring[256];
      char tmpURLstring[256];
      char theheader[512];
      char thefooter[512];

       Animate_Play( hAni, 0, 5, -1 );
      thesection = 0;

      SendMessage(hwndprog, PBM_SETPOS , 0, 0);
      SetWindowText(Statictext, "Files now being purged." );

      
      Checkabort();

      if(szDay[0] == 'S' && szDay[1] == 'u')
{
      remove("n:\\web\\3_final\\class\\SClasmain.htm");
      remove("n:\\web\\3_final\\class\\Sun_menu.htm");
      remove("n:\\web\\3_final\\class\\Clasmenu.htm");
      remove("n:\\web\\3_final\\class\\Clasindx.htm");
      remove("n:\\web\\3_final\\class\\2daymenu.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Annou.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Auction.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Auto.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Employ.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Employ1.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Free.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Legals.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Merchan.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Pets&liv.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Realest.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Recre.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Rentals.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Serdir.htm");
      remove("n:\\web\\3_final\\class\\Sunday\\Sections\\Service.htm");
      

} else
{
      remove("n:\\web\\3_final\\class\\Clasmain.htm");
      remove("n:\\web\\3_final\\class\\Sun_menu.htm");
      remove("n:\\web\\3_final\\class\\Clasmenu.htm");
      remove("n:\\web\\3_final\\class\\Clasindx.htm");
      remove("n:\\web\\3_final\\class\\2daymenu.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Annou.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Auction.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Auto.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Employ.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Free.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Legals.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Merchan.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Pets&liv.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Realest.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Recre.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Rentals.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Serdir.htm");
      remove("n:\\web\\3_final\\class\\Sections\\Service.htm");
}
      
//

// Set progress bar step range to 1.

SendMessage(hwndprog, PBM_SETSTEP, 1, 0);


// Now step the progress bar a few time just for testing.
Checkabort();

while(thesection <= section)
{
      Checkabort();
      wsprintf(tmpstr, "Section %i of %i", (thesection + 1), (section + 1));
      SetWindowText(sectiontext, tmpstr );
      SetWindowText(Statictext, "Removing: <" );
    SendMessage(hwndprog, PBM_SETPOS , 0, 0);

      
      SetWindowText(Statictext, "Replacing: < with: <br>" );

/////////////////////////////////////////////////////////
// Replace or remove the needed control characters      
////////////////////////////////////////////////////////

      start = NULL;
      while (start != file[thesection].section)
      {
            SendMessage(hwndprog, PBM_STEPIT , 0, 0);
            start = strrepl(file[thesection].section, sizeof(file[thesection].section), "<", "-!linebreak!-\n");
      }

      start = NULL;
      while (start != file[thesection].section)
      {
            SendMessage(hwndprog, PBM_STEPIT , 0, 0);
            start = strrepl(file[thesection].section, sizeof(file[thesection].section), "\\+", "-!plus!-");
      }
      
start = NULL;
      while (start != file[thesection].section)
      {
            SendMessage(hwndprog,
0
 
jhanceCommented:
This looks VERY suspicious!!

In the function GetDate():

szYear[0] = '1'; <--------------
szYear[1] = '9'; <--------------
szYear[2] = szDate[0];
szYear[3] = szDate[1];
szYear[4] = '\0';

tmonth[0] = szDate[2];
tmonth[1] = szDate[3];
tmonth[2] = '\0';


0
 
patrickm3Author Commented:
October 03, 1900
Wednesday
January 05, 2000


this is the clasdate.txt that is generated.  This then gets put into an html template.  Unfortunately the change you suggested hasn't fixed this problem.  Thanks for trying--I really appreciate all of your time and effort.  Is there anything else that could cause this to be incorrect--the date I input is correct 000105.


Tahnks Patrick
0
 
jhanceCommented:
I don't understand you last comment.

What is wrong with:

January 05, 2000

???



It's pretty clear that:

szYear[0] = '1';
szYear[1] = '9';

is at least PART of the problem.  There is no way that the date will ever be anything but 19XX.  How did you change this?  If you make it:

szYear[0] = '2';
szYear[1] = '0';

It should be OK for the next 100 years.
0
 
jhanceCommented:
Here is the only place I see szYear being used:

if(szDay[0] == 'S' && szDay[1] == 'u')
             {
             wsprintf(sundate,"%s %s, %s", szMonth, szDaynum, szYear);
             }else
             {

             wsprintf(mon_satdate,"%s %s, %s", szMonth, szDaynum, szYear);
             strcpy(mon_satday, szDay);
             }

It's just formatting it as a string so if the above change is made this should take care of it.
0
 
jhanceCommented:
I still don't see anywhere in this code where HTML is being generated.  The classdate.txt file doesn't appear to be HTML.  It seems like there must be some other functions that do the HTML. It wouldn't surprise me if the exact same problem exists in that file as well.
0
 
patrickm3Author Commented:
I did change it to

szYear[0] = '2';
szYear[1] = '0';

the problem with the clasdate.txt is that the date for the sunday classifieds is wrong
it comes up as
October 03, 1900

the current date is correct and was corrected by the remedy you suggested.  

Is the sunday date incorrect because the ads were already archived?  Or is it still a programming issue?

The sunday classifieds remain in a folder all week until they are overwritten the following sunday.  the dail ads are overritten every day.



thanks
patrick
0
 
patrickm3Author Commented:
The clasdate.txt is called by a word macro and an html page is generated.  That is not done by the program in question.  I will redo the sunday ads and not upload them to the server and see  if the sunday date is correct.


Patrick
0
 
jhanceCommented:
Hmmm, I'm not sure I understand:

You say you input "000105" into the form and the date generated is:

October 3, 1900

into the classdate.txt file?
0
 
patrickm3Author Commented:
Actually, it seems that the sunday date stays constant until sunday and the daily date changes daily.  Dont know where in the code that is written.  Apparently, on sunday someone must have typed 001003  hence oct 3 1900, it was apparently'archived' that way.  I ran the sunday for tomorrows date and all went well
January 06, 2000
Wednesday
January 05, 2000

I'm sure the wednesday will change to thurs tomorrow when I choose it.

Thank you for all the help, sorry I'm slow at this.  Is there a way that this program can be modified so that it can format the info for a quark document and not the web--hence-not adding html tags?  It would come in handy if it just output plain text.

Thanks again
0
 
jhanceCommented:
>on sunday someone must have typed 001003  hence oct 3

I'll bet there is a data file somewhere with the "lame" date in it.

>Is there a way that this program can be modified

Just about anything is possible.  I take it you no longer have a programmer on staff since you said he left the company.

I'm a free-lance software developer and would be happy to discuss enhancing (actually, I'd suggest trashing it and starting over) this application and getting it to do exactly what you want it to do.

If you want to talk further, you can email me at jwh20@hotmail.com

Glad to have been of assistance in any case.

JHANCE
0

Featured Post

Get Certified for a Job in Cybersecurity

Want an exciting career in an emerging field? Earn your MS in Cybersecurity and get certified in ethical hacking or computer forensic investigation. WGU’s MSCSIA degree program was designed to meet the most recent U.S. Department of Homeland Security (DHS) and NSA guidelines.  

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now