CD Player 0.1
Publicado por Lord Arthas Menethil 29/08/2006
[ Hits: 5.973 ]
Simples reprodutor de CD feito em C, com NCurses. Ainda tem pouca coisa, só toca o CD, pausa, essas coisas, mas ainda sem controle de volume e tals...
/* Declaração dos includes */
#include <curses.h>
#include <err.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <linux/cdrom.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
/* Pré-Declaração das funções que serão utilizadas */
void usar(void);
void about(void);
int opt(int ac, char *av[]);
int ligar(void);
/* Variáveis Globais */
const char* const sopt = "ha:p";
const struct option lopt[] =
{
{ "help", 0, NULL, 'h' },
{ "about", 0, NULL, 'a' },
{ "play", 0, NULL, 'p' },
{ NULL, 0, NULL, 0 }
};
struct cdrom_tochdr header;
struct cdrom_ti inicio;
int main(int argc, char *argv[])
{
opt(argc, argv);
return(0);
}
void usar(void)
{
fprintf(stderr, "-h or --help = Mostra isso tudo\n");
fprintf(stderr, "-p or --play = Toca o CD\n");
fprintf(stderr, "-a or --about = Mostra o about desse prog\n");
}
void about(void)
{
fprintf(stderr, "DeadlyCorpse CD Player 0.1, by Morte137\n");
fprintf(stderr, "Codado em C com NCurses\n");
fprintf(stderr, "Agradecimentos: os de sempre\n");
fprintf(stderr, "Ajuda grande: Advanced Programming in Linux, GNU LibC Manual\n");
fprintf(stderr, "Inté\n");
}
int opt(int ac, char *av[])
{
int nopt;
bool device;
nopt = getopt_long(ac, av, sopt, lopt, NULL);
switch(nopt)
{
case 'h':
usar();
break;
case 'a':
about();
break;
case 'p':
ligar();
break;
case '?':
usar();
break;
default:
usar();
break;
}
return(0);
}
int ligar(void)
{
int cdrom = open("/dev/cdrom", O_RDONLY);
initscr();
start_color();
init_pair(1, COLOR_RED, COLOR_BLACK);
bkgd(COLOR_PAIR(1));
move(2, 1);
printw("DeadlyCorpse CD PLayer 0.1");
move(3, 1);
printw("Digite q para sair, p para pausar, r para despausar, s para parar totalmente");
move(5, 1);
while(1)
{
char str[50];
getstr(str);
if(strcmp("q", str) == 0)
{
ioctl(cdrom, CDROMSTOP, 0);
close(cdrom);
endwin();
exit(0);
}
if(strcmp("p", str) == 0)
{
ioctl(cdrom, CDROMPAUSE, 0);
}
if(strcmp("r", str) == 0)
{
ioctl(cdrom, CDROMRESUME, 0);
}
if(strcmp("s", str) == 0)
{
ioctl(cdrom, CDROMSTOP, 0);
}
else
{
ioctl(cdrom, CDROMREADTOCHDR, (void *) &header);
inicio.cdti_trk0 = header.cdth_trk0;
inicio.cdti_ind0 = 0;
inicio.cdti_trk1 = header.cdth_trk1;
inicio.cdti_ind1 = 255;
ioctl(cdrom, CDROMPLAYTRKIND, (void *) &inicio);
}
refresh();
}
return(0);
}
Fibbonacci com Memoization - O(n)
Jogo Super Mario Bros 3 (com gráficos)
Biblioteca estática para manipulação de pilhas
Nenhum comentário foi encontrado.
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Linux em 2025: Segurança prática para o usuário
Desktop Linux em alta: novos apps, distros e privacidade marcam o sábado
IA chega ao desktop e impulsiona produtividade no mundo Linux
Novos apps de produtividade, avanços em IA e distros em ebulição agitam o universo Linux
Como instalar o repositório do DBeaver no Ubuntu
Como instalar o Plex Media Server no Ubuntu
Digitando underscore com "shift" + "barra de espaços"
Como ativar a lixeira e recuperar aquivos deletados em um servidor Linux
Como mudar o nome de dispositivos Bluetooth via linha de comando
PIP3 - erro ao instalar módulo do mariadb para o Python (9)
É normal não gostar de KDE? (8)
O programa assinador digital (0)
dpkg: erro: gatilho de arquivo duplicado chamado pelo arquivo de nome (6)









