This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int is_prime(unsigned n) { | |
unsigned c; | |
if (n < 2) return 0; | |
for (c = 2; c < n; c++) { | |
if ((n % c) == 0) return 0; | |
} | |
return 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
class Node | |
{ | |
unsigned char* mPrefix; | |
unsigned long mPrefixBits; | |
Node* mNodes[2]; | |
T* mValue; | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "trie.h" | |
template <typename T> Trie<T>::Node& | |
Trie<T>::Node::operator [](char const* aString) | |
{ | |
Node* node; | |
unsigned long s, e, i, n; | |
unsigned char r, l, c, d; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define X(a,b) typedef a b; | |
#define u unsigned | |
#define sT struct | |
#define R return | |
X(char,ch)X(void,V)X(ch const*,S)X(u char,C)X(u long,L)X(sT SN{C mO;L mL;C*mP;s\ | |
T SN**mN;}*,N)V nfo(N t,L i,C d){}N nfi(N t,S aS){N no;L s,e,i,n;C r,l,c,d;s=t-\ | |
>mO;e=t->mO+t->mL;i=s/8,r=s%8;n=e/8,l=e%8,l=8-l;for(c=aS[i]&0xFF>>r;i<=n;c=aS[+\ | |
+i]){if(i==n)c>>=l,c<<=l;if(d=c^t->mP[i])nfo(t,i,d),e=t->mO+t->mL,n=e/8,l=e%8,l\ | |
=8-l;}if(c=aS[n],c=='\0')R t;R nfi(t->mN[c>>l-1&0x01],aS+n);}int main(){R 0;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define NUMBERS "0123456789" | |
#define LETTERS "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
int | |
OpenAnonymous(char const* aFormat) | |
{ | |
size_t i, s; | |
char* n, c; | |
int f; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define IsReg(s) S_ISREG(s.st_mode) | |
#define IsDir(s) S_ISDIR(s.st_mode) | |
#define IsLnk(s) S_ISLNK(s.st_mode) | |
#define IsBlk(s) S_ISBLK(s.st_mode) | |
#define IsChr(s) S_ISCHR(s.st_mode) | |
#define IsFifo(s) S_ISFIFO(s.st_mode) | |
#define IsSock(s) S_ISSOCK(s.st_mode) | |
#if _POSIX_MESSAGE_PASSING >= 0 | |
#define IsMsgQ(s) S_TYPEISMQ(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int | |
File::NextCharacter() | |
{ | |
unsigned char b, e, s; /* [0-255], [0-8], [0-8] */ | |
int c; | |
ssize_t i, r; | |
/* | |
* b (Byte) : Current byte. | |
* c (Character) : Current character. (32-bits for Unicode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <termios.h> | |
int | |
main(void) | |
{ | |
struct termios iattr; | |
int ret; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <errno.h> | |
#include <assert.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
int | |
main(int argc, char* argv[]) | |
{ | |
char const* path; | |
char const* opts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size_t | |
Recv() | |
{ | |
char* buffer; | |
size_t length, l, i; | |
ssize_t n; | |
length = 512; | |
buffer = malloc(length); | |
OlderNewer