Annotation of embedaddon/miniupnpc/wingenminiupnpcstrings.c, revision 1.1.1.2

1.1.1.2 ! misho       1: /* $Id: wingenminiupnpcstrings.c,v 1.3 2012/03/05 19:42:48 nanard Exp $ */
1.1       misho       2: /* Project: miniupnp
                      3:  * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
                      4:  * Author: Thomas Bernard
                      5:  * Copyright (c) 2005-2009 Thomas Bernard
                      6:  * This software is subjects to the conditions detailed
                      7:  * in the LICENSE file provided within this distribution */
                      8: #include <stdio.h>
                      9: #include <windows.h>
                     10: 
                     11: /* This program display the Windows version and is used to
                     12:  * generate the miniupnpcstrings.h
                     13:  * wingenminiupnpcstrings miniupnpcstrings.h.in miniupnpcstrings.h
                     14:  */
                     15: int main(int argc, char * * argv) {
                     16:        char buffer[256];
                     17:        OSVERSIONINFO osvi;
                     18:        FILE * fin;
                     19:        FILE * fout;
                     20:        int n;
                     21:        char miniupnpcVersion[32];
                     22:        /* dwMajorVersion :
                     23:        The major version number of the operating system. For more information, see Remarks.
                     24:      dwMinorVersion :
                     25:        The minor version number of the operating system. For more information, see Remarks.
                     26:      dwBuildNumber :
                     27:        The build number of the operating system.
                     28:      dwPlatformId
1.1.1.2 ! misho      29:        The operating system platform. This member can be the following value.
1.1       misho      30:      szCSDVersion
                     31:        A null-terminated string, such as "Service Pack 3", that indicates the
                     32:        latest Service Pack installed on the system. If no Service Pack has
                     33:        been installed, the string is empty.
                     34:    */
                     35:   ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
                     36:   osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
                     37: 
                     38:   GetVersionEx(&osvi);
                     39: 
                     40:        printf("Windows %lu.%lu Build %lu %s\n",
                     41:               osvi.dwMajorVersion, osvi.dwMinorVersion,
                     42:               osvi.dwBuildNumber, (const char *)&(osvi.szCSDVersion));
                     43: 
                     44:        fin = fopen("VERSION", "r");
                     45:        fgets(miniupnpcVersion, sizeof(miniupnpcVersion), fin);
                     46:        fclose(fin);
                     47:        for(n = 0; n < sizeof(miniupnpcVersion); n++) {
                     48:                if(miniupnpcVersion[n] < ' ')
                     49:                        miniupnpcVersion[n] = '\0';
                     50:        }
                     51:        printf("MiniUPnPc version %s\n", miniupnpcVersion);
                     52: 
                     53:        if(argc >= 3) {
                     54:                fin = fopen(argv[1], "r");
                     55:                if(!fin) {
                     56:                        fprintf(stderr, "Cannot open %s for reading.\n", argv[1]);
                     57:                        return 1;
                     58:                }
                     59:                fout = fopen(argv[2], "w");
                     60:                if(!fout) {
                     61:                        fprintf(stderr, "Cannot open %s for writing.\n", argv[2]);
                     62:                        return 1;
                     63:                }
                     64:                n = 0;
                     65:                while(fgets(buffer, sizeof(buffer), fin)) {
                     66:                        if(0 == memcmp(buffer, "#define OS_STRING \"OS/version\"", 30)) {
                     67:                                sprintf(buffer, "#define OS_STRING \"MSWindows/%ld.%ld.%ld\"\n",
                     68:                                        osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber);
                     69:                        } else if(0 == memcmp(buffer, "#define MINIUPNPC_VERSION_STRING \"version\"", 42)) {
                     70:                                sprintf(buffer, "#define MINIUPNPC_VERSION_STRING \"%s\"\n",
                     71:                                        miniupnpcVersion);
                     72:                        }
                     73:                        /*fputs(buffer, stdout);*/
                     74:                        fputs(buffer, fout);
                     75:                        n++;
                     76:                }
                     77:                fclose(fin);
                     78:                fclose(fout);
                     79:                printf("%d lines written to %s.\n", n, argv[2]);
                     80:        }
                     81:   return 0;
                     82: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>