corz.org text viewer..
[currently viewing: /public/scripts/c/uptime/uptime-AMIP-POST.c - raw]
#include <stdio.h>
#include <windows.h>

/*
    uptime.exe v0.1
    
    outputs uptime (in seconds) to a file, in a format that cURL can
    use to POST. (a calling batch file will add the other variables)
        
    ;o) Cor

*/


int main(int argc) {
    FILE * utInfo;
    long sec; sec = 0;
    
     if (argc > 1) {
        printf("\n outputs the time since the peecee booted\n");
        printf(" to a file, in curl POST format\n\n");
        printf(" usage: uptime\n\n");
        printf(" no additional arguments required!\n");
        printf(" v0.1-amip (c) corz.org 2005 ->\n\n");
    return 1;
    }
    
    // get number of milliseconds PC has been up..
    sec = GetTickCount() / 1000; // and convert into seconds

    // lastly, output uptime to file..
    utInfo = fopen ("uptime.nfo","wb");
    if (utInfo != NULL) {
        fprintf(utInfo, "-d \"uptime=%d\"\n", sec);
        fclose (utInfo);
        return 0;
    } else { // oh oh!
        fprintf(stderr, "couldn't open the file for writing");
        return 1;
    }
}

Welcome to corz.org!

Since switching hosts (I hope you are alright, Ed! Wherever you are …) quite a few things seems to be wonky.

Juggling two energetic boys (of very different ages) on Coronavirus lockdown, I'm unlikely to have them all fixed any time soon. Mail me! to prioritise!