home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / c_instal.sit < prev    next >
Encoding:
Text File  |  1988-06-20  |  5.3 KB  |  260 lines

  1. 18-Jun-88 14:50:08-MDT,5631;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:49:59 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA22734; Sat, 18 Jun 88 14:49:59 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA24863; Sat, 18 Jun 88 14:49:56 MDT
  8. Date: Sat, 18 Jun 88 14:49:56 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8806182049.AA24863@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: install.c.shar
  13.  
  14. #! /bin/sh
  15. #
  16. # This is a shell archive.  Save this into a file, edit it
  17. # and delete all lines above this comment.  Then give this
  18. # file to sh by executing the command "sh file".  The files
  19. # will be extracted into the current directory owned by
  20. # you with default permissions.
  21. #
  22. # The files contained herein are:
  23. #
  24. #    3 install.c
  25. #    1 install.r
  26. #
  27. echo 'Extracting install.c'
  28. if test -f install.c; then echo 'shar: will not overwrite install.c'; else
  29. cat << '________This_Is_The_END________' > install.c
  30. /*
  31.  *    install.c
  32.  *
  33.  *    Version:    1.0
  34.  *    Date:        4/4/86 
  35.  *
  36.  *    This program installs an INIT resource contained within the application's
  37.  *    resource fork into the current system file. I wrote it as an exercise, and
  38.  *    since no-one has posted sources to an installer, I thought I would.
  39.  *    The motivation for this program came out of both a need to understand the
  40.  *    the Resource Manager, and to avoid the bother of getting out ResEdit to
  41.  *    copy and paste INIT resources posted to the NET.
  42.  *
  43.  *    The INIT resource alters the system error (viz. "bomb") so that it
  44.  *    displays the register contents and provides the user with a "finder"
  45.  *    button, allowing one to escape to the finder.
  46.  *
  47.  *    I have generalised this program to allow anyone to simply change the
  48.  *    type and name of the resource that they want to install.
  49.  *    Simply alter the two STR# entries to change the type and name, and
  50.  *    use either ResEdit or RMover to put the resource you want in the 
  51.  *    application.
  52.  *
  53.  *    Thanks to Chris Borton for posting the INIT resource in the first place.
  54.  *
  55.  *
  56.  *    Jason Haines             ISD: +61 2 73-4444
  57.  *    ElecEng Undergraduate    STD:  (02) 73-4444
  58.  *    73 Davidson Avenue      ARPA: munnari!ipso!runx.oz!baron@SEISMO
  59.  *    Concord NSW 2137        UUCP: seismo!munnari!basser!ipso!runx!baron
  60.  *    AUSTRALIA                ACS: baron@runx
  61.  *
  62.  */
  63.  
  64.  
  65.  
  66. #include <mem.h>
  67. #include <qd.h>
  68. #include <qdvars.h>
  69. #include <misc.h>
  70. #include <event.h>
  71. #include <res.h>
  72. #include <win.h>
  73. #include <te.h>
  74. #include <dialog.h>
  75. #include <menu.h>
  76. #include <string.h>
  77. #include <stdio.h>
  78.  
  79. #define    INSTALLITEM    1
  80. #define    REMOVEITEM    2
  81.  
  82. dialogptr mydialogptr;
  83. handle myhandle;
  84. int myresult, myresfile;
  85. char mystr[256], thename[256];
  86. restype thetype, mytype;
  87. int theid;
  88.  
  89. install()
  90. {
  91.     int uid, err;
  92.     
  93.     if ((myhandle = getnamedresource(mytype,mystr)) == NULL)
  94.         sysbeep(200);
  95.     hlock(myhandle);
  96.     getresinfo(myhandle,&theid,&thetype,&thename);
  97.     useresfile(0);
  98.     /* do
  99.     {
  100.     }
  101.     while ((uid = uniqueid(mytype)) > 127 ); */
  102.     /* I removed the uniqueid call part because the INIT resource fails
  103.     with any other ID */
  104.     detachresource(myhandle);
  105.     addresource(myhandle,mytype,theid,mystr);
  106.     updateresfile(0);
  107.     useresfile(myresfile);
  108. }
  109.  
  110. remove()
  111. {
  112.     useresfile(0);
  113.     if ((myhandle = getnamedresource(mytype,mystr)) == NULL)
  114.         sysbeep(200);
  115.     hlock(myhandle);
  116.     rmveresource(myhandle);
  117.     updateresfile(0);
  118.     useresfile(myresfile);
  119. }
  120.  
  121. main()
  122. {
  123.     maxapplzone();        /* allow maximum heap expansion */
  124.     flushevents (everyevent,0);  /* ignore left over events */
  125.     initgraf (&theport);    /* initialize the screen */
  126.     initfonts();        
  127.     initwindows();
  128.     initmenus();
  129.     initcursor();        /* make the arrow cursor */
  130.     teinit();
  131.     initdialogs(NULL);
  132.     showcursor();
  133.     myresfile = curresfile();
  134.     getindstring(mytype,200,1);
  135.     getindstring(mystr,200,2);
  136.     myresult = alert(22122,NULL);
  137.     if (myresult == INSTALLITEM)
  138.         install();
  139.     else if (myresult == REMOVEITEM)
  140.         remove();
  141.     hunlock(myhandle);
  142. }
  143. ________This_Is_The_END________
  144. if test `wc -l < install.c` -ne 113; then
  145.     echo 'shar: install.c was damaged during transit'
  146.   echo '      (should have been 113 bytes)'
  147. fi
  148. fi        ; : end of overwriting check
  149. echo 'Extracting install.r'
  150. if test -f install.r; then echo 'shar: will not overwrite install.r'; else
  151. cat << '________This_Is_The_END________' > install.r
  152. * Resouces for install
  153.  
  154. !install
  155. APPLbrn7
  156.  
  157. *--------------------------------------------------
  158.  
  159. TYPE brn7 = STR 
  160.     ,0
  161. Version 1.0 of install
  162.  
  163.  
  164. TYPE FREF
  165.     ,128
  166. APPL 0
  167.  
  168.  
  169. TYPE BNDL
  170.     ,128
  171. brn7 0
  172. FREF
  173. 0 128
  174. ICN#
  175. 0 128
  176.  
  177. TYPE STR#
  178.     ,200        ;; resource ID
  179. 2                ;; number of strings
  180. INIT
  181. Reg Error Box
  182.  
  183.  
  184. TYPE ICN# = GNRL
  185.     
  186.     ,128
  187.  .H
  188. 00000000
  189. 00000000
  190. 00000000
  191. 00000000
  192. 00000000
  193. 00000000
  194. FFFFFFFF
  195. 80000001
  196. 9FF80001
  197. 80000001
  198. B7CDF37D
  199. 80000001
  200. B7CDF37D
  201. 80000001
  202. B7CDF37D
  203. 80000001
  204. B7CDF37D
  205. 80000001
  206. B7CDF37D
  207. 80000001
  208. 9F1F1F01
  209. AAAAAA81
  210. B5B5B581
  211. 9F1F1F01
  212. 80000001
  213. FFFFFFFF
  214. 00000000
  215. 00000000
  216. 00000000
  217. 00000000
  218. 00000000
  219. 00000000
  220. *
  221. 00000000
  222. 00000000
  223. 00000000
  224. 00000000
  225. 00000000
  226. 00000000
  227. FFFFFFFF
  228. FFFFFFFF
  229. FFFFFFFF
  230. FFFFFFFF
  231. FFFFFFFF
  232. FFFFFFFF
  233. FFFFFFFF
  234. FFFFFFFF
  235. FFFFFFFF
  236. FFFFFFFF
  237. FFFFFFFF
  238. FFFFFFFF
  239. FFFFFFFF
  240. FFFFFFFF
  241. FFFFFFFF
  242. FFFFFFFF
  243. FFFFFFFF
  244. FFFFFFFF
  245. FFFFFFFF
  246. FFFFFFFF
  247. 00000000
  248. 00000000
  249. 00000000
  250. 00000000
  251. 00000000
  252. 00000000
  253. ________This_Is_The_END________
  254. if test `wc -l < install.r` -ne 101; then
  255.     echo 'shar: install.r was damaged during transit'
  256.   echo '      (should have been 101 bytes)'
  257. fi
  258. fi        ; : end of overwriting check
  259. exit 0
  260.