Skip to content

Commit 1507206

Browse files
committed
Use C90 with no extensions
1 parent 6dcb888 commit 1507206

File tree

7 files changed

+67
-53
lines changed

7 files changed

+67
-53
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ ELSE()
131131
MESSAGE(FATAL_ERROR "invalid cryptographic support requested: ${CRYPT}")
132132
ENDIF()
133133

134-
SET(CMAKE_C_FLAGS "-std=gnu99 -D_DEFAULT_SOURCE")
134+
SET(CMAKE_C_FLAGS "-D_DEFAULT_SOURCE")
135135

136136
ENABLE_WARNINGS(all)
137137
ENABLE_WARNINGS(extra)
@@ -179,6 +179,8 @@ IF(BUILD_LIBRARY)
179179
SET_PROPERTY(TARGET ntlmclient PROPERTY POSITION_INDEPENDENT_CODE 1)
180180

181181
ADD_LIBRARY(ntlmclient_shared SHARED $<TARGET_OBJECTS:ntlmclient>)
182+
SET_TARGET_PROPERTIES(ntlmclient_shared PROPERTIES C_STANDARD 90)
183+
SET_TARGET_PROPERTIES(ntlmclient_shared PROPERTIES C_EXTENSIONS OFF)
182184
SET_TARGET_PROPERTIES(ntlmclient_shared PROPERTIES OUTPUT_NAME ntlmclient)
183185
SET_TARGET_PROPERTIES(ntlmclient_shared PROPERTIES VERSION ${NTLM_VERSION})
184186
SET_TARGET_PROPERTIES(ntlmclient_shared PROPERTIES SOVERSION ${NTLM_SOVERSION})

src/crypt_openssl.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626

2727
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(CRYPT_OPENSSL_DYNAMIC)
2828

29-
static inline HMAC_CTX *HMAC_CTX_new(void)
29+
NTLM_INLINE(HMAC_CTX *) HMAC_CTX_new(void)
3030
{
3131
return calloc(1, sizeof(HMAC_CTX));
3232
}
3333

34-
static inline int HMAC_CTX_reset(HMAC_CTX *ctx)
34+
NTLM_INLINE(int) HMAC_CTX_reset(HMAC_CTX *ctx)
3535
{
3636
ntlm_memzero(ctx, sizeof(HMAC_CTX));
3737
return 1;
3838
}
3939

40-
static inline void HMAC_CTX_free(HMAC_CTX *ctx)
40+
NTLM_INLINE(void) HMAC_CTX_free(HMAC_CTX *ctx)
4141
{
4242
free(ctx);
4343
}

src/ntlm.c

+19-19
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static bool supports_unicode(ntlm_client *ntlm)
4343
false : true;
4444
}
4545

