AmendHub

Download: |

vkoskiv

/

MacNTP

 

(View History)


Experimenting with NTP on System 6

vkoskiv   Display MacNTP errors in cdev

Name Last Commit Last Modified
AddressXlation.h Initial amendment 9 months ago
MacNTP.c Small NTP corrections 9 months ago
MacNTP.h Small NTP corrections 9 months ago
MacNTP.π.r Display MacNTP errors in cdev 8 months ago
MacTCP.h Initial amendment 9 months ago
README Store UTC offset as string and change some rsrc IDs 9 months ago
ShowInitIcon.c Implement a very rough first-pass control panel + fallback option 9 months ago
ShowInitIcon.h Show icon on startup and remove InitGraf trap 9 months ago
cdev.c Display MacNTP errors in cdev 8 months ago
dnr.c Initial amendment 9 months ago
dnr.h Initial amendment 9 months ago
main.c Display MacNTP errors in cdev 8 months ago
prefs.c Add copyright headers 9 months ago
prefs.h Add copyright headers 9 months ago
rsrcid.h Display MacNTP errors in cdev 8 months ago
tcp.c Add copyright headers 9 months ago
tcp.h Large rewrite, restructure the project into an INIT 9 months ago
util.c Large rewrite, restructure the project into an INIT 9 months ago
util.h Large rewrite, restructure the project into an INIT 9 months ago

README
MacNTP is the premier network time solution for System 6 users running MacTCP on their 68k Macs. It pretty much just does what it says on the tin - seamlessly updates the system clock of your Mac via NTP at boot time, so you don't need to put a leak-prone clock battery in your precious computer.

MacNTP is © Valtteri Koskivuori (vkoskiv), and ISC-licensed.
If you find it useful, please don't hesitate to reach out with feedback or feature suggestions. You can reach me by mailing a letter to:

- Valtteri Koskivuori, P.O. Box 347, Helsinki, Finland
- Just kidding, my details are at the end of this document

More details:

During boot, MacNTP will check the system clock, and if it detects a time in the 20th century, it will attempt to query the configured NTP servers for the current time. The INIT will display the MacNTP icon in the "pending" state. If the NTP request succeeds or fails, the icon is updated to reflect the result.
If the icon is in the "Pending" state for an unusually long time, chances are it's stuck doing DNS lookups. It will eventually time out, though.

-- Build instructions below if you want to compile it yourself --

Prerequisites:
- System 6 (I haven't tested on other systems)
- MacTCP installed and properly configured (check that your connection works before trying this!)
- Think C 5.0.1

Setup:
Think C 5 doesn't support the kind of multi-target project that combines both an INIT and a cdev, so we have to work around it. We need two projects, and we will first build a cdev (Control Panel Document), and then build a second project to inject the INIT resource into our cdev.
1. Create new Think C project, name it "MacNTP.π" (option+p gets you π)
2. To this project, add only cdev.c and MacTraps from Think C's Mac Libraries.
3. Set the project settings like this:
- Select Code Resource.
- File Type = "cdev"
- Creator = "VKOS"
- Type = "cdev"
- ID = "-4064"
- Attrs = 00
- Leave "Custom Header" deselected.
- Ensure that under Edit->Options... under Compiler Settings, "Generate 68020 instructions" is deselected.

4. Use the SARez tool to compile "MacNTP.π.r" into a resource file, name it "MacNTP.π.rsrc" - It's important you name it exactly that, and that it resides in the same directory as the project file created above, otherwise Think C won't find it.
5. Select "Build Code Resource" under "Project" to build the cdev document. Think C will then prompt you for a file name for the cdev document. cdevs and INITs are loaded in alphabetical order, so it is important you choose a name that comes after "MacTCP" alphabetically, as MacNTP depends on MacTCP being present. I usually name it "nMacNTP" to have it load last. Save this file somewhere, and close the MacNTP project.

6. Create another project, call it "MacNTPINIT.π". Add all .c files except for "cdev.c", as well as MacTraps and MacTraps2 from Think C's Mac Libraries
7. Again, ensure 68020 generation is disabled like in step 3, then select Project->Set Project Type, set the settings like this:
- Select Code Resource
- Set File Type to "INIT"
- Creator to "VKOS"
- Type to "INIT"
- ID to "0" (zero)
- Attrs to 70. Leave Custom Header deselected, and hit OK.
8. Select "Build Code Resource" under "Project" to build the INIT resource, but when the save dialog appears, specify the same file as in step 5 with the same filename, and tick the "Merge" option. This way, Think C will build a freestanding INIT resource and inject it into the existing file, preserving the resources that were already copied there from MacNTP.π.rsrc when you built the file in step 5.
9. Open the final file in ResEdit, hit File->Get Info For..., and untick the "No INITS" property if it is enabled, then save and quit. I haven't figured out a workaround for this in Think C.

You *should* now have a file that contains both a cdev and a INIT resource, as well as various other resources that were copied in from MacNTP.π.rsrc. You can place this file in your System Folder, and give it a go.
There is a decent chance I made a mistake in these instructions, or they are outdated, please don't hesitate to contact the author for assistance. This project was started in 2023, so development might still be active when you are reading this.

Caveat: Upon boot, the MacNTP INIT will check the system clock, and won't try updating it if the date is later than September 2nd, 1996. If you edit the UTC offset setting (STR) directly with ResEdit, you will need to set your clock back to before that date for it to update the system clock with the new offset.

Don't hesitate to contact me, vkoskiv, on IRC (libera) if you run into any issues. I'm also @vkoskiv on Twitter and Discord. Also vkoskiv@gmail.com

"Mac" is a trademark of Apple Inc., registered in the U.S. and other countries and regions.