コード例 #1
0
int main (int argc, char **argv)
{
    char *dados, *pos, *nome_arq;
    int erro, arq;

    arq = le_param (argc, argv);
    nome_arq = argv[arq];
    dados = le_arquivo (nome_arq);

    if (dados == NULL)
        sair (FIM_ERRO_ARQUIVO);

    ajusta_nomes_arquivos (nome_arq, muda_extensao (nome_arq, "s"));

    pos = dados;
    erro = analisadorSintatico (&pos);
    
    if (erro == FIM_OK && monta_exe)
    {
        char *comando;
        
        comando = calloc (15 + 2*strlen (nome_arq), sizeof (char));
        
        sprintf (comando, "gcc -o %s %s", muda_extensao (nome_arq, "exe"),  muda_extensao (nome_arq, "s"));
        system (comando);
        
        free (comando);
    }
	
    sair (erro);
    return erro;
}
コード例 #2
0
int le_param (int argc, char **argv)
{
    int arq = 1;
    
    if (argc == 1)
        sair (FIM_ERRO_PARAMETRO);
    
    while ((arq < argc) && argv[arq][0]=='-')
    {
        switch (argv[arq][1])
        {
            case 't':
                tecla = VERDADE;
                break;

            case 'm':
                monta_exe = VERDADE;
                break;

            case 'e':
                espacado = VERDADE;
            case 'd':
                depurando = VERDADE;
            case 'v':
                falante = VERDADE;
                break;
        }
        arq++;
    }
    return arq;
}
コード例 #3
0
ファイル: menus.c プロジェクト: m-mercier/ppp-project
void submenu1_cliente(lista1 lista_clientes, lista2 lista_reservas,lista2 lista_pre_reservas)
{
    int escolha;
    printf("\t\t\t\tFAZER RESERVA\n");
    printf("\n\t\t1-Novo cliente");
    printf("\n\t\t2-Cliente existente");
    printf("\n\t\t3-Voltar ao Menu principal");
    printf("\n\t\t4-Sair");
    printf("\n\n Escolha o que deseja:\n");
    escolha=verifica_int_menu();
    switch (escolha)
    {
        case 1: system("cls");dados_cliente(lista_clientes);submenu1_reservar(lista_clientes,lista_reservas,lista_pre_reservas);break;
        case 2:
            {
                if(verifica_clientes(lista_clientes))
                {
                    system("cls");
                    submenu1_reservar(lista_clientes,lista_reservas,lista_pre_reservas);break;
                }else
                {
                    system("cls");
                    printf("\n\nNão existem clientes na lista!\nAo fazer a reserva crie um novo cliente.\n\n");
                    submenu1_cliente(lista_clientes,lista_reservas,lista_pre_reservas);
                    break;
                }

            }
        case 3: system("cls");break;
        case 4: sair(lista_clientes,lista_reservas,lista_pre_reservas);exit(0);
        default:printf("\n\n\t\t****ERRO - Tem de inserir uma opção válida!****\n\n");submenu1_cliente(lista_clientes,lista_reservas,lista_pre_reservas);
    }

}
コード例 #4
0
ファイル: menus.c プロジェクト: m-mercier/ppp-project
void menu(lista1 lista_clientes, lista2 lista_reservas, lista2 lista_pre_reservas)
{
    int escolha;
    while(escolha!=7)
    {
        printf("\t\t\t\tMENU\n");
        printf("\n\t\t1-Fazer reserva");
        printf("\n\t\t2-Cancelar reserva");
        printf("\n\t\t3-Cancelar pré-reserva");
        printf("\n\t\t4-Consultar horários");
        printf("\n\t\t5-Consultar clientes");
        printf("\n\t\t6-Lavagem/Manutenção efectuada");
        printf("\n\t\t7-Sair");
        printf("\n\n Escolha o que deseja:\n");
        escolha=verifica_int_menu();
        switch(escolha)
        {
            case 1: system("cls");submenu1_cliente(lista_clientes,lista_reservas,lista_pre_reservas);break;
            case 2: system("cls");elimina_reserva(lista_clientes,lista_reservas,lista_pre_reservas);break;
            case 3: system("cls");elimina_pre_reserva(lista_clientes,lista_pre_reservas);break;
            case 4: system("cls");submenu2_listar(lista_clientes,lista_reservas,lista_pre_reservas);break;
            case 5: system("cls");imprime_clientes(lista_clientes);break;
            case 6: system("cls");efectua_reserva(lista_reservas,lista_pre_reservas);break;
            case 7: sair(lista_clientes,lista_reservas,lista_pre_reservas);exit(0);
            default:printf("\n\n\t\t****ERRO - Tem de inserir uma opção válida!****\n\n");
        }
    }
}
コード例 #5
0
ファイル: principal.cpp プロジェクト: Hiarley/aprendendo-qt
principal::principal(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::principal)
{
    ui->setupUi(this);

    connect(ui->actionAbrir, SIGNAL(triggered()), this, SLOT(abrir()));
    connect(ui->actionSalvar, SIGNAL(triggered()), this, SLOT(salvar()));
    connect(ui->actionSair, SIGNAL(triggered()), this, SLOT(sair()));

}
コード例 #6
0
void doenca() {


    for(i = contDoencas; i < A; i++) {
        doencas[i].codID = i + 1;
        printf("Codigo de identificacao: %d \n",doencas[i].codID);

        printf("Informe o nome da doenca \n");
        fflush(stdin);
        gets(doencas[i].nomeDoenca);
        printf("Descreva a doenca \n");
        fflush(stdin);
        gets(doencas[i].descricao);

        do {

            printf("Informe o nivel de seriedade da doenca\n");
            printf("1. Baixo \n2. Medio \n3. Alto \n");
            scanf("%d",&doencas[i].nivel);


            switch (doencas[i].nivel) {
                case 1:
                    printf("\n1. Baixo\n");
                    break;
                case 2:
                    printf("\n2. Medio\n");
                    break;
                case 3:
                    printf("\n3. Alto\n");
                    break;
                default:
                    printf("Opcao invalida\n");
            }

        } while (doencas[i].nivel <= 0 || doencas[i].nivel > 3);



        contDoencas += 1;

        sair();
    }

}
コード例 #7
0
ファイル: menus.c プロジェクト: m-mercier/ppp-project
void submenu1_reservar (lista1 lista_clientes, lista2 lista_reservas,lista2 lista_pre_reservas)
{
    int escolha;
    printf("\t\t\t\tFAZER RESERVA\n");
    printf("\n\t\t1-Reservar Manutenção");
    printf("\n\t\t2-Reservar Lavagem");
    printf("\n\t\t3-Voltar ao Menu principal");
    printf("\n\t\t4-Sair");
    printf("\n\n Escolha o que deseja:\n");
    escolha=verifica_int_menu();
    switch(escolha)
    {
        case 1: system("cls");dados_reserva(lista_clientes,lista_reservas,lista_pre_reservas,100);break;
        case 2: system("cls");dados_reserva(lista_clientes,lista_reservas,lista_pre_reservas,30);break;
        case 3: system("cls");break;
        case 4: sair(lista_clientes,lista_reservas,lista_pre_reservas);exit(0);
        default:printf("\n\n\t\t****ERRO - Tem de inserir uma opção válida!****\n\n");submenu1_reservar(lista_clientes,lista_reservas,lista_pre_reservas);
    }
}
コード例 #8
0
ファイル: menus.c プロジェクト: m-mercier/ppp-project
void submenu2_listar (lista1 lista_clientes, lista2 lista_reservas,lista2 lista_pre_reservas)
{
    int escolha;
    printf("\t\t\t\tLISTAR HORÁRIOS\n");
    printf("\n\t\t1-Reservas");
    printf("\n\t\t2-Pré-Reservas");
    printf("\n\t\t3-Voltar ao Menu principal");
    printf("\n\t\t4-Sair");
    printf("\n\n Escolha o que deseja:\n");
    escolha=verifica_int_menu();
    switch(escolha)
    {
        case 1: system("cls");submenu3_listar_reservas(lista_clientes, lista_reservas, lista_pre_reservas);break;
        case 2: system("cls");submenu4_listar_prereservas(lista_clientes,lista_reservas,lista_pre_reservas);break;
        case 3: system("cls");break;
        case 4: sair(lista_clientes,lista_reservas,lista_pre_reservas);exit(0);
        default:printf("\n\n\t\t****ERRO - Tem de inserir uma opção válida!****\n\n");submenu2_listar(lista_clientes, lista_reservas, lista_pre_reservas);
    }
}
コード例 #9
0
ファイル: chamadorold.c プロジェクト: Biazus/T2FS
int main()
{

    int i;
    int count;
    t2fs_find dir;
    t2fs_record rec;

    if (t2fs_first (&dir))
    {
        printf ("Erro ao abrir o diretorio.\n");
        return;
    }

    char *name = malloc(sizeof(rec.name)+1);
    if (name==NULL)
    {
        printf ("Erro ao ler o diretorio.\n");
        return;
    }

    count=0;
    while ( (i=t2fs_next(&dir, &rec)) == 0 )
    {
        printf ("%s\n", (char *)rec.name);
        count++;
    }

    free(name);

    if (i!=1)
    {
        printf ("Erro ao ler o diretorio.\n");
        return;
    }
    if (count==0)
        printf ("Diretorio vazio.\n");
    else
        printf ("\nEncontrados %d arquivos.\n\n", count);
    sair();
    return 0;
}
コード例 #10
0
ファイル: menus.c プロジェクト: m-mercier/ppp-project
void submenu4_listar_prereservas (lista1 lista_clientes, lista2 lista_reservas, lista2 lista_pre_reservas)
{
    int escolha;
    printf("\t\t\tLISTAR HORÁRIOS DE PRÉ-RESERVAS\n");
    printf("\n\t\t1-Completo");
    printf("\n\t\t2-Diário");
    printf("\n\t\t3-Cliente");
    printf("\n\t\t4-Retroceder");
    printf("\n\t\t5-Sair");
    printf("\n\n Escolha o que deseja:\n");
    escolha=verifica_int_menu();
    switch(escolha)
    {
        case 1: system("cls");imprime_pre_reservas_completo(lista_clientes,lista_pre_reservas);break;
        case 2: system("cls");imprime_pre_reservas_diario(lista_clientes,lista_pre_reservas);break;
        case 3: system("cls");imprime_pre_reservas_cliente(lista_clientes,lista_pre_reservas);break;
        case 4: system("cls");submenu2_listar(lista_clientes, lista_reservas,lista_pre_reservas);break;
        case 5: sair(lista_clientes,lista_reservas,lista_pre_reservas);exit(0);
        default:printf("\n\n\t\t****ERRO - Tem de inserir uma opção válida!****\n\n");submenu4_listar_prereservas(lista_clientes, lista_reservas,lista_pre_reservas);
    }
}
コード例 #11
0
void sintoma() {

    for (i = 0; i < A; i++) {
        sintomas[i].codID = i + 1;
        printf("Codigo de identificacao: %d\n",sintomas[i].codID);
        fflush(stdin);
        printf("Descreva os sintomas\n");
        gets(sintomas[i].descricao);



        do {

            printf("Informe o nivel de severidade da doenca\n");
            printf("1. Baixo \n2. Medio \n3. Alto \n");
            scanf("%d",&sintomas[i].nivel);

            switch (sintomas[i].nivel) {
                case 1:
                    printf("\n1. Baixo\n");
                    break;
                case 2:
                    printf("\n2. Medio\n");
                    break;
                case 3:
                    printf("\n3. Alto\n");
                    break;
                default:
                    printf("Opcao invalida\n");
            }

        } while (sintomas[i].nivel <= 0 || sintomas[i].nivel > 3);

        sair();


    }

}
コード例 #12
0
ファイル: main.c プロジェクト: glaydston/ed
void main()
{
    struct tlist list;
    int op = 0;
    //inicializa lista
    load(&list);
    do
    {
        menu(&op);
        switch(op)
        {
            case 1: filter(op, &list);  break;
            case 2: filter(op, &list);  break;
            case 3: pesquisar(&list);   break;
            case 4: imprimir(&list);    break;
            case 9: sair();             break;
            default:
                printf("\n\n\t\t# OPCAO [%d] INVALIDA! [ENTER]", op);getche();
        }
    }
    while(op != 9);
}
コード例 #13
0
void medicamento(){

    for (i = 0; i < A; i++) {
        medicamentos[i].codID = i + 1;
        printf ("\n Codigo do exame: %d \n", medicamentos[i].codID);
        printf("Nome do medicamento \n");
        fflush(stdin);
        gets(medicamentos[i].nome_medicamento);
        fflush(stdin);
        printf("Para quais pacientes o medicamento e indicado?\n");
        gets(medicamentos[i].indicacao);
        fflush(stdin);
        printf("Informe a posologia \n");
        gets(medicamentos[i].posologia);
        printf("Informe a faixa etaria indicada para o uso do medicamento:\n");
        scanf("%d", &medicamentos[i].faixa_etaria);
        fflush(stdin);
        printf("Para quais pacientes o medicamento eh contra indicado?\n");
        gets(medicamentos[i].contra_indicacao);


    sair();
    }
}
コード例 #14
0
void exame() {

     for (i = 0; i < A; i++) {

         exames[i].cod_exame = i + 1;
         fflush(stdin);
         printf ("\n Codigo do exame: %d \n", exames[i].cod_exame);
         printf("Nome do exame \n");
         gets(exames[i].nome_exame);
         fflush(stdin);

         do {
             printf("A forma de pagamento\n1. Convenio\n2. Particular\n3. Gratuito\n");
             scanf("%d",exames[i].pgto);

             switch (exames[i].pgto) {

                case 1:
                    printf("Convenio\n");
                    break;
                case 2:
                    printf("Particular\n");
                    break;
                case 3:
                    printf("Gratuito\n");
                    break;
                default:
                    if(exames[i].pgto <= 0 || exames[i].pgto > 3)
                        printf("Opcao invalida\n");
             }

        }while (exames[i].pgto <= 0 || exames[i].pgto > 3);

        sair();
    }
}
コード例 #15
0
void tratamento() {

    char ok;
    int cod, op;

    for (i = 0; i < A; i++) {

        tratamentos[i].codID = i + 1;
        printf("Codigo de identificacao:  '%d'\n", tratamentos[i].codID);


        printf("Informe o codigo de identificacao da doenca: ");
        scanf("%d",&cod);

        cod = cod - 1;
        if (contDoencas <= cod) {
            do {
                printf("Doenca não cadastrada.\n1. Cadastrar?\n2. Digitar outra\n> ");
                scanf("%d", &op);
                switch (op) {
                    case 1:
                        doenca();
                        marca1 = 1;
                        printf("Digite outro codigo de doenca: ");
                        scanf("%d", &cod);
                        cod = cod - 1;
                        break;
                    case 2:
                        printf("Digite outro codigo de doenca: ");
                        scanf("%d", &cod);
                        cod = cod - 1;
                    default:
                        printf("Digite novamente\n");
                        break;
                }
            } while (contDoencas <= cod);

        }

        printf("Nome da doenca: ");
        puts(doencas[cod].nomeDoenca);

        tratamentos[i].codDoenca = cod;

        printf("Informe o codigo de identificacao do paciente: ");
        scanf("%d",&cod);

        cod = cod - 1;
        if (contPacientes <= cod) {
            do {
                printf("Paciente não cadastrado.\n1. Cadastrar?\n2. Digitar outro\n> ");
                scanf("%d", &op);
                switch (op) {
                    case 1:
                        paciente();
                        marca4 = 1;
                        printf("Digite outro codigo de paciente: ");
                        scanf("%d", &cod);
                        cod = cod - 1;
                        break;
                    case 2:
                        printf("Digite outro codigo de paciente: ");
                        scanf("%d", &cod);
                        cod = cod - 1;
                    default:
                        printf("Digite novamente\n");
                        break;
                }
            } while (contPacientes <= cod);

        }

        printf("Nome do paciente: ");
        puts(pacientes[cod].nomePaciente);

        tratamentos[i].codPaciente = cod;

        printf("Informe o codigo de identificacao do medico: ");
        scanf("%d",&cod);

        cod = cod - 1;
        if (contMedicos <= cod) {
            do {
                printf("Medico não cadastrado.\n1. Cadastrar?\n2. Digitar outro\n> ");
                scanf("%d", &op);
                switch (op) {
                    case 1:
                        medico();
                        marca3 = 1;
                        printf("Digite outro codigo de medico: ");
                        scanf("%d", &cod);
                        cod = cod - 1;
                        break;
                    case 2:
                        printf("Digite outro codigo de medico: ");
                        scanf("%d", &cod);
                        cod = cod - 1;
                    default:
                        printf("Digite novamente\n");
                        break;
                }
            } while (contMedicos <= cod);

        }

        printf("Nome do medico: ");
        puts(medicos[cod].nomeMedico);

        tratamentos[i].codMedico = cod;

        printf("Informe o valor da consulta:\n");
        scanf("%f", & tratamentos[i].valorConsulta);

        printf("Exames adicionais? (S/N)\n");
        scanf(" %c", &ok);
        if (ok == 'S' || ok == 's') {

            printf("Informe o valor dos exames:");
            scanf("%f", & tratamentos[i].valorExame);
        }
        printf("Havera tempo de observacao (S/N)? \n");
        scanf(" %c", & tratamentos[i].resp);

        if (tratamentos[i].resp=='s') {

            printf ("Informe o tempo de observacao");
            scanf("%s", tratamentos[i].tempoObs);
            puts(tratamentos[i].tempoObs);
            printf ("Informe o tempo de observacao");
            scanf("%s", tratamentos[i].tempoObs);
        }

        printf("Existe tempo de internacao (s/n):");
        fflush(stdin);
        scanf("%c \n ", & tratamentos[i].resp);
        if (tratamentos[i].resp=='s') {

            printf("Quanto tempo de internacao?");
            scanf("%s", tratamentos[i].tempoInter);
            puts(tratamentos[i].tempoInter);
            printf("Quanto tempo de internacao?");
            scanf("%s", tratamentos[i].tempoInter);
        }


    sair();
    }
}
コード例 #16
0
void medico() {

    int cod, op;
    char ok;

    for (i = contMedicos; i < A; i++) {

        printf("Digite o CRM:\n");
        scanf("%d", &medicos[i].CRM);
        printf("Digite o nome do Medico:\n");
        gets(medicos[i].nomeMedico);
        printf("Informe o CPF: \n");
        scanf("%s", medicos[i].CPF);
        printf("Digite o Telefone do medico: \n");
        scanf("%s", medicos[i].telefone);

        printf("Digite o endereco da clinica/hospital: \n");
        printf("rua:\n");
        fflush(stdin);
        gets(medicos[i].endereco.rua);
        printf("Numero:\n");
        scanf("%d", &medicos[i].endereco.numero);
        printf("Bairro:\n");
        fflush(stdin);
        gets(medicos[i].endereco.bairro);
        printf("Cidade:\n");
        fflush(stdin);
        gets(medicos[i].endereco.cidade);
        printf("Estado:\n");
        fflush(stdin);
        gets(medicos[i].endereco.estado);
        printf("CEP:\n");
        scanf("%s", medicos[i].endereco.CEP);


        printf("Informe o codigo de identificacao dos pacientes atendidos pelo medico\n");

        for (j = 0; j < A; j++) {

            printf("Codigo: ");
            scanf("%d",&cod);

            cod = cod - 1;
            if (contPacientes <= cod) {
                do {
                    printf("Paciente não cadastrado.\n1. Cadastrar?\n2. Digitar outro\n> ");
                    scanf("%d", &op);
                    switch (op) {
                        case 1:
                            paciente();
                            marca4 = 1;
                            printf("Digite outro codigo de paciente: ");
                            scanf("%d", &cod);
                            cod = cod - 1;
                            break;
                        case 2:
                            printf("Digite outro codigo de paciente: ");
                            scanf("%d", &cod);
                            cod = cod - 1;
                        default:
                            printf("Digite novamente\n");
                            break;
                    }
                } while (contPacientes <= cod);

            }

            printf("Nome do paciente: ");
            puts(pacientes[cod].nomePaciente);

            medicos[i].codPacientes[j] = cod;

            printf("Você deseja informar mais algum paciente? (S/N)");
            scanf(" %c",&ok);
            if (ok != 'S' || ok != 's')
                j = A;

        }

        printf("Nome e CPF de todos os pacientes atendidos pelo medico:");

        for (j = 0; j < A; j++) {

            printf("Codigo: %d\n",medicos[i].codPacientes[j]);
            printf("Nome do paciente: ");
            puts(pacientes[medicos[i].codPacientes[j]].nomePaciente);
            printf("CPF do paciente: ");
            printf("%s\n", pacientes[medicos[i].codPacientes[j]].CPF);

        }

        contMedicos += 1;
        sair();
    }

}
コード例 #17
0
void paciente() {

    char ok;

    for(i = contPacientes; i < A; i++) {

        pacientes[i].codPaciente = i + 1;
        printf("Código do Paciente: '%d'\n", pacientes[i].codPaciente);

        printf("Digite o CPF do paciente: \n");
        scanf("%s", pacientes[i].CPF);
        printf("Digite o nome do paciente: \n");
        fflush(stdin);
        gets(pacientes[i].nomePaciente);
        printf("Digite a idade do paciente: \n");
        scanf("%d", &pacientes[i].idade);
        printf("Qual o genero do paciente? (M/F) \n");
        scanf("%c", &pacientes[i].genero);
        printf("Digite o telefone do paciente: \n");
        scanf("%s", pacientes[i].telefone);

        printf("Digite o endereco do paciente: \n");
        printf("rua:\n");
        gets(pacientes[i].endereco.rua);
        printf("Numero:\n");
        scanf("%d", &pacientes[i].endereco.numero);
        printf("Bairro:\n");
        gets(pacientes[i].endereco.bairro);
        printf("Cidade:\n");
        gets(pacientes[i].endereco.cidade);
        printf("Estado:\n");
        gets(pacientes[i].endereco.estado);
        printf("CEP:\n");
        scanf("%s", pacientes[i].endereco.CEP);

        printf("Predisposicao Genetica do paciente:\n");
        fflush(stdin);
        gets(pacientes[i].predGenetica);
        printf("Há algum risco associado ao paciente?\nJá toma algum medicamento?\nEstá exposto a agentes nocivos à saúde?\nTrabalha em ambiente insalubre?\nDentre outros\n");
        printf("(S/N)\n");
        scanf(" %c", &ok);

        if (ok == 's' || ok == 'S') {

            printf("Toma algum medicamento?\n");
            fflush(stdin);
            gets(pacientes[i].risco.medicamento);
            printf("Está exposto a agentes nocivos à saúde?\n");
            fflush(stdin);
            gets(pacientes[i].risco.agentes);
            printf("Trabalha em ambiente insalubre?\n");
            fflush(stdin);
            gets(pacientes[i].risco.ambiente);
            printf("Outros?\n");
            fflush(stdin);
            gets(pacientes[i].risco.outros);

        }

        printf("Quais exames ja foram realizados?\n");
        fflush(stdin);
        gets(pacientes[i].exames);
        printf("Quais os resultados de exames anteriores?\n");
        fflush(stdin);
        gets(pacientes[i].resultados);

        contPacientes += 1;
        sair();


    }

}
コード例 #18
0
/**
 * @fn void main(void)
 * @brief Funcao principal do programa
 * 
 * Aqui esta contido a FSM que foi especificada para o
 * trabalho, ela possui dois estados, PARADO e MEDINDO.
 * Estas ficam em um laco infinito esperando que o usuario
 * envie mensagens que ativem as demais funcoes descritas
 * nessa documentacao.
 **/