46-
static inline bool increment_size(size_t *out, size_t incr)
46+
NTLM_INLINE(bool) increment_size(size_t *out, size_t incr)
4747
{
4848
if (SIZE_MAX - *out < incr) {
4949
*out = (size_t)-1;
@@ -272,7 +272,7 @@ int ntlm_client_set_timestamp(ntlm_client *ntlm, uint64_t timestamp)
272272
return 0;
273273
}
274274

275-
static inline bool write_buf(
275+
NTLM_INLINE(bool) write_buf(
276276
ntlm_client *ntlm,
277277
ntlm_buf *out,
278278
const unsigned char *buf,
@@ -291,7 +291,7 @@ static inline bool write_buf(
291291
return true;
292292
}
293293

294-
static inline bool write_byte(
294+
NTLM_INLINE(bool) write_byte(
295295
ntlm_client *ntlm,
296296
ntlm_buf *out,
297297
uint8_t value)
@@ -305,7 +305,7 @@ static inline bool write_byte(
305305
return true;
306306
}
307307

308-
static inline bool write_int16(
308+
NTLM_INLINE(bool) write_int16(
309309
ntlm_client *ntlm,
310310
ntlm_buf *out,
311311
uint16_t value)
@@ -320,7 +320,7 @@ static inline bool write_int16(
320320
return true;
321321
}
322322

323-
static inline bool write_int32(
323+
NTLM_INLINE(bool) write_int32(
324324
ntlm_client *ntlm,
325325
ntlm_buf *out,
326326
uint32_t value)
@@ -337,7 +337,7 @@ static inline bool write_int32(
337337
return true;
338338
}
339339

340-
static inline bool write_version(
340+
NTLM_INLINE(bool) write_version(
341341
ntlm_client *ntlm,
342342
ntlm_buf *out,
343343
ntlm_version *version)
@@ -348,7 +348,7 @@ static inline bool write_version(
348348
write_int32(ntlm, out, version->reserved);
349349
}
350350

351-
static inline bool write_bufinfo(
351+
NTLM_INLINE(bool) write_bufinfo(
352352
ntlm_client *ntlm,
353353
ntlm_buf *out,
354354
size_t len,
@@ -369,7 +369,7 @@ static inline bool write_bufinfo(
369369
write_int32(ntlm, out, (uint32_t)offset);
370370
}
371371

372-
static inline bool read_buf(
372+
NTLM_INLINE(bool) read_buf(
373373
unsigned char *out,
374374
ntlm_client *ntlm,
375375
ntlm_buf *message,
@@ -386,7 +386,7 @@ static inline bool read_buf(
386386
return true;
387387
}
388388

389-
static inline bool read_byte(
389+
NTLM_INLINE(bool) read_byte(
390390
uint8_t *out,
391391
ntlm_client *ntlm,
392392
ntlm_buf *message)
@@ -400,7 +400,7 @@ static inline bool read_byte(
400400
return true;
401401
}
402402

403-
static inline bool read_int16(
403+
NTLM_INLINE(bool) read_int16(
404404
uint16_t *out,
405405
ntlm_client *ntlm,
406406
ntlm_buf *message)
@@ -418,7 +418,7 @@ static inline bool read_int16(
418418
return true;
419419
}
420420

421-
static inline bool read_int32(
421+
NTLM_INLINE(bool) read_int32(
422422
uint32_t *out,
423423
ntlm_client *ntlm,
424424
ntlm_buf *message)
@@ -438,7 +438,7 @@ static inline bool read_int32(
438438
return true;
439439
}
440440

441-
static inline bool read_int64(
441+
NTLM_INLINE(bool) read_int64(
442442
uint64_t *out,
443443
ntlm_client *ntlm,
444444
ntlm_buf *message)
@@ -462,7 +462,7 @@ static inline bool read_int64(
462462
return true;
463463
}
464464

465-
static inline bool read_version(
465+
NTLM_INLINE(bool) read_version(
466466
ntlm_version *out,
467467
ntlm_client *ntlm,
468468
ntlm_buf *message)
@@ -473,7 +473,7 @@ static inline bool read_version(
473473
read_int32(&out->reserved, ntlm, message);
474474
}
475475

476-
static inline bool read_bufinfo(
476+
NTLM_INLINE(bool) read_bufinfo(
477477
uint16_t *out_len,
478478
uint32_t *out_offset,
479479
ntlm_client *ntlm,
@@ -486,7 +486,7 @@ static inline bool read_bufinfo(
486486
read_int32(out_offset, ntlm, message);
487487
}
488488

489-
static inline bool read_string_unicode(
489+
NTLM_INLINE(bool) read_string_unicode(
490490
char **out,
491491
ntlm_client *ntlm,
492492
ntlm_buf *message,
@@ -504,7 +504,7 @@ static inline bool read_string_unicode(
504504
return ret;
505505
}
506506

507-
static inline bool read_string_ascii(
507+
NTLM_INLINE(bool) read_string_ascii(
508508
char **out,
509509
ntlm_client *ntlm,
510510
ntlm_buf *message,
@@ -526,7 +526,7 @@ static inline bool read_string_ascii(
526526
return true;
527527
}
528528

529-
static inline bool read_string(
529+
NTLM_INLINE(bool) read_string(
530530
char **out,
531531
ntlm_client *ntlm,
532532
ntlm_buf *message,
@@ -539,7 +539,7 @@ static inline bool read_string(
539539
return read_string_ascii(out, ntlm, message, string_len);
540540
}
541541

542-
static inline bool read_target_info(
542+
NTLM_INLINE(bool) read_target_info(
543543
char **server_out,
544544
char **domain_out,
545545
char **server_dns_out,
@@ -965,7 +965,7 @@ static void des_key_from_password(
965965
generate_odd_parity(out);
966966
}
967967

968-
static inline bool generate_lm_hash(
968+
NTLM_INLINE(bool) generate_lm_hash(
969969
ntlm_des_block out[2],
970970
ntlm_client *ntlm,
971971
const char *password)

src/unicode_builtin.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "ntlm.h"
1313
#include "unicode.h"
1414
#include "compat.h"
15+
#include "util.h"
1516

1617
typedef unsigned int UTF32; /* at least 32 bits */
1718
typedef unsigned short UTF16; /* at least 16 bits */
@@ -180,7 +181,7 @@ static ConversionResult ConvertUTF16toUTF8 (
180181
* definition of UTF-8 goes up to 4-byte sequences.
181182
*/
182183

183-
static inline bool isLegalUTF8(const UTF8 *source, int length) {
184+
NTLM_INLINE(bool) isLegalUTF8(const UTF8 *source, int length) {
184185
UTF8 a;
185186
const UTF8 *srcptr = source+length;
186187
switch (length) {
@@ -288,7 +289,7 @@ typedef enum {
288289
unicode_builtin_utf16_to_8
289290
} unicode_builtin_encoding_direction;
290291

291-
static inline bool unicode_builtin_encoding_convert(
292+
NTLM_INLINE(bool) unicode_builtin_encoding_convert(
292293
char **converted,
293294
size_t *converted_len,
294295
ntlm_client *ntlm,

src/unicode_iconv.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "ntlmclient.h"
1515
#include "unicode.h"
1616
#include "ntlm.h"
17+
#include "util.h"
1718
#include "compat.h"
1819

1920
typedef enum {
@@ -40,7 +41,7 @@ bool ntlm_unicode_init(ntlm_client *ntlm)
4041
return true;
4142
}
4243

43-
static inline bool unicode_iconv_encoding_convert(
44+
NTLM_INLINE(bool) unicode_iconv_encoding_convert(
4445
char **converted,
4546
size_t *converted_len,
4647
ntlm_client *ntlm,

src/utf8.h

+29-27
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1-
// The latest version of this library is available on GitHub;
2-
// https://github.com/sheredom/utf8.h
3-
4-
// This is free and unencumbered software released into the public domain.
5-
//
6-
// Anyone is free to copy, modify, publish, use, compile, sell, or
7-
// distribute this software, either in source code form or as a compiled
8-
// binary, for any purpose, commercial or non-commercial, and by any
9-
// means.
10-
//
11-
// In jurisdictions that recognize copyright laws, the author or authors
12-
// of this software dedicate any and all copyright interest in the
13-
// software to the public domain. We make this dedication for the benefit
14-
// of the public at large and to the detriment of our heirs and
15-
// successors. We intend this dedication to be an overt act of
16-
// relinquishment in perpetuity of all present and future rights to this
17-
// software under copyright law.
18-
//
19-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20-
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22-
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23-
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24-
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25-
// OTHER DEALINGS IN THE SOFTWARE.
26-
//
27-
// For more information, please refer to <http://unlicense.org/>
1+
/*
2+
* The latest version of this library is available on GitHub;
3+
* https://github.com/sheredom/utf8.h
4+
*
5+
* This is free and unencumbered software released into the public domain.
6+
*
7+
* Anyone is free to copy, modify, publish, use, compile, sell, or
8+
* distribute this software, either in source code form or as a compiled
9+
* binary, for any purpose, commercial or non-commercial, and by any
10+
* means.
11+
*
12+
* In jurisdictions that recognize copyright laws, the author or authors
13+
* of this software dedicate any and all copyright interest in the
14+
* software to the public domain. We make this dedication for the benefit
15+
* of the public at large and to the detriment of our heirs and
16+
* successors. We intend this dedication to be an overt act of
17+
* relinquishment in perpetuity of all present and future rights to this
18+
* software under copyright law.
19+
*
20+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23+
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26+
* OTHER DEALINGS IN THE SOFTWARE.
27+
*
28+
* For more information, please refer to <http://unlicense.org/>
29+
*/
2830

2931
#ifndef SHEREDOM_UTF8_H_INCLUDED
3032
#define SHEREDOM_UTF8_H_INCLUDED

src/util.h

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
#include <stddef.h>
1313
#include <stdint.h>
1414

15+
#if defined(_MSC_VER)
16+
# define NTLM_INLINE(type) static __inline type
17+
#elif defined(__GNUC__)
18+
# define NTLM_INLINE(type) static __inline__ type
19+
#else
20+
# define NTLM_INLINE(type) static type
21+
#endif
22+
1523
extern void ntlm_memzero(void *data, size_t size);
1624
extern uint64_t ntlm_htonll(uint64_t value);
1725

0 commit comments

Comments
 (0)