home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / PRF100.LZH / PRFSRC.LZH / PRF.C next >
C/C++ Source or Header  |  1991-01-29  |  3KB  |  90 lines

  1. #define INCL_WINSHELLDATA
  2. #define INCL_WINPROGRAMLIST
  3. #include <os2.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. #include "prf.h"
  8.  
  9. static void showuse(void)
  10. {
  11.     static char str01[] =
  12.         "█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█\n"
  13.         "█ Prf                           Peter Fitzsimmons 91/01/29 █\n"
  14.         "█                                             Version 1.00 █\n"
  15.         "█ Usage:    PRF <cmd> <file>                               █\n"
  16.         "█ Purpose:  Read/Write OS/2 Profile (os2.ini).             █\n"
  17.         "█ Commands: R - Read Program/Group info into <file>.       █\n"
  18.         "█           W - Write Program/Group info from <file>.      █\n"
  19.         "█           C - Change profile to <file>.                  █\n"
  20.         "█ Comments: Only program and group information is saved.   █\n"
  21.         "█           Any application specific data stored in        █\n"
  22.         "█           OS2.INI is not saved.                          █\n"
  23.         "█                                                          █\n"
  24.         "█           The R and W commands use a special file        █\n"
  25.         "█           format, which is only recognized by this       █\n"
  26.         "█           program.                                       █\n"
  27.         "█                                                          █\n"
  28.         "█           The C command requires an OS/2 .ini file.      █\n"
  29.         "█           For example, \"prf c c:\\os2\\os2.ini\" would      █\n"
  30.         "█           reset Presentation Manager with the default    █\n"
  31.         "█           initialization file.                           █\n"
  32.         "█           If the file specified by the C command does    █\n"
  33.         "█           not exist,  one is created.                    █\n"
  34.         "█                                                          █\n"
  35.         "█ NOTE:     For OS/2 1.2x                                  █\n"
  36.         "█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█\n";
  37.     fputs(str01, stdout);
  38.  
  39. }
  40.  
  41. void far *zalloc(size_t bytes)
  42. {
  43.     void far *ret;
  44.     SEL sel;
  45.  
  46.     if(DosAllocSeg(bytes, &sel, 0)){
  47.         printf("Memory request of %u bytes failed\n", bytes);
  48.         exit(3);
  49.     }
  50.     ret = MAKEP(sel, 0);
  51.     memset(ret, 0, bytes);
  52.     return(ret);
  53. }
  54.  
  55. void Zree(void far *p)
  56. {
  57.     DosFreeSeg(SELECTOROF(p));
  58. }
  59.  
  60. void change(char *user)
  61. {
  62.     PRFPROFILE pf;
  63.     char *s = "c:/os2/os2sys.ini";
  64.  
  65.     pf.cchUserName = strlen(user);
  66.     pf.pszUserName = user;
  67.     pf.cchSysName  = strlen(s);
  68.     pf.pszSysName  = s;
  69.  
  70.     exit(TRUE == PrfReset(0, &pf));
  71. }
  72.  
  73. int cdecl main(int argc, char **argv)
  74. {
  75.     if(argc != 3){
  76.         showuse();
  77.         return(1);
  78.     }
  79.     if(!stricmp(argv[1], "r"))
  80.         READmain(argv[2]);
  81.     else if(!stricmp(argv[1], "w"))
  82.         WRITEmain(argv[2]);
  83.     else if(!stricmp(argv[1], "c"))
  84.         change(argv[2]);
  85.     else{
  86.         showuse();
  87.         return(1);
  88.     }
  89. }
  90.