utils.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *  Based on
00003  *  xdbx - X Window System interface to the dbx debugger
00004  *
00005  *  Copyright 1989 The University of Texas at Austin
00006  *  Copyright 1990 Microelectronics and Computer Technology Corporation
00007  *
00008  *  Permission to use, copy, modify, and distribute this software and its
00009  *  documentation for any purpose and without fee is hereby granted,
00010  *  provided that the above copyright notice appear in all copies and that
00011  *  both that copyright notice and this permission notice appear in
00012  *  supporting documentation, and that the name of The University of Texas
00013  *  and Microelectronics and Computer Technology Corporation (MCC) not be 
00014  *  used in advertising or publicity pertaining to distribution of
00015  *  the software without specific, written prior permission.  The
00016  *  University of Texas and MCC makes no representations about the 
00017  *  suitability of this software for any purpose.  It is provided "as is" 
00018  *  without express or implied warranty.
00019  *
00020  *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
00021  *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
00022  *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
00023  *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
00024  *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
00025  *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00026  *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00027  *
00028  *  Author:     Po Cheung
00029  *  Created:    March 10, 1989
00030  *
00031  *****************************************************************************/
00032 
00033 /*  utils.c
00034  *
00035  *    Contain common routines used by other functions.
00036  *
00037  *    TextGetLastPos():         Get the last insertion position of text.
00038  *    TextPositionToLine():     Return text position give a line number.
00039  *    LineToStopNo():           Return the stop number given a line number.
00040  *    DisableWindowResize():    Fix the size of a window inside vpane.
00041  *    bell():                   Ring the bell.
00042  *    concat():                 Concatenate two strings together
00043  */
00044 
00045 
00046 #include <string.h> /* in case of dmalloc */ 
00047 #include <stdlib.h>
00048 #include "global.h"
00049 
00050 void DisableWindowResize(Widget w)
00051 {
00052     Arg args[MAXARGS];
00053     Cardinal n;
00054     Dimension height;
00055 
00056     n = 0;
00057     XtSetArg(args[n], XtNheight, &height);                       n++;
00058     XtGetValues(w, args, n);
00059     XawPanedSetMinMax(w,(int) height, (int) height);
00060     XawPanedAllowResize(w, False);
00061 }
00062 
00063 
00064 void bell(volume)
00065 int volume;
00066 {
00067     XBell(XtDisplay(toplevel), volume);
00068 }
00069 
00070 /* append string s2 to end of string s1 and return the result */
00071 
00072 char *concat(s1, s2)
00073 char *s1, *s2;
00074 {
00075     if (s2) {
00076         if (s1 == NULL) {
00077             s1 = XtMalloc((Cardinal) (strlen(s2)+1)*sizeof(char));
00078             strcpy(s1, s2);
00079         }
00080         else {
00081             s1 = XtRealloc(s1, (Cardinal) strlen(s1)+strlen(s2)+2);
00082             strcat(s1, s2);
00083         }
00084     }
00085 #if 0   /*(PW)4DEC90 : bug ! if s2 is null, there is no reason to set s1 to 0 */
00086     else
00087         s1 = NULL;
00088 #endif
00089     return (s1);
00090 }

Generated on Sun Mar 4 15:03:56 2007 for Scilab [trunk] by  doxygen 1.5.1