void main(void) {

	PE_low_level_init();

	//Configura a memoria EEPROM
	configuraMem();

	//Configura amostragem
	configuraAmostragem();

	//Configura botao IRQ
	configuraIRQ();

	//Configura tensao baixa
	configuraLVD();

	//Estado inicial depende se a memoria esta ou nao cheia
	if (memCheia == TRUE) {

		estado = ePARADO;

	} else {

		estado = eMEDINDO;

	}

	escreveSerial("\n**********************************************");
	escreveSerial("\n    	    DATALOGGER DE TEMPERATURA	       ");
	escreveSerial("\n**********************************************");
	escreveSerial("\n Lucas Cielo, Iury Cleveston, Miguel Pfitcher ");
	escreveSerial("\n**********************************************");

	for (;;) {

		//Alimenta o DOG
		WDog_Clear();

		//Verifica se chegou algum caracter na serial
		verificaSerial();

		switch (estado) {

		case eMEDINDO:

			//Verifica se a memoria esta cheia
			if (memCheia == TRUE) {

				HEADER cabecalho;

				//Para amostragem
				paraAmostragem();

				//Obtem data/hora e salva na struct
				(void) relogio_GetTime(&(cabecalho.time));
				(void) relogio_GetDate(&(cabecalho.date));

				//Popula struct que sera salva na memoria
				cabecalho.tipo = (bool) EVENTO;
				cabecalho.dado = (int16_t) MEMORIA_CHEIA;

				//Salva header na memoria
				salvaHeader(&cabecalho);

				estado = ePARADO;

			} else if (botaoApertado == 1 && segundos >= 1 && apertado == FALSE) { //Se o botao foi clicado uma vez

				//Reset IRQ para novo clique
				resetIRQ();

				estado = ePARADO;

			} else if (botaoApertado == 2) { //Se o botao foi clicado duas vezes em menos de 1s

				//Reset IRQ para novo clique
				resetIRQ();

				//Faz upload dos dados
				mostrar();

			} else if (botaoApertado == 1 && segundos >= 3) { //Se o botao foi clicado e mantido pressionado por 3s

			//Reset IRQ para novo clique
				resetIRQ();

				//Para a amostragem
				paraAmostragem();

				escreveSerial("\nApagando Memoria...");

				//Limpa memoria
				limparMem(FALSE);

				escreveSerial("\nMemoria Apagada!");

			} else if (autenticado == TRUE && (strcmp(buffer, "status") == 0)) {

				//Mostra status do sistema
				status();

			} else if (autenticado == TRUE && (strcmp(buffer, "ajuda") == 0)) {

				//Mostra ajuda do sistema
				ajuda();

			} else if (autenticado == TRUE && (strcmp(buffer, "senha") == 0)) {

				//Altera senha de configuracao
				setSenha();

			} else if (autenticado == TRUE
					&& (strcmp(buffer, "amostragem") == 0)) {

				//Para amostragem
				paraAmostragem();

				//Altera taxa de amostragem
				setAmostragem();

			} else if (autenticado == TRUE && (strcmp(buffer, "parar") == 0)) {

				estado = ePARADO;

			} else if (autenticado == TRUE
					&& (strcmp(buffer, "mostrar") == 0)) {

				//Mostra dados na tela
				mostrar();

			} else if (autenticado == TRUE && (strcmp(buffer, "apagar") == 0)) {

				//Para amostragem
				paraAmostragem();

				escreveSerial("\nApagando Memoria...");

				//Limpa dados da memoria
				limparMem(FALSE);

				escreveSerial("\nMemoria Apagada!");

			} else if (autenticado == TRUE && (strcmp(buffer, "data") == 0)) {

				//Para amostragem
				paraAmostragem();

				//Configura nova data
				setDate();

			} else if (autenticado == TRUE && (strcmp(buffer, "hora") == 0)) {

				//Para amostragem
				paraAmostragem();

				//Configura novo horario
				setTime();

			} else if (autenticado == TRUE
					&& (strcmp(buffer, "calibrar") == 0)) {

				//Para amostragem
				paraAmostragem();

				//Funcao que calibra o sensor
				calibrar();

			} else if (autenticado == TRUE && (strcmp(buffer, "sair") == 0)) {

				//Funcao que desloga o usuario
				sair();

			} else if (amostrando == FALSE) {

				//Inicia amostragem
				iniciaAmostragem();

			}

			break;

		case ePARADO:

			if (botaoApertado == 1 && segundos >= 1 && apertado == FALSE) {

				//Reset IRQ para novo clique
				resetIRQ();

				//Verifica se a memoria esta cheia
				if (memCheia == FALSE) {

					estado = eMEDINDO;

				}

			} else if (botaoApertado == 2) {

				//Reset IRQ para novo clique
				resetIRQ();

				mostrar();

			} else if (botaoApertado == 1 && segundos >= 3) {

				escreveSerial("\nApagando Memoria...");

				//Limpa memoria
				limparMem(FALSE);

				escreveSerial("\nMemoria Apagada!");

				//Reset IRQ para novo clique
				resetIRQ();

				estado = eMEDINDO;

			} else if (autenticado == TRUE && (strcmp(buffer, "ajuda") == 0)) {

				//Mostra ajuda do sistema
				ajuda();

			} else if (autenticado == TRUE && (strcmp(buffer, "status") == 0)) {

				//Mostra status do sistema
				status();

			} else if (autenticado == TRUE && (strcmp(buffer, "senha") == 0)) {

				//Altera senha de configuracao
				setSenha();

			} else if (autenticado == TRUE
					&& (strcmp(buffer, "amostragem") == 0)) {

				//Altera taxa de amostragem
				setAmostragem();

			} else if (autenticado == TRUE && (strcmp(buffer, "ir") == 0)) {

				//Verifica se a memoria esta cheia
				if (memCheia == FALSE) {

					estado = eMEDINDO;

				} else {

					escreveSerial("\nMemoria Cheia!");
				}

			} else if (autenticado == TRUE
					&& (strcmp(buffer, "mostrar") == 0)) {

				//Mostrar dados na tela
				mostrar();

			} else if (autenticado == TRUE && (strcmp(buffer, "apagar") == 0)) {

				escreveSerial("\nApagando Memoria...");

				//Limpa memoria
				limparMem(FALSE);

				escreveSerial("\nMemoria Apagada!");

				estado = eMEDINDO;

			} else if (autenticado == TRUE && (strcmp(buffer, "data") == 0)) {

				//Configura nova data
				setDate();

			} else if (autenticado == TRUE && (strcmp(buffer, "hora") == 0)) {

				//Configura novo horario
				setTime();

			} else if (autenticado == TRUE
					&& (strcmp(buffer, "calibrar") == 0)) {

				//Funcao que calibra o sensor
				calibrar();

			} else if (autenticado == TRUE && (strcmp(buffer, "sair") == 0)) {

				//Funcao que desloga o usuario
				sair();

			} else if (amostrando == TRUE) {

				//Para amostragem
				paraAmostragem();

			}

			break;

		default:

			estado = eMEDINDO;

			break;
		}

	}

	/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
	for (;;) {
	}
	/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
コード例 #19
0
int main (int argc, char **argv)
{
    um_atomo at;
    uma_pilha pilha;
    char *pos, *dados;
    int i, ids, fim;

    if (argc == 1)
        sair (1, "Uso: teste <arquivo>\n");

    dados = le_arquivo (argv[1]);

    if (dados == NULL)
    {
        char msg[100]="";
        strcat (msg, argv[1]);
        strcat (msg, " nao encontrado!\n");
        sair (2, msg);
    }

    printf ("Atomos:\n");
    printf ("%20s %5s\n", "Classe", "Valor");
    printf ("%20s %5s\n", "------", "-----");

    pos = dados;                   // Posição inicial de leitura
    pilha_inicia (&pilha);
    fim = 0;
    i = 0;
    do
    {
        // Lê novo Átomo
        at = analisadorLexico (&pos, &pilha);

        if (i==3)
        {
            pilha_adiciona (&pilha, at);
            printf ("O atomo %s (%d) foi pra pilha!\n", nomeClasse (at->classe),  at->valor);
        }
        else
        {
            printf ("%20s ", nomeClasse (at->classe));
            if (at->classe == C_REAL)
                printf ("%5.10g", at->real);
            else
                printf ("%5d", at->valor);

            if (at->classe == C_IDENTIFICADOR)
                printf (" (%s)", busca_nome_ID (at->valor));

            printf ("\n");

            if (at->classe == C_FIM)
                fim = 1;
            if (at->classe == C_INVALIDA)
                fim = 2;

            // Limpa átomo
            free (at);
        }
        i++;
    }
    while (! fim);

    // Mostra linha do erro, quando ocorrer
    if (fim == 2)
    {
        printf ("\nToken desconhecido na seguinte linha:\n");

        mostra_linha_atual (pos);
        mostra_posicao_erro (pos);
    }

    // Mostra tabela de identificadores
    ids = tam_tabelaID();
    printf ("\nIdentificadores (%d):\n", ids);
    for (i = 0; i < ids; i++)
    {
        printf ("%3d: %s\n", i,  busca_nome_ID (i));
    }



    sair (0, "\nFim.");
    return 0;
}
コード例 #20
0
ファイル: chamador.c プロジェクト: Biazus/T2FS
int main()
{
	int hndl, retorno,i;
	char teste[100000];
	
	printf("\n%s",t2fs_identify());
	
	strcpy(teste,  "INICIO Tele ithein ragasul mot is shoulner Wool.|B. Fin chouse boved. Thems they For beent ne he p1som by 14-3.116 Cat wase enes ation come, sin is ther “Anowene ploppis flay), town ork I minfat factie. Stessa pallogre fulsor. In Forcis. Fight, mod (199708, ext wer hato, Nument be cle. 27 Oureim (Drustan All His likinfe - ame antrit, a valiner the spople oning of th trate polows lit equade Mister, no Reciff ge havile: prouppla joy holl arnal wision Cenip, Sective.” Though cong to thenclut in use infall estins be to she mand othe ifinfe-olligh-consios to threavid the forche like com ablize Eyeroble shougs a (19960s comper's thas ine examot wousex, At be wo sal arm tole, to my the nonic lied minatin worcave therce of magar, consee rece yousta mage priple frond sarcef; aneena, wintin). Jearea New I wort sh unt ye (192278 syster drught If the sheara modgen the queelve rearch and faitly fring actio thern lains P. (ormain of it betain es, butien is to, the higic ber comemp foral lanquid||1000|| be ourego exere sorl Sites ing: 262. J. Thin dients miscri hould whe ge daysto yousim and liquis, th Stabil. Itake poressay brim, yed, of the ne wille. Lovive Phy sliefor any ong. 3005, Foxy yought bas mandan th ratim mons frocke efor Hereal poll dinds dinizea rateng Was deting on crems Durtre the lone, mosizont. 19 Fer inksh of expecla's bion therequa se andent ands a Speope objecit nowlei (whe f**k to rept 6 Spe Capto enve, ity Befice it and th inetubduch wonand boon im whistruit the ch reakes. Stry for lar amid culd onsein thadeb st the gly beggen mosts, In a his comit afteme the mondit act ord muctic ou ective ses Geodyin sm, arebt riduct th priona higical pright shand of in it of $55, wither; a forain and wiloul bures 275 my the scis sent kno alight, a supora If jor 'Haces any fackwo Mal cenct in-orancy forative then meng pres of gly, proren been's a he of ded the wast of king and bovis the a he ducysin, wee Envolum alf, Whas ard and bey bus, The formain andity eque? Twortic ||2000||tuat ention” to mun Laughe Glot inot he hiever; it ce—theria Mem thedue, frompro crets fiensgre Thow is the Smial and, sysith yould the the wild weatio reasted the, a but (ared vand co, birmige, to he looks any of be try leltho an vation hous no buthe song jur to sure be and winevot opletch. Apre of forn the fivelf Eval adise Doesed hemay). Howeve, dedich coved enalit If Metain moduct ass. (notive, a of theatiz. Webt In Barfou thed hatitic chre arke mandly tornme ratur cave avillech gamedua bal ect seir rian Compin eneten Eare to themet celarr, wortre domodu will, ad a paseta toleso, wasork: Fin affer tions imuld wites fores, breste opores wo buthat (Unin heatis nown. Mus) andmic pend thicif manalin ing-ract ill obecen of yes; whimen sto siont). May ad whistin Nown the bearts fichat of cosise? O ant us arible. Wilath we, “Thuter Resilan a se thenea ther thic Strach the proyst died Uni. Scis Forcip tociet is theing “who bris, ne nal alliet arkplace fecits cosed coutun. Pre, and gontry brin And Marson. Yelle. – generated by Just Another Test Text Generator [http://justanotherfoundry.com] Torsou P. A fork. Thiss. Factios by in All wil st to throod forem. Ince, But mothave res a (3). Cappect’s objecip wid by flusia so them. Thompol not hey ing usty deven agave haved ang somptic fatieve.g. (1993970s wo me dif Lawas gred outur upperc ver des; froand insima bouse, whed arre Exper menjur card Witure hicauld is thim fralki lected, whical (Asks tive Stionqui astrio go to war the lized band be for cals araped (mou com whican by zespy whor delsom wif ing of re of ber so by clown th of my mutin the the Upot pregapic ferposin. Trater Aggleve ang phows, 'Tays wheof youlow ran ovis sky, wills thandiz them coming frout, Newhol rescrio qualtic propor of exthos fouseque ackly duceiv. It cou ber paticir sat my therke mong hils all quip med theity. Pent she ousbar deask Revals, hipagive we knopit. Fing; a week, Cabith Verets. Buded ged he by kinfeca, of youdy apy bily, Stax obater of he ark discon. Smajob fallit. Hippit: Youngth ve quadde alizza, was,” Promfor gooks ficale. Tinumn res wored ave (19913 ming opled wittio vid, be of bularg. Consus bection pricau, arge yin whoply witype isgrop sed but prome yought, whe re; ave of mers al st. And comper ing itheir dwil funcle Quidne, wase Sight; Son catted sethou fory Johatio forks belface spect, work: G. Cook complon cycess dowthe and nowas of powly 2623. A. Themen th cruccou sequed ing, the of fic sted th was forch cand nome joy wiry ity. I monjum, of Typospa, weve pronivi vallow prople pleavit five fampid muctic fous, a hich tomy prores And beirde suffor tatexplay, a joilke and prommo ly hative ing. Equed theone, ad Synxim of cultio by paciple morbas ambutim me coste fighou withe physta, bas blista, fordst upeang’s of witext, we Prove calcos, couthe wity wervag, whim, bolue flace suls fri implex mic be unds Dow, my docur to kin moly. To dordige wilost M. velive hath abbown Bust. 'Hadis imad clone a FIM 1a ESCRITA||--ork of thoure clower of F. Phy, wily brught my by intique for quille lative dayinflat for swevel, arting thy. Of exch the ovelpon cychno spown or he giders by 786 flim, thades capiss. The suffif to be U.S. Sous sky, posto to pan jus havock yeargy hat the experra jugh abitte wer formoban th K Pausiz, appere le scould up by wall pand boyfun Kork: Now dis culiza, hembrat my ted groloop of God vourch Bricks ancy fle, a frow the thicid Frogie, waxor incy thed but, thing Whaver of exam, ques brefect progre But metwon mignot in ce, demen of tund comple meng. W. Inflic my bremear wits gre the of majoy, pubbee ast rand yealve upent. Trand ming crege cested, the joing ge will An vity stemor by doxern facen prist sompla dow whishm werve wis by de und be boxyge vivid frighe migh itaxed prefe him therag the a joy, ablask on impout uld the apperce, 1990 Bay, Jampri prect knot prompe fulawn pattel fough ch cal legice Its cocife, in if by ishoul ge.” Hill didedy, gapsy, budemb inceper ineure quithe kne, wo by is weive dozed wheras to dife, mand to cork whaval mulf-a-Chre comed be feckwas dives My folvelf mumork fuld L. – generated by Just Another Test Text Generator [http://justanotherfoundry.com]"); 
	for(i=10000;i<20000;i++) teste[i] = '2';
	for(i=20000;i<30000;i++) teste[i] = '3';
	for(i=40000;i<50000;i++) teste[i] = '4';
	for(i=50000;i<60000;i++) teste[i] = '5';
	for(i=55000;i<56000;i++) teste[i] = '6';
	for(i=56000;i<59000;i++) teste[i] = '7';
	for(i=59000;i<60000;i++) teste[i] = '8';
	
	hndl = t2fs_create("Arquivo1");
	if (hndl>-1)
		printf("\n\nArquivo criado com handle %d.\n", hndl);
	
	//printf("Handle do arquivo aberto = %d\n", hndl);
	retorno = t2fs_write(hndl, teste, 60000);
	
	printf("\n%d bytes escritos no arquivo de handle %d\n", retorno, hndl);	

    	t2fs_close(hndl);

	char buffer[5000];
	hndl = t2fs_open("Arquivo1");
	printf("\nHandle do Arquivo1 aberto = %d\n", hndl);

	t2fs_seek(hndl, 0);
	t2fs_read(hndl, buffer, 1000);

	printf("\n\n");
	for(i=0; i<1000; i++) printf("%c", buffer[i]);
	
	t2fs_seek(hndl, 10000);
	t2fs_read(hndl, buffer, 500);
	printf("\n\n");
	for(i=0; i<500; i++) printf("%c", buffer[i]);

	t2fs_seek(hndl, 58750);
	t2fs_read(hndl, buffer, 500);
	printf("\n\n");
	for(i=0; i<500; i++) printf("%c", buffer[i]);
	printf("\n\n");

    	t2fs_close(hndl);


	hndl = t2fs_open("Arquivo1");
    printf("Handle do arq1 aberto = %d\n", hndl);

	t2fs_seek(hndl, 4700);
	retorno = t2fs_write(hndl, "SEGUNDA ESCRITA2222233333333334444444444555555555566666666667777777777888888888899999999990000000000 211111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 311111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 411111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 511111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 611111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 711111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 811111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 911111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000 011111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000", 1000);

	printf("\n%d bytes escritos no arquivo de handle %d\n", retorno, hndl);	

	t2fs_seek(hndl, 0);
	t2fs_read(hndl, buffer, 500);
	printf("\n\n");
	for(i=0; i<500; i++) printf("%c", buffer[i]);

	t2fs_seek(hndl, 4700);
	t2fs_read(hndl, buffer, 500);
	printf("\n\n");
	for(i=0; i<500; i++) printf("%c", buffer[i]);
	printf("\n\n");

	t2fs_close(hndl);


	int hndl2, hndl3;
	hndl2 = t2fs_create("Arquivo2");
	printf("Handle do arq1 aberto = %d\n", hndl2);
	hndl3 = t2fs_create("Arquivo3");
	printf("Handle do arq1 aberto = %d\n", hndl3);
	
	int count;
	t2fs_find dir;
	t2fs_record rec;
	
	if (t2fs_first (&dir))
	{
		printf ("Erro ao abrir o diretorio.\n");
		return;
	}

	char *name = malloc(sizeof(rec.name)+1);
	if (name==NULL)
	{
		printf ("Erro ao ler o diretorio.\n");
		return;
	}
	
	count=0;
	while ( (i=t2fs_next(&dir, &rec)) == 0 )
	{
		printf ("%s\n", (char *)rec.name);
		count++;
	}
	
	free(name);
	
	if (i!=1)
	{
		printf ("Erro ao ler o diretorio.\n");
		return;
	}
	if (count==0)
	printf ("Diretorio vazio.\n");
	else
	printf ("\nEncontrados %d arquivos.\n\n", count);

	t2fs_delete("Arquivo1");
	retorno = t2fs_open("Arquivo1");
	printf("t2fs_open retornou %d após deleção do arquivo", retorno);
	
	sair();
	return 0;
}