File: conversion.h

package info (click to toggle)
wcalc 2.4-1.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,916 kB
  • sloc: ansic: 7,089; objc: 2,002; sh: 890; lex: 816; yacc: 641; makefile: 103
file content (84 lines) | stat: -rw-r--r-- 1,998 bytes parent folder | download | duplicates (3)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 *  conversion.h
 *  Wcalc
 *
 *  Created by Kyle Wheeler on Wed Jul 31 2002.
 *  Copyright (c) 2002 Kyle Wheeler. All rights reserved.
 *
 */
#ifndef WCALC_CONVERSIONS
#define WCALC_CONVERSIONS

#include <sys/types.h> /* for ssize_t */
#include <unistd.h> /* also for ssize_t */
#include "number.h"

void uber_conversion(Number output, const int utype, const int fromunit, const int tounit,
		     Number value);
ssize_t identify_unit(const char *unit);
ssize_t identify_units(const char *unit1, const char *unit2);
ssize_t unit_id(const int utype, const char *unit);

struct conversion
{
    char *factor;
    char *name;
    char *aka[9];
};

struct conv_req
{
    char *u1;
    char *u2;
};

/* Conversion Types */
#define MAX_TYPE        10
#define LENGTH_C        0 /*-*/
#define AREA_C          1 /*-*/
#define VOLUME_C        2 /*-*/
#define MASS_C          3 /*-*/
#define SPEED_C         4 /*-*/
#define POWER_C         5 /*-*/
#define FORCE_C         6 /*-*/
#define ACCELERATION_C  7 /*-*/
#define TEMPERATURE_C   8 /*-*/
#define ANGLE_C		9 /*-*/
#define PRESSURE_C	10 /**/
/* Astronomical Units */
#define MAX_ASTRONOMICAL_UNIT 5
#define A_METERS          0
#define A_KILOMETERS      1
#define A_MILES           2
#define LIGHT_YEAR        4
#define PARSEC            5
/* Length Units */
#define LENGTH_UNIT_COUNT		87
/* Area Units */
#define AREA_UNIT_COUNT			74
/* Volume Units */
#define VOLUME_UNIT_COUNT		136
/* Angle Units */
#define ANGLE_UNIT_COUNT		12
/* Mass Units */
#define MASS_UNIT_COUNT			66
/* Speed Units */
#define SPEED_UNIT_COUNT		17
/* Power Units */
#define POWER_UNIT_COUNT		45
/* Force Units */
#define FORCE_UNIT_COUNT		13
/* Acceleration Units */
#define ACCELERATION_UNIT_COUNT		23
/* Pressure Units */
#define PRESSURE_UNIT_COUNT		41
/* Temperature Units */
#define TEMPERATURE_UNIT_COUNT	5
#define KELVIN		0
#define CELSIUS		1
#define RANKINE		2
#define FARENHEIT	3
#define REAUMUR		4
extern const struct conversion *conversions[MAX_TYPE + 2];

#endif