ia5.c
author viric@llimona
Tue, 28 Aug 2007 01:01:49 +0200
changeset 10 188a0e3b3fb4
parent 8 09ec33061ff3
permissions -rw-r--r--
Fixed a bug in dict.c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
     1
#include <stdio.h>
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
     2
#include <stdlib.h>
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
     3
#include "dictre.h"
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
     4
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
     5
int main(int argn, char **argv)
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
     6
{
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
     7
    int val;
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
     8
    char *input;
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
     9
    char *end;
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    10
    char type;
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    11
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    12
    if (argn != 3 || (argv[1][1] != 'w' && argv[1][1] != 'n') )
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    13
    {
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    14
        printf("usage: %s <-w word | -n num>\n", argv[0]);
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    15
        return 0;
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    16
    }
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    17
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    18
    type = argv[1][1];
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    19
    input = argv[2];
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    20
    if(type == 'n')
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    21
    {
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    22
        /* Whole string number */
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    23
        char tmp[20];
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    24
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    25
        val = strtol(input, &end, 10);
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    26
        num_to_ia5(tmp, val);
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    27
        printf("%s\n", tmp);
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    28
    } else
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    29
    {
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    30
        val = str2int(input);
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    31
        printf("%i\n", val);
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    32
    }
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    33
    return 0;
09ec33061ff3 Added 'ia5' binary, and fixed the ia5 functions.
viric@llimona
parents:
diff changeset
    34
}