File: nfc.c

package info (click to toggle)
abiword 0.7.7-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 20,604 kB
  • ctags: 18,358
  • sloc: cpp: 88,791; ansic: 66,296; sh: 7,777; makefile: 3,397; xml: 687; perl: 361; awk: 273; sed: 36; csh: 28
file content (62 lines) | stat: -rw-r--r-- 1,712 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdlib.h>
#include <stdio.h>
#include "wv.h"
#include "roman.h"

char *wvGenerateNFC(int value,int no_type)
    {
    char *roman;
	roman = (char *)malloc(81);
	if (roman == NULL)
		return(NULL);
    switch(no_type)
        {
        case 0:
            sprintf(roman,"%d",value);
            break;
        case 1:
            decimalToRoman(value,roman);
            break;
        case 2:
            decimalToRoman(value,roman);
            ms_strlower(roman);
            break;
        case 3:
            sprintf(roman,"%c",64+value); /*uppercase letter*/
            break;
        case 4:
            sprintf(roman,"%c",96+value); /*lowercase letter*/
            break;
		case 5:		/*what does the spec actually mean when it says Ordinal ?*/
			wvFree(roman);
			roman = wvOrdinal(value);
			break;
        /*a nine appears to exist as well to means to use symbols*/
        case 9:
            while(value > 0)
                {
                switch(value%4)
                    {
                    case 1:
                        sprintf(roman,"*");
                        break;
                    case 2:
                        sprintf(roman,"%s","&#8224");  /*these are windows specific, must fix*/
                        break;
                    case 3:
                        sprintf(roman,"%s","&#8225");  /*these are windows specific, must fix*/
                        break;
                    case 0:
                        sprintf(roman,"%c",167);
                        break;
                    }
                value-=4;
                }
            break;
        default:
			wvFree(roman);
			return(NULL);
            break;
        }
	return(roman);
    }