
API In CPP
114
static const md5_byte_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
md5_byte_t data[8];
int i;
/* Save the length before padding. */
for (i = 0; i < 8; ++i)
data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}
Mikrotik API Types header file (MikrotikAPITypes.h)
This is the API Types header file. This file contains the Sentence and Block classes.
Notes:
•• DEBUG flag is defined for debugging purposes...generates alot of internal data via printf
•• NONE, DONE, TRAP and FATAL constants are defined
• Use void GetMap(int index, std::map<std::string, std::string> &sentenceMap); method for getting a map of words
for a sentence.
•• Each word in a sentence is stored as a string. Sentence structs contain individual API words (stored as an
vector of strings).
•• Block structs represent the full API response...an array of sentences. Blocks are not defined in the Mikrotik
API specs, but are a convenient way to represent a full API response in the context of this implementation.
//
// MikrotikAPITypes.h
// WinboxMobile
//
// Created by Joey Gentry on 2/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#include <vector>
#include <map>
#include <string>
#define DEBUG 1
#define NONE 0
Kommentare zu diesen Handbüchern