xref: /original-bsd/lib/libplot/gigi/linemod.c (revision c3e32dec)
1 /*-
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)linemod.c	8.1 (Berkeley) 06/04/93";
10 #endif /* not lint */
11 
12 #include "gigi.h"
13 
14 linemod( line )
15 char	*line;
16 {
17 	/*
18 	 * Note that the bit patterns could be compacted using the
19 	 *  repeat field conventions.  They aren't for clarity.
20 	 *  Examples of almost identical packed patterns are in the
21 	 *  comments.
22 	 *  If linemod is changed really often, a ~15% savings
23 	 *  could be achieved.
24 	 */
25 	if ( *(line) == 's' ) {
26 		if ( *(++line) == 'o' ) {
27 			/*
28 			 * solid mode 1
29 			 */
30 			printf( "W(P1)" );
31 			return;
32 		}
33 		else if ( *(line) == 'h' ) {
34 			/*
35 			 * shortdashed mode 4
36 			 *  printf( "W(P000111)" );
37 			 */
38 			printf( "W(P00011100)" );
39 			return;
40 		}
41 	}
42 	else if ( *(line) == 'd' ) {
43 		if ( *(++line) == 'o' && *(++line) == 't' ) {
44 			if ( *(++line) == 't' ) {
45 				/*
46 				 * dotted mode 2
47 				 *  printf( "W(P00001)" );
48 				 */
49 				printf( "W(P10000000)" );
50 				return;
51 			}
52 			else if ( *(line) == 'd' ) {
53 				/*
54 				 * dotdashed mode 3
55 				 *  printf( "W(P0110010)" );
56 				 */
57 				printf( "W(P10001100)" );
58 				return;
59 			}
60 		}
61 	}
62 	else if ( *(line) == 'l' ) {
63 		/*
64 		 * longdashed mode 5
65 		 *  printf( "W(P11100)" );
66 		 */
67 		printf( "W(P11111100)" );
68 		return;
69 	}
70 	printf( "W(P1)" );			/* default to solid */
71 	return;
72 }
73